cadquery
cadquery copied to clipboard
Export a separate STL for each object in a STEP file
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.
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)?