×
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

Loop through assembly. NX Open C++

Loop through assembly. NX Open C++

Loop through assembly. NX Open C++

(OP)
Can someone plz tell me whey the loop in the below code is not getting terminated? Its going in an infinite loop.

Session *theSession = Session::GetSession();
Part *workPart(theSession->Parts()->Work());
UI *theUI = UI::GetUI();
ListingWindow *list=theSession->ListingWindow();
NXObject *nullNXObject(NULL);

list->SelectDevice(NXOpen::ListingWindow::DeviceTypeWindow, "log.txt");
list->Open();

NXOpen::Assemblies::ComponentAssembly *rootAssembly = workPart->ComponentAssembly();

NXOpen::Assemblies::Component *rootComponent = rootAssembly->RootComponent();

vector<NXOpen::Assemblies::Component *> childComponents = rootComponent->GetChildren();
vector<NXOpen::Assemblies::Component *>::iterator itrComponent = childComponents.begin();


for(itrComponent = childComponents.begin() ; itrComponent != childComponents.end(); itrComponent++){
list->WriteLine("inside loop");
}
list->WriteLine("After the loop");

list->Close();


/* Terminate the API environment */
UF_CALL(UF_terminate());
}

RE: Loop through assembly. NX Open C++

Is the iterator stepping through the components?

Is ++ implemented for NXOpen::Assemblies::Component?

What do you see if you add the component name to the list->WriteLine("inside loop");? Is it stepping through the components?

Paul

Paul Turner
CAD & Process Engineer
Mastip Technology

RE: Loop through assembly. NX Open C++

(OP)
I have found the solution Paul. The code written by me is correct. The problem was, I was using VS2012 for developing NX application & I was testing it in NX7.5. Whereas, I should have used VS2008 for NX7.5 applications. So, when I used the same code in VS2008 & created the dll, it worked perfectly fine in NX7.5.

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