cancel
Showing results for 
Search instead for 
Did you mean: 

(C# API) - Traverse Object Tree

Solution Partner Creator Solution Partner Creator
Solution Partner Creator

Hello,

 

I'm quite new in PS/PD. The current TxSelection class goves me access to the selected object,

but what if I want to retrieve all - lets say Weldoperations - under an Object. Is there a Function to traverse the children? I found some functions in theTxDocument namespace, but they did not work, i.e. I could not retrieve the desired object instead of iterating over the complete Documentcollection of the TxApplication.

also, how is it possible to load a PlanningObject ? I found some Shortcuts but no method to load the referenced object. How would one do that ?

 

Any help is appreciated

4 REPLIES

Re: (C# API) - Traverse Object Tree

Siemens Phenom Siemens Phenom
Siemens Phenom

Hi,

 

to find a special type you can use type filters.

The following line allows you to get all frames from the object tree:

TxObjectList allDescendants = TxApplication.ActiveDocument.PhysicalRoot.GetAllDescendants(new TxTypeFilter(typeof(TxFrame)));

 

To get all Mfgs you only need to change from PhysicalRoot to MfgRoot

 

 

Re: (C# API) - Traverse Object Tree

Solution Partner Creator Solution Partner Creator
Solution Partner Creator

Hi,

 

thanks for your reply. This seems logical so far, unfortunately whatever object I query I get an empty list as result. Same for MfgRoot. When I check the total number of documents (TxApplication.DocumentCollection) in my simulation I get a count of > 2Billion documents. I assume my current document is simply wrong/empty. How can I check which document is the current one ?

 

Thanks

Re: (C# API) - Traverse Object Tree

Siemens Phenom Siemens Phenom
Siemens Phenom

Hi,

 

if you take "TxObjectList allDescendants = TxApplication.ActiveDocument.PhysicalRoot.GetAllDescendants(new TxTypeFilter(typeof(TxFrame)));" you need to have some frames in your ObjectTree, otherwise "allDescendants" returns "null".

 

Use "TxApplication.ActiveDocument"...

 

Regards

Re: (C# API) - Traverse Object Tree

Solution Partner Creator Solution Partner Creator
Solution Partner Creator

Hi,

 

I searched for other type of Objects like TxPlanningObject or ITXObject. The only match was

when i used the filter for ITXObject. I think the problem is in my testdata, your provided code should work fine. thanks for your help.

 

regards