×
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

NX Open - Get immidiate children

NX Open - Get immidiate children

NX Open - Get immidiate children

(OP)
Hello all,

I'm taking my first steps into NX Open using c# and have the following problem...

From an assembly I am able to produce a list of the child components...However it is returning a list of ALL the components in the Assembly.
I would like to see only the immidiate children (sub assemblies toplevels)...

What Ihave so far is;

CODE --> C#

//get all parts in session and create List
                List<NXOpen.Part> newDisplayParts = new List<NXOpen.Part>();

                foreach (NXOpen.Part part in theSession.Parts)
                {
                    NXOpen.Assemblies.Component childComp = part.ComponentAssembly.RootComponent;
                    if (childComp != null)
                    {
                        foreach (NXOpen.Assemblies.Component comp in childComp.GetChildren())
                        {
                            //Checking if comp.protype is an actual NXOpen part is
                            if (comp.Prototype is NXOpen.Part)
                            {
                                theSession.ListingWindow.Open();
                                theSession.ListingWindow.WriteLine(comp.DisplayName);
                                NXOpen.Part prototype = (NXOpen.Part) comp.Prototype;
                                if (prototype == workPart)
                                {
                                    newDisplayParts.Add(part);
                                }
                            }
                        }
                    }
                } 

How to proceed?

Ronald van den Broek
Application Specialist
Winterthur Gas & Diesel Ltd
NX8.5.3 / TC9.1.2
HPZ420 Intel(R) Xeon(R) CPU E5-1620 0 @ 3.60GHz, 32 Gb Win7 64B
Nvidea Quadro4000 2048MB DDR5
HP EliteBook 8570W Intel(R) Core(TM) I7-3740QM CPU @ 2.70GHz, 16Gb Win7 64B

RE: NX Open - Get immidiate children

Don't loop through all the parts that are in the current NX session, only process the desired assembly part. In other words, eliminate this loop:

CODE

foreach (NXOpen.Part part in theSession.Parts) 

Instead, get a reference to the assembly of interest and only process that one "part".

www.nxjournaling.com

RE: NX Open - Get immidiate children

(OP)
Thanks Cowski...It works now..

Ronald van den Broek
Application Specialist
Winterthur Gas & Diesel Ltd
NX8.5.3 / TC9.1.2
HPZ420 Intel(R) Xeon(R) CPU E5-1620 0 @ 3.60GHz, 32 Gb Win7 64B
Nvidea Quadro4000 2048MB DDR5
HP EliteBook 8570W Intel(R) Core(TM) I7-3740QM CPU @ 2.70GHz, 16Gb Win7 64B

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