Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations JAE on being selected by the Eng-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
Joined
Apr 13, 2015
Messages
31
Location
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());
}
 
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.

Part and Inventory Search

Sponsor

Back
Top