标签:cat The code session info 二次开发 exception splay div
1 NX11+VS2013 2 3 #include <NXOpen/DisplayManager.hxx> 4 #include <NXOpen/Body.hxx> 5 #include <NXOpen/BodyCollection.hxx> 6 #include <NXOpen/NXException.hxx> 7 #include <NXOpen/NXObject.hxx> 8 #include <NXOpen/Part.hxx> 9 #include <NXOpen/PartCollection.hxx> 10 11 12 NXOpen::Session *theSession = NXOpen::Session::GetSession(); 13 NXOpen::Part *workPart(theSession->Parts()->Work()); 14 NXOpen::Part *displayPart(theSession->Parts()->Display()); 15 16 std::vector<tag_t> BodyVecotor; 17 NXOpen::Body *WorkBody; 18 NXOpen::BodyCollection *Bodys = workPart->Bodies(); 19 NXOpen::BodyCollection::iterator Ite = Bodys->begin(); 20 for (; Ite != Bodys->end(); ++Ite) 21 { 22 WorkBody = (*Ite); 23 BodyVecotor.push_back(WorkBody->Tag()); 24 25 NXOpen::DisplayModification *displayModification1; 26 displayModification1 = theSession->DisplayManager()->NewDisplayModification(); 27 displayModification1->SetNewColor(36); 28 std::vector<NXOpen::DisplayableObject *> objects1(1); 29 NXOpen::Body *body1(dynamic_cast<NXOpen::Body *>(workPart->Bodies()->FindObject(WorkBody->JournalIdentifier()))); 30 objects1[0] = body1; 31 displayModification1->Apply(objects1); 32 } 33 34 char msg[256]; 35 sprintf_s(msg, "当前有%d个体", BodyVecotor.size()); 36 lw->Open(); 37 lw->WriteLine(msg);
NX二次开发-NXOpen方式遍历所有体workPart->Bodies();
标签:cat The code session info 二次开发 exception splay div
原文地址:https://www.cnblogs.com/nxopen2018/p/10957470.html