Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loop through assembly. NX Open C++

Status
Not open for further replies.

yadvdinesh

Aerospace
Apr 13, 2015
31
0
0
IN
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());
}
 
Replies continue below

Recommended for you

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
 
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.
 
Status
Not open for further replies.
Back
Top