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


     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);

  • 相关阅读:
    bootstrap模态框
    css 禁止选中文本
    Python Flask Tornado
    JS canvas标签动态绘制图型
    JS 跳转页面
    JS 计算器
    JS
    柱状图中最大的矩形
    在不使用第三个变量的情况下交换两个数的值
    springboot配置静态资源访问的2种方式
  • 原文地址:https://www.cnblogs.com/nxopen2018/p/10957470.html
Copyright © 2020-2023  润新知