UG Secondary Program-Accessing Bodies, Faces and Edges

Source: Internet
Author: User

Each part may contain in any number of solid bodies. each solid body is defined by a set of faces and edges. each face contains a reference to the body it belongs to and a list of edges that define the face. each edge will also contain a reference to the owning body and a list of faces that are defined by the edge. NX Open makes it very easy to find the bodies in a part and then to find the relationships between the faces and edges that are used to define the solid body. this section shows examples of how the methods and properties of the body, face and edge objects are used to access the related objects.

Typically a body will have multiple faces and an edge will be used by two faces. however, there are exceptions. for instance, a sphere will only have a single face and no edges. another example a cone, which will have two faces and a single edge.

The examples show how to access the following relationships:

  • NX session → list of parts

  • Part → list of solid bodies

  • Solid body → list of faces

    Solid body → list of edges

  • Face → list of associated edges

    Face → solid body

  • Edge → list of associated faces

    Edge → solid body

Bodies, Faces and Edges-Language Specific Details

NX Open for C ++

NX Open for. NET

NX 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[inx]);  }} 

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[inx]);    }} 

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[inx]);}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[inx]);}Body *bodyOfEdge = edgeObject->GetBody();}

NX open for. net

NX session → list of parts

To access all parts in an NX session, use the parts property to access the part collection. Then use a standard iterator method to access each part.

  Dim NXSession As Session = Session.GetSession  For Each partObject As Part In NXSession.Parts()    processPart(partObject)  Next partObject

Part → list of solid bodies

To access all solid bodies in a part, use the bodies property to access the body collection. Then cast the object to the generic object class to access the face and edge methods.

Sub processPart(ByVal partObject As Part)   For Each bodyObject As DisplayableObject In partObject.Bodies        processBodyFaces(CType(bodyObject, Object))        processBodyEdges(CType(bodyObject, Object))    Next bodyObjectEnd Sub

Solid body → list of faces

To access the faces of a body use the GetFaces () method to return an array of faces.

Sub processBodyFaces(ByVal bodyObject As Object)    For Each faceObject As Face In bodyObject.GetFaces()        processFace(faceObject)    Next faceObjectEnd Sub

Solid body → list of edges

To access a edges in a body use the GetEdges () method to return an array of edges.

Sub processBodyEdges(ByVal bodyObject As Object)    For Each edgeObject As Edge In bodyObject.GetEdges()        processEdge(edgeObject)    Next edgeObjectEnd Sub

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.

Sub processFace(ByVal faceObject As Face)    For Each edgeObject As Edge In faceObject.GetEdges()        processEdge(edgeObject)    Next edgeObject    Dim bodyOfFace As Body = faceObject.GetBody()End Sub

Edge → list of associated faces
Edge-→ 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.

Sub processEdge(ByVal edgeObject As Edge)    For Each faceObject As Face In edgeObject.GetFaces()        processEdgeFace(faceObject)    Next faceObject     Dim bodyOfEdge As Body = edgeObject.GetBody()End Sub

NX Open for Java

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.

   NXSession = (Session) SessionFactory.get("Session");   Part partObject;   PartCollection partList = NXSession.parts();   PartCollection.Iterator itr;   for (itr = partList.iterator(); itr.hasNext();)   {     partObject = (Part) itr.next();     processPart(partObject);   }

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.

public static void processPart(Part partObject) {    BodyCollection bodyList = partObject.bodies();   BodyCollection.Iterator itr;   for (itr = bodyList.iterator(); itr.hasNext();)   {        Body bodyObject = (Body) itr.next();       processBodyFaces(bodyObject);        processBodyEdges(bodyObject);    } }

Solid body → list of faces

To access the faces of a body use the getFaces () method to return an array of faces.

public static void processBodyFaces(Body bodyObject) {    Face faceArray[] = bodyObject.getFaces();     for (int inx=0; inx <(int)faceArray.size(); ++inx)    {       processFace(faceArray[inx]);    }}

Solid body → list of edges

To access a edges in a body use the getEdges () method to return an array of edges.

public static void processBodyEdges(Body bodyObject) {     Edge edgeArray[] = bodyObject.getEdges();     for (int inx = 0; inx < edgeArray.length; ++inx)    {        processEdge(edgeArray[inx]);     } } 

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.

public static void processFace(Face faceObject) {     Edge edgeArray[] = faceObject.getEdges();     for (int inx=0; inx < edgeArray.length; ++inx)    {       processEdge(edgeArray[inx]);     }      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.

public static void processEdge(Edge edgeObject) {     Face faceArray[] = edgeObject.getFaces();     for (int inx=0; inx <faceArray.length; ++inx)    {       processEdgeFace(faceArray[inx]);     }      Body bodyOfEdge = edgeObject.getBody(); }
Original article: http://blog.csdn.net/begtostudy/archive/2008/08/19/2797815.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.