cadquery icon indicating copy to clipboard operation
cadquery copied to clipboard

Export a separate STL for each object in a STEP file

Open 0xCoto opened this issue 3 years ago • 1 comments

I'm new to CadQuery, trying to transition from FreeCAD to carry out some modelling automation/operations.

I've managed to load a STEP file, and export it as an STL:

result = cq.importers.importStep("data/" + step_file)
cq.exporters.export(result, "data/" + stl)

What I couldn't quite find on the documentation is whether it is also possible to export an STL for each shape/object individually? E.g. if the STEP consists of 3 cubes, I should get 3 separate STLs.

0xCoto avatar Aug 23 '22 22:08 0xCoto

Figured it out:

shapes = model.objects[0]
for i, shape in enumerate(shapes):
    shape.exportStl("obj_"+str(i)+".stl")

Follow-up question: is it possible to maintain the name of each shape (like it's maintained when you open a STEP file with FreeCAD and see the name of each object)?

0xCoto avatar Aug 24 '22 02:08 0xCoto