How to verify if part is derived

How to verify if part is derived

Anonymous
Not applicable
427 Views
1 Reply
Message 1 of 2

How to verify if part is derived

Anonymous
Not applicable

I need to check if a part is derived because I'm developing a method to fix missing references.

To verify, I use a foreach that traverses all occurrences.

 

AssemblyDocument asmDoc = (AssemblyDocument)invApp.ActiveDocument;

ComponentOccurrences Occurrences = asmDoc.ComponentDefinition.Occurrences;

foreach (ComponentOccurrence oOcc in Occurrences)
{


}

In this example, it is possible to see that the reference is lost for the part that originated the derive.

 

part.PNG

I'm trying to do that, but I can not do it.

 

PartDocument oPart = (PartDocument)oOcc;

ReferenceComponents oRefsComps = oPart.ComponentDefinition.ReferenceComponents;

DerivedPartComponent oDerPartC = oRefsComps.DerivedPartComponents[1];

DerivedPartDefinition oDerPartDef = oDerPartC.Definition;

if (oDerPartDef is DerivedPartDefinition) {
    MessageBox.Show("yes");
}

Thanks.

0 Likes
Accepted solutions (1)
428 Views
1 Reply
Reply (1)
Message 2 of 2

sajith_subramanian
Autodesk Support
Autodesk Support
Accepted solution

Hi marcelo.zattera,

 

To check for missing references you could try using the methods listed below.

 

1. To check if the reference is missing:

PartDocument.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Item(1).ReferencedDocumentDescriptor.ReferenceMissing

 

 

2. To check if the component is suppressed:

PartDocument.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Item(1).SuppressLinkToFile

 

 

3. To check if the component link is broken:

PartDocument.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Item(1).LinkedToFile

 

 

Let me know if this helps.

 

 

Regards,

Sajith


Sajith Subramanian
Autodesk Developer Network
0 Likes