AnsweredAssumed Answered

check if Component2 is invalid

Question asked by Jana Stahn on Jan 25, 2017
Latest reply on Jan 26, 2017 by Jana Stahn

I noticed that it is possible to retrieve a Component2 and make it invalid.

I will shortly explain how I did it.

 

This is my assembly:

structure.png

 

1. I retrieved all components via AssemblyDoc.GetComponents(false). This gave me two components: the top level component and its child component.

2. I replaced the top level component by a part file. Thus, after the replace, the top level component does not have a child any more.

 

I still have the child component, even though it has no counterpart in the feature tree any more. I call it "invalid" for the purpose of this question. (I don't know if this is the official nomenclature.)

 

My question is: How do I find out if a given Component2 is invalid?

 

I noticed that before replacing, the component in question had a Name2: "subLvlComp-1".

After replacing, its Name2 is "". So the Name2 is an indicator. But I don't know if this always works.

Does anyone have experience with this? Is there a method that was designed to return the validity state?

 

I attached the assembly and part files as well as a macro that does the component retrieving, replacing and writing the names to the console.

If you want to try, just open assembly.SLDASM and run the macro (with output console visible).

Attachments

Outcomes