How to get a tree view of objects with their types?

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
elsordo
Posts: 70
Joined: Sat Jan 30, 2016 6:34 am

How to get a tree view of objects with their types?

Post by elsordo »

I was poking around in this forum and I saw the following image.
treeview.png
treeview.png (33.25 KiB) Viewed 464 times
How do I enable this view of the model in the combo view? I'm attempting to learn how to traverse a model and this would help me understand how the model is constructed.

-David
freedman
Veteran
Posts: 3472
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: How to get a tree view of objects with their types?

Post by freedman »

This may be some help.

Code: Select all

doc = FreeCAD.ActiveDocument
for obj in doc.Objects:
    FreeCAD.Console.PrintMessage("obj.Name = "+obj.Name+"\nobj.Label = "+obj.Label+"\nstr(obj) = "+str(obj)+"\nstr(type(obj)) = "+str(type(obj))+ "\nobj.TypeId = "+obj.TypeId  +  " \n\n")
Post Reply