partImporter插入part到当前零件时,如何获得插入的所有实体
Features::MoveObject *nullFeatures_MoveObject(NULL);std::vector<NXObject *> GroupObjects;//
Objects= partImporter1->GetCommittedObjects();//插入part到当前零件
移动特征时提示找不到实体对象:
Features::MoveObjectBuilder *moveObjectBuilder1;
moveObjectBuilder1 = workPart->BaseFeatures()->CreateMoveObjectBuilder(nullFeatures_MoveObject);
bool added1;
added1 = moveObjectBuilder1->ObjectToMoveObject()->Add(Objects); Session *theSession = Session::GetSession();
Part *workPart(theSession->Parts()->Work());
Part *displayPart(theSession->Parts()->Display());
// ----------------------------------------------
// Menu: File->Import->Part...
// ----------------------------------------------
PartImporter *partImporter1;
partImporter1 = workPart->ImportManager()->CreatePartImporter();
partImporter1->SetFileName("F:\\_model10.prt");
partImporter1->SetScale(1.0);
partImporter1->SetCreateNamedGroup(true);
partImporter1->SetImportViews(false);
partImporter1->SetImportCamObjects(false);
partImporter1->SetLayerOption(PartImporter::LayerOptionTypeWork);
partImporter1->SetDestinationCoordinateSystemSpecification(PartImporter::DestinationCoordinateSystemSpecificationTypeWork);
Matrix3x3 element1;
element1.Xx = 1.0;
element1.Xy = 0.0;
element1.Xz = 0.0;
element1.Yx = 0.0;
element1.Yy = 1.0;
element1.Yz = 0.0;
element1.Zx = 0.0;
element1.Zy = 0.0;
element1.Zz = 1.0;
NXMatrix *nXMatrix1;
nXMatrix1 = workPart->NXMatrices()->Create(element1);
partImporter1->SetDestinationCoordinateSystem(nXMatrix1);
Point3d destinationPoint1(0.0, 0.0, 0.0);
partImporter1->SetDestinationPoint(destinationPoint1);
NXObject *nXObject1;
nXObject1 = partImporter1->Commit();
std::vector< NXOpen::NXObject * >GetCommittedObjects;
GetCommittedObjects=partImporter1->GetCommittedObjects();
partImporter1->Destroy();
// set the color
NXOpen::DisplayModification *displayObject;
displayObject = theSession->DisplayManager()->NewDisplayModification();
displayObject->SetApplyToAllFaces(true);
displayObject->SetNewColor(200);
std::vector <DisplayableObject *> ImporterObjects;
NXOpen::ListingWindow*lw = theSession->ListingWindow();
stringstream ss;
lw->Open();
ss.clear();
ss.str("");
ss<<"插入的对象有几个:"<< GetCommittedObjects.size()<<endl;
lw->WriteLine(ss.str());
for(unsigned int i = 0 ; i < GetCommittedObjects.size();i++)
{
ImporterObjects.push_back( dynamic_cast<DisplayableObject *>(GetCommittedObjects));
}
displayObject->Apply(ImporterObjects);
delete displayObject; 附上出错截图,求plm大师出手 没有大神知道吗?
页:
[1]