How to get the Part DocumentObject

Discussion about the development of the Assembly workbench.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

How to get the Part DocumentObject

Post by ickby »

Hello,

as always freetime is more limited than expected, but finaly I started with the assembly solver integration. One thing I can't figure out is how to retrieve the part document object from an PropertyLinkSub. This is what happens:

The constraint gets created and it's PropertyLinkSub's are set, e.g. (App.ActiveDocument.Pad001,["Face1"]). When all information is gathered and new placement values are calculated, they need to be set for the Part documentobject to which the subelement belongs (e.g. Face1 of Pad001 belongs to Part001). But how can I get the Part001 DocumentObject from the Pad001 DocumentObject (which I get from the PropertyLinkSub) ?

Thanks for any advice,
Stefan
User avatar
jriegel
Founder
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: How to get the Part DocumentObject

Post by jriegel »

Its even more complicated ;)

The Pad is the feature which contain the geometry which the Constraint object reference to. But it makes no sense to move the Pad. In the new PartDesign object world there is a Body above the Pad. But thats also not the one to move. In Assembly the Body is in a AssemblyItem object, in this case AssemblyItemPart. And this is the object which holds the Placement to move. The Feature (Pad) and the Body have to stay untouched. Thats an important point, cause we have to seperate the creation and the positioning of geometry for later revision control and multi-model stuff.

So we need in the assembly module a helper method which travel the product tree up to find the right Assembly item object to move. That depends on which level (in which product) the constraint is located. Generally we need some tools to work with product tree structures.

I can make an example tree if you wish...
Stop whining - start coding!
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: How to get the Part DocumentObject

Post by ickby »

I'm aware that I need to move the Assembly Item, I just don't know how to get the Assembly Item from the PropertyLinkSub which relates to the feature.
So we need in the assembly module a helper method which travel the product tree up to find the right Assembly item object to move
And thats basicly the answer, I just hoped there is a simpler way :) I can implement this method.
User avatar
jriegel
Founder
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: How to get the Part DocumentObject

Post by jriegel »

Actually I planed to use information in the document for that task.
The document build up a graph data structure to determine the recompute cycle. This data structure holds all the information needed.
The idea was to create a interface to the document where you can retrieve that Boost-Graph data structure. On that structure you can retrieve the "Path" from the top of the
product tree to the actual element you interested in. In fact you can determine the top of product tree (which is also a question).

You can take a read about the boost graph data structure on their web site. We use a adjacency-list in the document. Boost has some algorithms to extract information from the graph.

Another easier (but slower) way is to get the inList from the document object and traverse the way up in the hierarchy until you find the right object...
Stop whining - start coding!
Post Reply