|
Each part may contain 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.7 c6 X/ O! s' Y* X6 { r8 h. e4 |
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.
& I; y8 {; a0 b, ?2 e, KThe examples show how to access the following relationships:1 e# G, X* h/ ?, K2 O5 Z6 O; G
NX session → list of parts
, ]$ n6 i S8 r( c$ U( Ppart → list of solid bodies
8 T" U' C9 D! S' g; T5 I, ?solid body → list of faces' L5 H' J" i7 V, L
solid body → list of edges% k( v& r( t' S1 L
face → list of associated edges
2 P+ X3 P @" i# E8 e, Q5 ]% ^face → solid body
! y) f! b3 C6 J1 ?- r* Bedge → list of associated faces0 n6 r( p1 ~1 E5 |
edge → solid body9 z7 l! Z, e- Q2 w% i. j5 u
Bodies, Faces and Edges - Language Specific Details
* M7 J- s5 F+ t) H& dNX Open for C++- a( k" d4 B! h2 o7 M, ^+ ]
NX Open for .NET7 y2 b0 c Q9 S; ?+ n K- i( N
NX Open for Java# u/ ]9 o, T+ A9 j2 \ h! E6 q
NX Open for C++/ j3 A# d0 w0 M4 Z! M; m
NX session → list of parts
" e4 Z N7 F3 q% q7 J) q! bTo 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.
$ K; V t1 K2 w7 F; M0 }8 c3 K+ `4 Y Session *NXSession = Session::GetSession();
) ~9 G9 R+ @! V# C2 ]) l3 q; S1 ` PartCollection *partList = NXSession->Parts();" E: R' s5 T m, U
PartCollection::iterator itr;
7 K/ K' L, d# u3 p& B @9 j+ y for ( itr = partList->begin(); itr != partList->end(); ++itr )
3 a- E5 j1 O( _- q6 B0 i: l$ L {
; N4 K1 ?; z# h7 Z1 v0 K( V processPart(*itr);) s8 V e% y" J. v, d
}1 b, s8 r9 ?% z7 E
part → list of solid bodies
& F3 z5 U& l5 X4 V. r/ VTo 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.
5 {1 j+ a( G$ [- |* }) m0 [void processPart(Part *partObject)0 c% s/ T) Z! i5 t8 R2 c
{
/ d; p( o" ?# X- E% O BodyCollection *bodyList = partObject->Bodies();
% ?- X3 ] |( N- ]' d+ Z BodyCollection::iterator itr;7 P: l$ Y+ J, U a7 i, Z
for (itr = bodyList->begin(); itr != bodyList->end(); ++itr)
5 o0 E, B8 |2 ^ {! E! \/ L9 T4 o: d; @' {* Y
processBodyFaces(*itr);
% a/ [7 U v; G, U6 T& w processBodyEdges(*itr);
5 }; U) w) K/ a/ M }% y, w5 V1 h) `7 l
}) p# B5 B( n6 h& r3 N+ {' [( j: ~
solid body → list of faces
0 V: ]3 J# I) E6 HTo access the faces of a body use the GetFaces() method to return an array of faces.& g: E( l- I9 j' \
void processBodyEdges(Body *bodyObject)
/ a# J# `; t9 m' W* Q% o3 h7 l9 S{
' h9 q! i# [; z6 h7 M1 ?# y std::vector <Edge *> edgeArray = bodyObject->GetEdges();7 t R7 r. U( q
for (int inx = 0; inx < (int)edgeArray.size(); ++inx)# [& @6 O& g6 \9 I
{0 W7 J( W0 ` K. O/ Y/ i
processEdge(edgeArray[inx]);7 Q( A1 N8 f! ?4 `8 _. O+ N' y
}
0 \& `' }3 q6 J0 r% d0 F} solid body → list of edges" @3 D/ m7 |) q% o3 p6 u7 D3 n
To access the edges in a body use the GetEdges() method to return an array of edges.
1 a3 Y" ?1 i9 ?! P5 ?. qvoid processBodyEdges(Body *bodyObject)
. y8 r t: k) K4 d0 E{" u" A3 U5 n% Y4 g: `; R9 b) i3 ]# h
std::vector <Edge *> edgeArray = bodyObject->GetEdges();
" Q0 Q' L N9 d9 G. Q for (int inx = 0; inx < (int)edgeArray.size(); ++inx)5 t# ~% b7 [$ f* o2 e! D f
{
, o6 l- k% S5 K7 W* Z/ Y) c6 b processEdge(edgeArray[inx]);1 \8 P5 p( w9 r. @
}) l, L6 `% d, O- C+ t
} face → list of associated edges
* W. P1 }8 j9 O! P" j8 jface → solid body
) i7 j- ~% m- S+ ATo 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.; i7 w# t" s" p2 ~7 O0 W
void processFace(Face *faceObject)4 N4 W2 D4 x2 [! a4 N, m7 d" l
{
$ \! s$ B( N R! j/ T7 S std::vector<Edge *> edgeArray = faceObject->GetEdges();( Y% N7 s" v; h% U3 F$ P3 q- T
for (int inx = 0; inx < (int)edgeArray.size(); ++inx) Q2 D7 w& T; e$ {! T1 ~0 `3 A
{! l, L: i+ x; r" E7 L
processEdge(edgeArray[inx]);
. A0 r9 r9 d2 B }
/ u# x7 g/ ]( Z$ S" ?* T9 }' _ Body *bodyOfFace = faceObject->GetBody();
9 `" \( z. m% E7 Y! i" `} edge → list of associated faces
1 [1 R1 Q# Z0 R1 `' T7 oedge → solid body : x2 @* x* w; k0 v% [
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./ S" o; B: V) W. e8 k! T
void processEdge(Edge *edgeObject)5 D$ C/ T8 j7 j8 A# ]# e0 c
{) S7 R5 M' {5 q" i u1 q
std::vector<Face *> faceArray = edgeObject->GetFaces();# `+ w3 [8 x( w
for (int inx = 0; inx < (int)faceArray.size(); ++inx)
9 D. |5 o4 W( U7 a$ c2 b/ G9 I5 @ {6 }5 r: z* z: U% A e2 I& g/ x
processEdgeFace(faceArray[inx]);3 q" q4 y; k& M0 b% A
}0 B$ E6 Q0 \& B1 X" ` X1 Z, q
Body *bodyOfEdge = edgeObject->GetBody();
5 \1 o1 i! S1 J7 U}NX Open for .NET
4 G' g% a: Y- fNX session → list of parts
; n" O- @* i% V4 }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.
4 W0 w* m$ }7 c, g Dim NXSession As Session = Session.GetSession h' T- m* p8 ~* ^
For Each partObject As Part In NXSession.Parts()
8 M$ N. {6 A x2 X1 I* w processPart(partObject)8 [' Z/ z. j; u0 N
Next partObject% l( F+ ?. H: @/ l
part → list of solid bodies; ?9 G a0 m, u$ x: u
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.
! O; a3 R" s5 R& MSub processPart(ByVal partObject As Part)
8 A9 ?( V) |6 x6 ]) _" W& [" y For Each bodyObject As DisplayableObject In partObject.Bodies
$ f! i- a8 U* U* n& ?+ U. k processBodyFaces(CType(bodyObject, Object))
! {: I6 J+ k* i n) J processBodyEdges(CType(bodyObject, Object))
; E" K0 f: N) K6 D2 x; d Next bodyObject
2 y/ s+ Y- Q1 V9 REnd Sub
9 j3 a* y. G4 W7 t T; Z: W0 ]2 Psolid body → list of faces( X4 O u2 j( v
To access the faces of a body use the GetFaces() method to return an array of faces.
. ]! t7 e; W6 L$ g7 S* z& PSub processBodyFaces(ByVal bodyObject As Object)3 W) g* ]6 m- k4 Q$ m- U% r
For Each faceObject As Face In bodyObject.GetFaces()
4 a3 P f& r3 [( w2 ? processFace(faceObject)6 N7 t# J& r* Y% T
Next faceObject! u; e& O! _9 ~' v% r
End Sub
2 |) ~2 `8 |1 R6 \* Y6 wsolid body → list of edges
+ U1 p7 L& p. P2 M0 W r) eTo access a the edges in a body use the GetEdges() method to return an array of edges.
0 L, T9 D, k1 i( G9 s) n4 \" K6 X) D! _Sub processBodyEdges(ByVal bodyObject As Object)( }7 T1 O% t* T! f2 F" `% A1 ?9 I
For Each edgeObject As Edge In bodyObject.GetEdges()
5 O T9 e/ p& f; P processEdge(edgeObject)0 U. e2 a: U* V8 @ r7 t
Next edgeObject1 s; ^% o' Z/ u) a$ l. f2 B
End Sub6 h" F5 O: s# L, c' W4 D
face → list of associated edges
3 O* w2 B: n5 j6 z$ bface → solid body
% ~4 o# s; ~/ N' n* _! bTo 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.: f6 P2 \, k) C/ m% m
Sub processFace(ByVal faceObject As Face)9 |, L* G `: j. p
For Each edgeObject As Edge In faceObject.GetEdges()
& B7 y# R2 E5 V9 l' P processEdge(edgeObject)7 ~ L4 r) ]0 }
Next edgeObject5 r, B& J- |+ S* ~5 S; j( l
Dim bodyOfFace As Body = faceObject.GetBody()
2 X. }3 a0 K, d5 S6 m0 `2 qEnd Sub) F+ G7 E; o) Z& c1 c h: A* f5 p! ?' s0 x
edge → list of associated faces
X. W+ Z; C" Kedge -→ solid body : q' W4 u/ K! Y! V z3 x- n+ G
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.
8 v# Z9 m- }( d, rSub processEdge(ByVal edgeObject As Edge)" ~& t8 K9 G- H% Y( {: n
For Each faceObject As Face In edgeObject.GetFaces()
& I$ i4 [2 I6 \ processEdgeFace(faceObject)
# E, {9 i, M+ M2 T' r% {, F Next faceObject- W! G' s1 E3 s: t8 t
Dim bodyOfEdge As Body = edgeObject.GetBody()) V" s8 s% ?3 t- t* O0 P3 b3 C
End Sub
( ~( A( y5 u- o6 rNX Open for Java
' C# {* ^0 ^4 x9 U7 r/ zNX session → list of parts5 t- G# P' t$ `( z
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.
8 I. Y6 M! ]$ B NXSession = (Session) SessionFactory.get("Session");. X, E) [8 F8 \
Part partObject;
, \ @# r. }# E( w! S! P PartCollection partList = NXSession.parts();6 }3 l* g" K! K2 Y/ p/ I
PartCollection.Iterator itr;
) h. S$ C5 w9 Q- W' i' W for (itr = partList.iterator(); itr.hasNext();)
/ T; w/ A2 g p: C' g, R" d, m) Q {+ Q4 @! Z9 r1 W& \* ?% K
partObject = (Part) itr.next();- x. @, v; ?7 e, i
processPart(partObject);
6 I8 N# v) Z; X5 X) p }
: B) a) ^ T. D# e" ^5 npart → list of solid bodies+ V+ y- I6 d1 k' c
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.- q& a N8 }* B' Y* S: R- ^
public static void processPart(Part partObject) $ o: k- s5 n" H& C9 B
{ X$ {2 d% h: }; Y
BodyCollection bodyList = partObject.bodies();! o# j; Y1 {" J" @
BodyCollection.Iterator itr;3 \" R8 F h0 m" e8 u7 }( `
for (itr = bodyList.iterator(); itr.hasNext();), C3 J4 c& g* O
{ . V$ P' T2 w4 q- N
Body bodyObject = (Body) itr.next();/ c# t6 A' H, t* U
processBodyFaces(bodyObject);
. T# F7 M$ X: n7 [& E processBodyEdges(bodyObject);
. B) A# ]! o& Z, \* i3 F u6 V# A } . i1 c# }- e% D) Z8 m/ }3 c/ D9 ]
}- F8 u' N9 F( w) Z8 @& Q
solid body → list of faces$ ]% G2 O! @% l
To access the faces of a body use the getFaces() method to return an array of faces.
/ ~+ d) W# f; y h; Vpublic static void processBodyFaces(Body bodyObject) & \- J5 d" o8 D( \# b
{# D& ?1 f& C0 P: ?) A6 ^. c: P$ T
Face faceArray[] = bodyObject.getFaces();
+ A0 Z% d" R' W' Z for (int inx=0; inx <(int)faceArray.size(); ++inx)8 b! K, N+ s, A8 |4 A* H
{
+ m" ]3 s* \& Z. S/ n: j8 e- ] processFace(faceArray[inx]);/ C; S9 \5 `* [1 ~1 z) G4 o1 h
}
4 [6 W o4 B4 c, g1 l}* X/ t! W% T |1 S
solid body → list of edges7 f7 }5 R3 t3 y* U
To access a the edges in a body use the getEdges() method to return an array of edges.8 O7 ?- w' S4 D% i
public static void processBodyEdges(Body bodyObject)
% j9 _ Y9 S* U& @; l* e5 W$ ?3 k{
7 Q! _9 H A- E. r R; P { Edge edgeArray[] = bodyObject.getEdges();9 l+ l! u x! O8 U
% ?0 k! ^+ h r6 ]: I. O+ z* F
for (int inx = 0; inx < edgeArray.length; ++inx)
. m% C, U, Q; t7 B O3 }, P" _ {
4 n) S- F3 P7 q' c processEdge(edgeArray[inx]); 1 V6 y- j6 |' y6 U L" [' |. q
}
6 j; p2 _- ~4 ~6 ?4 i}/ R. o/ o. x; G8 t7 N" {
' p6 U) ]9 `5 Y4 D4 Oface → list of associated edges& z6 H3 R' F6 {; S' {4 B
face → solid body 8 a' @# L9 d; a! T0 U
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.
" F! _6 T- Z* E. Q# Opublic static void processFace(Face faceObject)
2 L, |" y3 R: {) V7 l7 ^1 m{
3 ~) [/ p# t4 |2 S Edge edgeArray[] = faceObject.getEdges();
8 d/ }' @ t) j5 r5 d" l0 u4 h1 C! Q- w2 x: J7 k" N( g6 }
for (int inx=0; inx < edgeArray.length; ++inx)( C5 r+ o, J6 \; _
{ ; b0 k4 g O+ o( Y/ l1 e8 k' P, |* x
processEdge(edgeArray[inx]);
C2 t5 A! S5 U4 g Q# Y } 4 G6 ]( K& k: m# C8 Y; v9 Z& ]% H
# \2 b* D5 a O% A9 _
Body bodyOfFace = faceObject.getBody();
: q' [) U/ M% s" t}, f7 H4 |$ F( o$ @
edge → list of associated faces
/ u/ D* A& A! S' ?' G# U- G7 y9 medge → solid body
0 g' ^2 v* C) nTo 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.
: B$ ?5 W3 R7 {7 D+ upublic static void processEdge(Edge edgeObject)
5 g8 |& n& p; [# [, ~{
: c5 I& Q8 ?0 l3 P/ I: T Face faceArray[] = edgeObject.getFaces();3 M7 T: G1 C8 j& M+ L1 `
for (int inx=0; inx <faceArray.length; ++inx)+ I+ h; l3 S: y' b t! l5 [, g
{
4 \1 t/ S0 |! ~2 e5 x processEdgeFace(faceArray[inx]);
7 `, ?- @# b: \) q" L _ }
) E* ^6 T1 ~ t Body bodyOfEdge = edgeObject.getBody(); 1 j& R/ F+ D1 q0 R
} |
|