NX11+VS2013
#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>
NXOpen::Session \*theSession = NXOpen::Session::GetSession();
NXOpen::Part \*workPart(theSession->Parts()->Work());
NXOpen::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());
NXOpen::DisplayModification \*displayModification1;
displayModification1 = theSession->DisplayManager()->NewDisplayModification();
displayModification1->SetNewColor();
std::vector<NXOpen::DisplayableObject \*> objects1();
NXOpen::Body \*body1(dynamic\_cast<NXOpen::Body \*>(workPart->Bodies()->FindObject(WorkBody->JournalIdentifier())));
objects1\[\] = body1;
displayModification1->Apply(objects1);
}
char msg\[\];
sprintf\_s(msg, "当前有%d个体", BodyVecotor.size());
lw->Open();
lw->WriteLine(msg);
手机扫一扫
移动阅读更方便
你可能感兴趣的文章