Import STEP
ImportStep brings a solid from a STEP file (.step / .stp, ISO 10303-21:
AP203, AP214 or AP242) into a part as an ordinary feature. It is fused with
the part like an extrusion, and it can be the input of Fillet, Chamfer,
Shell, BooleanOperation or MoveBody.
motor = ImportStep("nema17.step") # a path, like open("nema17.step")
self.add_operation(motor)
self.add_operation(MoveBody(ImportStep("bracket.step"), Point3D(0, 0, 40)))
self.add_operation(ImportStep("pocket.step", cut=True)) # subtract it
with open("coupling.step", "rb") as f: # any open file object works too
coupling = ImportStep(f)
boss = ImportStep.from_text(step_text, "boss.step") # text already in memory
shaft = Part.from_step("shaft.step") # a Part whose only operation is the import
assy.add_component(shaft)Reading the file
ImportStep reads a file like open() does: a path (str or pathlib.Path)
is resolved from the current directory, and an open file object (text or
binary) is read as is. Getting the file onto disk is up to you: a download, an
upload or the project’s files. There is no URL or storage logic in
ImportStep.
The file’s text is stored in the part itself, with its SHA-256 and its file
name. The part is self-contained: the kernel never goes back to the file. The
example above uses ImportStep.from_text with a small inline STEP file, so it
runs anywhere.
Before anything is built, the text is checked: it must start with
ISO-10303-21; and have HEADER and DATA sections. Otherwise you get a
StepFileError that names the file.
Geometry rules
- Units: lengths are converted from the unit the file declares (mm, m, inch…) to mm. A 1 in cube comes in as 25.4 mm.
- Several solids: they are fused into one body.
- Surfaces only (no closed solid), or a file with no geometry: the build fails with an error that names the file. The result is never an empty solid.
- Placement: the solid keeps the coordinates in the file. Use
MoveBodyto move or rotate it. - Bounding box:
check_interferencecan’t bound an imported solid without the kernel. Declare its extents withpart.set_extents(...)if you need them.