Open a specific component in an assembly

Hello,

I would need help to develop a code that would open a specific component in an assembly. The code would pass all the components that are open in an NX session. He will have to find the component that has the attribute (String) '' MASTER = YES ''. Once the part is found, NX will have to open it "Make Display Part".

If the code does not find a component with the attribute (String) '' MASTER = YES '', an error message should appear and do nothing. Also, an error message should also appear if it finds more than one component with this attributes and doing nothing.

I want to create a code similar to the '' Workpiece '' and '' Cavity Layout '' command from MoldWizard.

Thank You !

Loop through all the open parts with a For...Each loop, check for the attribute inside the for loop, add some variables to determine if one has been found and if multiple were found. After the for...Each loop check the variables and either display your error message or make the part the display part. Here is an example of how to loop through the open parts:

for each loadedPart as NXOpen.Parts in theSession.Parts

next