Reading and writing files#
report = meshkit.write("site.mkb", result)
mesh = meshkit.read("site.mkb")
report = meshkit.write("site.2dm", mesh, options={"allow_attribute_loss": True})
print(report["losses"])
Formats#
.mkb— MeshKit binaryLossless for everything a
MeshResultholds: coordinates, cells, edges, paths, IDs, markers, region labels, source aliases and metadata. Little-endian, versioned, with a trailing checksum that detects accidental corruption (it is not a signature).meshkit.read()selects it by the.mkbextension..2dm— SMS 2DMRead and written with
MESH2D,ND,E3T,E4QandNSrecords. Clockwise cells are reoriented; degenerate or non-convex cells fail. 2DM cannot hold units, CRS, description, labels, aliases, vertex or edge markers or path roles and IDs, so writing a mesh that has them is refused unlessallow_attribute_lossis true; the report’slosseslists what was dropped. Any extension other than.mkbis read as 2DM.
Writes are atomic: the file is written to a temporary in the destination folder and published only when complete, so a failed or cancelled write leaves an existing file as it was. A failed read returns no partial mesh.
File options#
Key |
Default |
Meaning |
|---|---|---|
|
|
Replace an existing file (write). Without it, writing to an existing
path returns a report whose |
|
|
Flush the temporary file to storage before publishing it (write). |
|
|
Let a 2DM write drop attributes 2DM cannot hold (write). |
|
|
Accept historical non-positive IDs and optional or text material labels (2DM read). |
|
|
Skip unknown 2DM cards and count them, returning
|
|
see Options |
Count, workspace and record-size limits. |