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

NXOpen遍历实体移除参数和改色

时间:2021-01-06 11:56:36      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:dialog   tap   文件   display   work   span   rem   lse   comm   

C++

 

//用户头文件
#include <NXOpen/DisplayManager.hxx>
#include <NXOpen/Body.hxx>
#include <NXOpen/BodyCollection.hxx>
#include <NXOpen/NXException.hxx>
#include <NXOpen/NXObject.hxx>
#include <NXOpen/Part.hxx>
#include <NXOpen/PartCollection.hxx>
#include <NXOpen/Builder.hxx>
#include <NXOpen/Features_FeatureCollection.hxx>
#include <NXOpen/SelectObjectList.hxx>
#include <NXOpen/NXObjectManager.hxx>
#include <NXOpen/SelectNXObjectList.hxx>

//用户代码

Part *workPart = theSession->Parts()->Work();
Part *displayPart = theSession->Parts()->Display();

std::vector<tag_t> BodyVecotor;
NXOpen::Body *workBody;
NXOpen::BodyCollection *Bodys = workPart->Bodies();
NXOpen::BodyCollection::iterator Ite = Bodys->begin();

//遍历
for (; Ite != Bodys->end(); ++Ite)
{
workBody = (*Ite);
BodyVecotor.push_back(workBody->Tag());

Body *body1(dynamic_cast<Body *>(NXObjectManager::Get(workBody->Tag())));
//Body *body1(dynamic_cast<NXOpen::Body *>(workPart->Bodies()->FindObject(workBody->JournalIdentifier())));
//Features::BodyFeature *bodyFeatObject(dynamic_cast<BodyFeature*> (feature1)); //特征转换body

//移除参数
Features::RemoveParametersBuilder *removeParametersBuilder1;
removeParametersBuilder1 = workPart->Features()->CreateRemoveParametersBuilder();
bool added1;
added1 = removeParametersBuilder1->Objects()->Add(body1);

NXObject *nXObject1;
nXObject1 = removeParametersBuilder1->Commit();

removeParametersBuilder1->Destroy();//释放

 

 

//改色
DisplayModification *displayModification1;
displayModification1 = theSession->DisplayManager()->NewDisplayModification();
displayModification1->SetApplyToAllFaces(false);
displayModification1->SetApplyToOwningParts(false);
displayModification1->SetNewWidth(DisplayableObject::ObjectWidthOne);
displayModification1->SetNewColor(1+BodyVecotor.size()*12); //设置色
displayModification1->SetNewTranslucency(40);//设置透明度
std::vector<NXOpen::DisplayableObject *> objects2(1);
objects2[0] = body1;
displayModification1->Apply(objects2);
delete displayModification1;

}

char msg[256];
sprintf_s(msg, "当前有%d个体", BodyVecotor.size());
//弹出消息框(四种消息框 错误:DialogTypeError 警告:DialogTypeWarning 提示:DialogTypeInformation 询问:DialogTypeQuestion
theUI->NXMessageBox()->Show("提示", NXOpen::NXMessageBox::DialogTypeWarning, msg); //弹出消息框提示

 

技术图片

 

NXOpen遍历实体移除参数和改色

标签:dialog   tap   文件   display   work   span   rem   lse   comm   

原文地址:https://www.cnblogs.com/hqsalanhuang/p/14224583.html

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