Cancel
Showing results for 
Search instead for 
Did you mean: 

Part import, how to get committed objects

Legend
Legend

NX10, C++:

 

How to get the objects created by a part import? I have the following code

NXOpen::PartImporter *partImporter = workPart->ImportManager()->CreatePartImporter();
partImporter->SetFileName(path);
partImporter->SetScale(1.0);
partImporter->SetCreateNamedGroup(false);
partImporter->SetImportViews(false);
partImporter->SetImportCamObjects(false);
//!!!partImporter->SetCreateNamedGroup(true);
partImporter->SetLayerOption(NXOpen::PartImporter::LayerOptionTypeOriginal);
partImporter->SetDestinationCoordinateSystemSpecification(NXOpen::PartImporter::DestinationCoordinateSystemSpecificationTypeWork);
NXOpen::Matrix3x3 matrix;
matrix.Xx = 1.0;matrix.Xy = 0.0;matrix.Xz = 0.0;matrix.Yx = 0.0;matrix.Yy = 1.0;matrix.Yz = 0.0;matrix.Zx = 0.0;matrix.Zy = 0.0;matrix.Zz = 1.0;
NXOpen::NXMatrix *nXMatrix = workPart->NXMatrices()->Create(matrix);
partImporter->SetDestinationCoordinateSystem(nXMatrix);
NXOpen::Point3d destinationPoint(0.0, 0.0, 0.0);
partImporter->SetDestinationPoint(destinationPoint);
partImporter->Commit();
std::vector<NXOpen::NXObject *> committedObjects = partImporter->GetCommittedObjects();
partImporter->Destroy();

If I SetCreateNamedGroup(true) I get a single object vector with the created named group inside as expected.

But I don't want to create a named group. I expected GetCommittedObjects to return the objects imported in this case. But the vector is always empty.

 

2 possible workarounds:

  1. Create a named group: Cycle cycle through the objects an collect them. Ungroup it.
  2. Cycle through all objects before and after import.

Any other less complicated idea? Is the builder working as designed or is it a bug?

 

Regards,

Jan

 

 

Jan Böttcher
1 REPLY

Re: Part import, how to get committed objects

Siemens Phenom Siemens Phenom
Siemens Phenom

Hmmm... The documentation does decribe the behavior that you are seeing:  "You can access the named group which is created when importing the part by accessing the object array returned from the method Builder::GetCommittedObjects after you execute the Builder::Commit on the NXOpen:Smiley TongueartImporter ."  In the absence of any mention of getting the objects any other way, I think it is probably working as designed.

 

I like your first possible workaround.  It seems like much less overhead than trying to compare the two lists of objects collected before and after the import.