realthunder / FreeCAD_assembly3

Experimental attempt for the next generation assembly workbench for FreeCAD
GNU General Public License v3.0
884 stars 74 forks source link

Assembly missing in root object #1101

Open ShuffleWire opened 2 years ago

ShuffleWire commented 2 years ago

Hello,

To reproduce the bug :
Open a new empty document in assembly3 workbench Add a assembly In the python console, enter : App.ActiveDocument.RootObjects You get : [], which is fine (and App.ActiveDocument.RootObjects[0].Label give 'Assembly') Create a link to this assembly. (I'm doing right click on the origin assembly, Link Action, Make link) In the python console, enter : App.ActiveDocument.RootObjects You get [] which is not fine, the original assembly is not listed (and App.ActiveDocument.RootObjects[0].Label give 'Link(Assembly)')

Is there anything I'm missing ?

Cheers,

PS: And btw, thanks for this workbench, it work nicely :)

OS: Debian GNU/Linux 11 (bullseye) (XFCE/xfce) Word size of FreeCAD: 64-bit Version: 2022.111.30764 (Git) AppImage Build type: Release Branch: LinkDaily Hash: ef3092bcbca5475eff4eb7ff7933eb3e9bbbe4b9 Python version: 3.9.9 Qt version: 5.12.9 Coin version: 4.0.1 OCC version: 7.5.3 Locale: English/United States (en_US)

realthunder commented 2 years ago

This is not really a bug. RootObjects is in App namespace. It's definition is object that is not depended on by any other objects. In your case, the newly created Link depends on the original assembly. Thus, the original assembly is no longer considered as a root object.

If you are looking for tree view root objects, you'll need a different API. The ClaimedBy attribute of a view object returns any objects that claim this object as a child in the tree view. For root object, this attribute shall return an empty list.

[ o.Name for o in App.ActiveDocument.Objects if not o.ViewObject.ClaimedBy ]