If you asked on the forum here how to set document visibility you would probably get a response like this:
Code: Select all
for obj in FreeCAD.ActiveDocument.Objects:
if hasattr(obj,'ViewObject'):
obj.ViewObject.Visibility = True
1) Using a bunch of if statements we only process certain objects
2) We determine if the object is of the Part family or a Body object. If the object is a Body then the last feature(Tip) is used to select visibility.
A description of the macro logic.
The "for" loop will run thru the entire document.
1) Use a bunch of "if" statements so we can be selective.
2) Decide if we have a Body object or Part object.
3) If a Body object then find the name of it's "Tip".
5) If we have a Tip-name then go search the entire document and find that feature by name, this is the target to set the object visibility.
6) If not a Body but instead a Part object then we can set visibility directly.
The Print message statement is great, I don't know who wrote but it sure helped me a bunch. If you turn it on you can see the doc structure in the Report view.
All comments are welcome.