visualdynamics.io.threemf¶
threemf
¶
3MF meshes — the CAD hand-off format that keeps parts and units.
A .3mf is a zip holding one XML model: already-tessellated
triangles (our tri3 face elements verbatim), named objects for
an assembly's parts — each becomes a named block — and a declared
unit, so nothing has to be asked at import. SolidWorks writes it from
Save As, which is why this importer exists: "import my SolidWorks
model" is an export to 3MF away, where the native format is closed
and STEP needs a geometry kernel this project deliberately does not
carry (see PLAN.md).
Assemblies arrive as component references with affine transforms;
they are resolved recursively, so each placed instance of a part
gets its triangles where the assembly put them. Everything here is
the standard library — zipfile and xml.etree — plus numpy.
Functions:
| Name | Description |
|---|---|
load |
Read a 3MF file as a geometry — one named block per placed part. |
save |
Write the geometry's face elements as 3MF — one named object |
Classes¶
Functions:¶
load
¶
load(path: str | PathLike) -> Geometry
Read a 3MF file as a geometry — one named block per placed part.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or path - like
|
The |
required |
Returns:
| Type | Description |
|---|---|
Geometry
|
Triangle face elements in metres (the file's declared unit is
converted, so |
Source code in src/visualdynamics/io/threemf.py
save
¶
save(
obj: Geometry,
path: str | PathLike,
unit_system: Any = None,
) -> None
Write the geometry's face elements as 3MF — one named object
per block, in metres (3MF can say so, so nothing is lost to an
assumed unit; unit_system is accepted for the exporter registry
and unused, because the file declares its own).
A geometry with no face elements is refused, like STL.