Skip to main content

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.

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.

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

Options

ImportOptions (core):

  • include_visualization_mesh – write one mesh representation per body and one package-level Visualization (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 (default 0.001); mesh_angular_deflection in radians (default 0.3); mesh_include_edges for edge polylines.

StepImporter(require_ap242=False, body_mesh_resources=True):

  • require_ap242=True restores the 0.1 behaviour of rejecting other schemas before any geometry is transferred. By default AP203/AP214 files are read and an informational STEP_SCHEMA_NOT_AP242 diagnostic is emitted.
  • body_mesh_resources=False keeps 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 Default configuration is synthesized for every product.
  • PMI/GD&T, layers, physical materials and external STEP references are not mapped; they produce *_NOT_MAPPED diagnostics 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.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cad3d-ir-step 0.3.0
File Size Uploaded Provenance
cad3d_ir_step-0.3.0.tar.gz 60.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for cad3d-ir-step 0.3.0
File Interpreter ABI Platform
cad3d_ir_step-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 98.3 kB

Release files / cad3d_ir_step-0.3.0.tar.gz

Download URL cad3d_ir_step-0.3.0.tar.gz
Size 60.5 kB
Tags Source
SHA-256 checksum
How to use checksums
372fa6deeb997a801a5647f244c6059e85cf6e199c2f8ef7805e9c23f2a1097e
BLAKE2b-256 checksum
How to use checksums
8f2745157bca18abbeacc67af55412683ad9ae5be310b8b25f2fdbce9d248756
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.3.0-py3-none-any.whl

Download URL cad3d_ir_step-0.3.0-py3-none-any.whl
Size 37.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7542b1bfd81eedb0ec25b9d1c5b82cfa925a2f840a31b7d196473a08c0c813d4
BLAKE2b-256 checksum
How to use checksums
9bee0f88cc9942bbfe003595d89880d441e641bf9637a3c1e151b3928677b03f
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.3.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.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page