教你如何通过NXOpen C++通过session 找part,part找body,body找face...
The examples show how to access the following relationships:[*]NX session → list of parts
[*]part → list of solid bodies
[*]solid body → list of facessolid body → list of edges
[*]face → list of associated edgesface → solid body
[*]edge → list of associated facesedge → solid body
Bodies, Faces and Edges - Language Specific Details
NX Open for C++NX Open for .NETNX Open for Java
NX Open for C++
NX session → list of parts
To access all parts in an NX session, use the Parts property to access the Part Collection.Then use the collection's iterator to access each part.Session *NXSession = Session::GetSession(); PartCollection *partList = NXSession->Parts();PartCollection::iterator itr;for ( itr = partList->begin(); itr != partList->end(); ++itr ){ processPart(*itr);}
part → list of solid bodies
To access all solid bodies in a part, use the Bodies property to access the Body Collection. Then use the collection's iterator to access each body.void processPart(Part *partObject){ BodyCollection *bodyList = partObject->Bodies(); BodyCollection::iterator itr; for (itr = bodyList->begin(); itr != bodyList->end(); ++itr) { processBodyFaces(*itr); processBodyEdges(*itr); }}
solid body → list of faces
To access the faces of a body use the GetFaces() method to return an array of faces.void processBodyEdges(Body *bodyObject){ std::vector <Edge *> edgeArray = bodyObject->GetEdges(); for (int inx = 0;inx < (int)edgeArray.size(); ++inx) { processEdge(edgeArray); }}
solid body → list of edges
To access the edges in a body use the GetEdges() method to return an array of edges.void processBodyEdges(Body *bodyObject){ std::vector <Edge *> edgeArray = bodyObject->GetEdges(); for (int inx = 0;inx < (int)edgeArray.size(); ++inx) { processEdge(edgeArray); }}
face → list of associated edges
face → solid body
To access the edges for a face use the GetEdges() method to return an array of edges. To access the face's body use the GetBody() method.void processFace(Face *faceObject){ std::vector<Edge *> edgeArray = faceObject->GetEdges(); for (int inx = 0;inx < (int)edgeArray.size(); ++inx) { processEdge(edgeArray); } Body *bodyOfFace = faceObject->GetBody();}
edge → list of associated faces
edge → solid body
To access the faces associated with and edge use the GetFaces() method to return an array of faces. To access the edge's body use the GetBody() method.void processEdge(Edge *edgeObject){ std::vector<Face *> faceArray = edgeObject->GetFaces(); for (int inx = 0;inx < (int)faceArray.size(); ++inx) { processEdgeFace(faceArray); } Body *bodyOfEdge = edgeObject->GetBody();}
页:
[1]