Robert Bruce
Robert Bruce

Reputation: 691

Python: How do I programmatically clear the viewer in FreeCAD?

I can use a Python script to create and show a part in FreeCAD like this:

Part.show(myPart)

But if I run the script again, it overlays a second copy of myPart on top of the original. How can the Python script clear the viewer before it starts drawing? I can manually use the FreeCAD menu to "Select All" and then "Delete", but how can I automate that to speed up my workflow?

Upvotes: 2

Views: 1548

Answers (1)

Robert Bruce
Robert Bruce

Reputation: 691

This is the solution I came up with:

def clearAll():
    doc = FreeCAD.ActiveDocument
    for obj in doc.Objects:
        doc.removeObject(obj.Label)

Upvotes: 7

Related Questions