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 binary

Lossless for everything a MeshResult holds: 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 .mkb extension.

.2dm — SMS 2DM

Read and written with MESH2D, ND, E3T, E4Q and NS records. 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 unless allow_attribute_loss is true; the report’s losses lists what was dropped. Any extension other than .mkb is 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

overwrite

False

Replace an existing file (write). Without it, writing to an existing path returns a report whose complete is false.

durable

False

Flush the temporary file to storage before publishing it (write).

allow_attribute_loss

False

Let a 2DM write drop attributes 2DM cannot hold (write).

legacy_2dm

False

Accept historical non-positive IDs and optional or text material labels (2DM read).

ignore_unknown_records

False

Skip unknown 2DM cards and count them, returning complete_with_exceptions, instead of failing (2DM read).

limits

see Options

Count, workspace and record-size limits.