cad3d-ir-step
cad3d-ir-step imports STEP (AP203, AP214, AP242) and IGES files into
cad3d-ir through Open CASCADE XDE. It preserves product definitions,
assembly occurrences, local placements, names and surface colours, exports
each reusable leaf shape as an external OCCT B-Rep resource and, on request,
tessellates everything into glTF binary display meshes. Since 0.3.0 it also
writes STEP: a STEP or IGES document re-exported in another schema or unit,
or a faceted STEP built from the triangles of a visualization GLB. Since 0.4.0
that faceted STEP can also be written straight from the mesh topology, without
OCCT sewing, so large assemblies are no longer limited to 20,000 triangles.
The runtime uses the official cadquery-ocp-novtk binding because conversion
does not require VTK or a visualization stack.
The distribution intentionally depends on cad3d-ir; the core distribution
does not depend on this adapter or on Open CASCADE.
Usage
from pathlib import Path
from cad3d_ir import DirectoryResourceWriter
from cad3d_ir.importers import ImportOptions
from cad3d_ir_step import IgesImporter, StepImporter
output = Path("converted")
result = StepImporter().import_file(
Path("assembly.step"),
options=ImportOptions(include_visualization_mesh=True),
resources=DirectoryResourceWriter(output),
)
preview = result.package.visualizations[0] # preview/<package>.glb
IgesImporter().import_file(Path("part.igs"), options=ImportOptions(), resources=...)
The command-line entry point picks the importer from the file content and
writes manifest.json plus geometry resources:
cad3d-ir-step assembly.step converted/ # B-Rep resources only
cad3d-ir-step assembly.step converted/ --mesh # + per-body GLB + package GLB
cad3d-ir-step robot.stp converted/ --mesh --no-brep --deflection-ratio 0.002
cad3d-ir-step part.igs converted/ --mesh
Writing STEP
from cad3d_ir_step import MeshTooLargeError, export_step, mesh_to_step
# STEP or IGES -> STEP in another schema / unit. Definition colours are copied
# onto the component labels first, so instanced parts keep their colour.
result = export_step("assembly.igs", "assembly.step", schema="AP242", unit="mm")
print(result.products, result.components, result.colors_copied, result.byte_length)
# Triangles of a cad3d-ir GLB -> one sewn solid per placed body (planar
# triangular faces; opens anywhere, not editable). Capped at 20,000 triangles
# because sewing time grows with the square of the count.
try:
mesh = mesh_to_step(open("part.glb", "rb").read(), "part.step")
except MeshTooLargeError as exc:
print(exc.triangles, exc.limit)
else:
print(mesh.solids, mesh.open_shells, mesh.volume_mm3, mesh.diagnostics[0].code)
export_step(verify=True) reads the written file back and reports fewer
coloured shapes as STEP_COLORS_CHANGED; PMI that is not written is reported
as STEP_PMI_NOT_WRITTEN. mesh_to_step(mode="tessellated") writes AP242
TRIANGULATED_FACE entities instead of solids (about 80 bytes per triangle
instead of 2.4 KB), which not every CAD reads. Mesh results always carry
STEP_MESH_SOLID_FACETED or STEP_MESH_TESSELLATED; open shells are reported
as STEP_MESH_FREE_EDGES.
Writing a mesh directly
from cad3d_ir.mesh import read_glb
from cad3d_ir_step import estimate_mesh_step, write_mesh_step
scene = read_glb(open("assembly.glb", "rb").read())
estimate = estimate_mesh_step(scene) # counted without writing
if estimate.byte_length < 200 * 2**20:
result = write_mesh_step(scene, "assembly.step", schema="AP214")
print(result.parts, result.placements, result.solids, result.open_shells)
write_mesh_step (AP214 or AP242) builds the topology from the mesh instead
of sewing OCCT faces, so its time grows linearly with the triangle count:
- each mesh is written once as a part and every node that places it becomes an
assembly component; a placement that mirrors or scales its mesh is written
as its own part (
STEP_MESH_PLACEMENTS_BAKED); - the vertex sets of a mesh are welded on identical positions, so faces that
were tessellated separately join again; triangles that share an edge share
one
EDGE_CURVEand are oriented consistently; - a part whose components all close is written as outward-oriented
MANIFOLD_SOLID_BREPs; otherwise as aSHELL_BASED_SURFACE_MODEL(STEP_MESH_FREE_EDGES); - every triangle is an
ADVANCED_FACEon aPLANEwithLINEedges (about 600–800 bytes per written triangle;edge_curve="polyline"is about a fifth smaller but slower to read in OCCT); - each solid or surface model takes its most common colour and triangles of another colour are styled individually; names come from the GLB meshes and nodes.
estimate_mesh_step returns the triangles that would be written (each mesh
once), the triangles once every placement is expanded, and a rough size
(DIRECT_BYTES_PER_TRIANGLE per triangle).
cad3d-ir-step-export assembly.step assembly-ap203.step --schema AP203
cad3d-ir-step-export part.igs part.step --unit inch --verify
cad3d-ir-step-export preview.glb part.step --max-triangles 20000
cad3d-ir-step-export preview.glb part.step --mode tessellated
cad3d-ir-step-export preview.glb assembly.step --mode direct
Options
ImportOptions (core):
include_visualization_mesh– write onemeshrepresentation per body and one package-levelVisualization(GLB). Off by default.include_brep– write exact OCCT B-Rep ASCII resources. On by default.mesh_linear_deflection_ratio– linear deflection as a ratio of the root bounding-box diagonal (default0.001);mesh_angular_deflectionin radians (default0.3);mesh_include_edgesfor edge polylines.
StepImporter(require_ap242=False, body_mesh_resources=True):
require_ap242=Truerestores the 0.1 behaviour of rejecting other schemas before any geometry is transferred. By default AP203/AP214 files are read and an informationalSTEP_SCHEMA_NOT_AP242diagnostic is emitted.body_mesh_resources=Falsekeeps only the package GLB when meshes are requested (what a viewer needs; halves the written bytes).
Current boundary
- STEP Part 21 files with any AP schema and IGES 5.x files are accepted; the mapping is the same XDE product graph for both.
- XDE product structure, names, local placements, visibility and definition surface colours are mapped. IGES carries little structure, so its packages are usually one part per shape.
- Leaf definition shapes are stored as OCCT B-Rep ASCII v1 resources
(
include_brep), as glTF binary meshes (include_visualization_mesh), or both. - One resolved
Defaultconfiguration is synthesized for every product. - PMI/GD&T, layers, physical materials and external STEP references are not
mapped; they produce
*_NOT_MAPPEDdiagnostics instead of being dropped silently. Faces that OCCT cannot triangulate are counted in*_MESH_INCOMPLETE. - Representation bounds come from
BRepBndLib::Add(surface control points), which is conservative; the visualization bounds are exact mesh bounds.
Measured on a 47 MB industrial robot STEP (12,817 faces): read 28 s, meshing 4 s, extraction and GLB 5 s, peak RSS about 730 MB, 27.6 MB GLB with 700k triangles.
Fixtures
tests/fixtures/reference-assembly.step (AP242), reference-assembly-ap214.step
and reference-assembly.iges are generated from primitive boxes and cylinders
by scripts/generate_reference_fixture.py --schema {ap242,ap214,iges} with
normalized dates and author fields. The abstraction test compares the AP242
assembly with an independent typed synthetic native-CAD source fixture.
Metadata
Release files for cad3d-ir-step 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cad3d_ir_step-0.4.0.tar.gz | 77.5 kB | Without provenance | Details for cad3d_ir_step-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cad3d_ir_step-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for cad3d_ir_step-0.4.0-py3-none-any.whl |
Total release size: 129.0 kB
Release files / cad3d_ir_step-0.4.0.tar.gz
| Download URL | cad3d_ir_step-0.4.0.tar.gz |
|---|---|
| Size | 77.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1be72f1d818c78fd88fb3d1fea729df17eda6a54b4381fca0f3d1b9eef714cc7
|
|
BLAKE2b-256 checksum How to use checksums |
58023b2c45d78ce57020f9b63e88fb960867cdfabe63ae6572ec180cb84d78d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / cad3d_ir_step-0.4.0-py3-none-any.whl
| Download URL | cad3d_ir_step-0.4.0-py3-none-any.whl |
|---|---|
| Size | 51.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
897702c3d9b09eb6078ba84247cbaeea6cf0e4f0ffdb4d8a57478726ce83f5de
|
|
BLAKE2b-256 checksum How to use checksums |
06d129ef3857a22e672f3e7c4b588a2c9a884557345cb92b48abf2bd17fd8903
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for cad3d-ir-step 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.