neshom
Mechanical
- Feb 7, 2016
- 43
I'd like to access collections (Sketches, Datums, Bodies, etc) of all of the parts in an assembly. The assembly part (.prt) itself is easy because I can use
to access the part instance of the assembly prt (assuming it is the work part). Using this instance I can access all of the collections that are in the assembly prt itself, but not those that are in other parts that are in the assembly.
So, my question is how I can access the part instances of other components of the assembly?
These are what I tried and can think of:
1) I can find out the list of the components of an assembly by using:
By knowing the component instance of the parts, I was hoping to get access to the part that has the component by using the following for the i-th component:
But, it returns the assembly part itself and not the instance of the individual part.
2) Theoretically, I can use the following to find all of the parts loaded in the session, but it also returns the parts that are not part of the assembly.
I may be able to investigate whether each individual part belongs to the assembly or not (which I am not sure how!).
I am wondering whether there is a way to directly (not by checking all of the loaded parts one by one to check which is part of the assembly and which is not) find the list of the parts that belong to the assembly that either itself or one of its components is the work part.
Thanks in advance.
Code:
NXOpen.Part partWork = theSession.Parts.Work;
So, my question is how I can access the part instances of other components of the assembly?
These are what I tried and can think of:
1) I can find out the list of the components of an assembly by using:
Code:
NXOpen.Assemblies.Component[] childComponents = partWork.ComponentAssembly.RootComponent.GetChildren();
Code:
childComponents[i].OwningPart
2) Theoretically, I can use the following to find all of the parts loaded in the session, but it also returns the parts that are not part of the assembly.
Code:
NXOpen.PartCollection pc = theSession.Parts;
I am wondering whether there is a way to directly (not by checking all of the loaded parts one by one to check which is part of the assembly and which is not) find the list of the parts that belong to the assembly that either itself or one of its components is the work part.
Thanks in advance.