Cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot Get Root TxPartApperances from GetAlldescendants

Creator
Creator

Hi

I am trying to get the root TxPartAppearance using the below method

TxApplication.ActiveDocument.PhysicalRoot.GetAllDescendants(New TxTypeFilter(GetType(TxPartAppearance)))

It is geting a lot of the child elements but not the main nodes. Please see below which part apperances I am referring to. Is this approach incorrect? Is there another method.

 

Capture.PNG

 

 

 

Thanks for the help

8 REPLIES

Re: Cannot Get Root TxPartApperances from GetAlldescendants

Experimenter
Experimenter

Hi,

 

we use: TxApplication.ActiveDocument.PhysicalRoot.GetDirectDescendants()

 

 

Re: Cannot Get Root TxPartApperances from GetAlldescendants

Creator
Creator

Hi

 

Yes I used this as well with the same bad result. I can't see how that would help as GetDirectDescendants is a reduced list of GetAllDescendants.

 

Regards

Re: Cannot Get Root TxPartApperances from GetAlldescendants

Siemens Phenom Siemens Phenom
Siemens Phenom

Hello,

 

In my case the following code works fine for MPA created from assembly structure:

TxObjectList allMPADescendants = TxApplication.ActiveDocument.PhysicalRoot.GetDirectDescendants(new TxTypeFilter(new Type[]{
                typeof( TxPartAppearance),
            } ));

From your provided screenshot I would say your MPA is coming from IPA part structure.

The strange thing is, when using ...

TxObjectList test = TxApplication.ActiveDocument.Selection.GetAllItems();

... it returns "TxPartAppearance" as object type.

 

Best regards

Patrick

 

Re: Cannot Get Root TxPartApperances from GetAlldescendants

Creator
Creator

Hi

 

After some investigation using GetDirectDescendants these are the items it is returning ticked in blue which is not what I need.

Capture.PNG

The main goal is to get the main part appearance node and move it to a new location using ITxLocatableObject but there is no metod to get to this without manually selecting it.

 

Regards

Re: Cannot Get Root TxPartApperances from GetAlldescendants

Siemens Phenom Siemens Phenom
Siemens Phenom

Hi,

 

Yes that´s what I said.

This is because your Appearance is coming from "IPA".

 

As you said you get the appearances (children) from API.

Maybe you need to check if these appearances have  parents, so iterate backwards to find the parents.

 

Best regards

Patrick

Re: Cannot Get Root TxPartApperances from GetAlldescendants

Creator
Creator

Hi

 

The parent is physicalroot so this will not be possible

 

Regards

Re: Cannot Get Root TxPartApperances from GetAlldescendants

Siemens Phenom Siemens Phenom
Siemens Phenom

Hi Root7,

 

Can you check what is the API type of that root objects?

You can write a small command, something like that:

ITxObject selectedObject = TxApplication.ActiveSelection.GetAllItems()[0];
MessageBox.Show(selectedObject.ToString());

Or check the type while debugging.

 

 

Best Regards,

DianaG

Re: Cannot Get Root TxPartApperances from GetAlldescendants

Creator
Creator

Hi

 

It is TxPartApperance. I have found a solution using TxOperationEx.GetAllPartApperances.

 

Regards