yapcad.io package
Submodules
yapcad.io.geometry_json module
Geometry JSON serialization/deserialization helpers.
Implements the draft schema described in docs/geometry_json_schema.md.
- yapcad.io.geometry_json.geometry_from_json(doc: Dict[str, Any]) List[list][source]
Deserialize geometry JSON into yapCAD list structures.
- yapcad.io.geometry_json.geometry_to_json(entities: Iterable[list], *, units: str | None = None, generator: Dict[str, Any] | None = None, relationships: List[Dict[str, Any]] | None = None, attachments: List[Dict[str, Any]] | None = None) Dict[str, Any][source]
Serialize solids/surfaces into the geometry JSON document.
yapcad.io.step module
STEP export utilities for yapCAD surfaces and solids.
- yapcad.io.step.write_step(obj: Sequence, path_or_file, *, name: str = 'yapCAD', schema: str = 'AUTOMOTIVE_DESIGN_CC2') None[source]
Export
obj(surface or solid) to a STEP file using a faceted BREP.
- yapcad.io.step.write_step_analytic(obj: Sequence, path: str, *, name: str = 'yapCAD', fallback_to_faceted: bool = True) bool[source]
Export
objto a STEP file using analytic BREP if available.This function attempts to export the object using its native BREP representation (with analytic surfaces like planes, cylinders, spheres). If native BREP data is not available or OCC is not installed, it can fall back to faceted BREP export.
- Parameters:
- Returns:
True if analytic export succeeded, False if fell back to faceted.
- Return type:
- Raises:
RuntimeError – If OCC is not available and fallback_to_faceted is False.
ValueError – If native BREP is not available and fallback_to_faceted is False.
yapcad.io.step_importer module
STEP import utilities backed by pythonocc-core.
yapcad.io.stl module
STL import and export utilities for yapCAD surfaces and solids.
- yapcad.io.stl.import_stl(path: str, *, deduplicate: bool = True) list[source]
Import an STL file as a yapCAD solid.
This is an alias for
read_stl()for API consistency withyapcad.io.step_importer.import_step().
- yapcad.io.stl.read_stl(path_or_file, *, deduplicate: bool = True) list[source]
Read an STL file and return a yapCAD solid.
- Parameters:
- Returns:
yapCAD solid containing a single surface with the imported mesh. The solid structure is: [‘solid’, [surface], boundary, holes]
- Return type:
solid
Examples
>>> from yapcad.io.stl import read_stl, write_stl >>> my_solid = read_stl('model.stl') >>> # Round-trip: export and re-import >>> write_stl(my_solid, 'copy.stl') >>> copy_solid = read_stl('copy.stl')
Module contents
I/O utilities for yapCAD.