×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Access part collections in an assembly

Access part collections in an assembly

Access part collections in an assembly

(OP)
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

CODE --> C#

NXOpen.Part partWork = theSession.Parts.Work; 
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:

CODE --> C#

NXOpen.Assemblies.Component[] childComponents = partWork.ComponentAssembly.RootComponent.GetChildren(); 
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:

CODE --> C#

childComponents[i].OwningPart 
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.

CODE --> C#

NXOpen.PartCollection pc = theSession.Parts; 
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.

RE: Access part collections in an assembly

Walk the Assembly Tree Top/Down in a recursive way.
There a plenty of GTAC code examples doing that.
Look for "WalkAssemblyTree" in the GTAC library.

RE: Access part collections in an assembly

If you have a reference to a component, you can get the prototype part with:

CODE

{component}.Prototype.OwningPart 

www.nxjournaling.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources