码迷,mamicode.com
首页 > 其他好文 > 详细

NX二次开发-NXOpen方式遍历所有体workPart->Bodies();

时间:2019-05-31 21:50:31      阅读:456      评论:0      收藏:0      [点我收藏+]

标签: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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!