|
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.
, b# y, f: z, J% d( |7 s) S, kTypically 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.
) u$ E8 L' }0 u$ OThe examples show how to access the following relationships:4 Z8 x6 \/ T/ m+ b* }; f2 H+ ~; Q
NX session → list of parts
& h) j% f9 I% c# Y% Mpart → list of solid bodies8 `2 W6 U& W6 L% Q) o+ m9 e
solid body → list of faces
" W; I9 v- j4 V* T( @solid body → list of edges
- N8 L. j2 ~6 Wface → list of associated edges& w) B' X, ^- e: d/ x+ p
face → solid body
5 X( z! x9 z+ B9 L5 R, d$ R# I( R6 Dedge → list of associated faces
3 C0 V; J' R b/ D9 M# tedge → solid body3 C8 n. U& A8 D6 `0 |" u
Bodies, Faces and Edges - Language Specific Details0 J) k0 N1 D4 L8 w
NX Open for C++4 V+ K/ P1 o1 I& J9 x9 ^* ~! z
NX Open for .NET) Z+ I" b- X7 M- L% J/ `7 v
NX Open for Java; \1 b2 X# E+ L' S! Z
NX Open for C++3 c q) ^$ `( k5 h4 X5 u/ W7 t
NX session → list of parts$ r# v8 I/ {, C
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." d9 X2 A& `- O6 K, ~- s
Session *NXSession = Session::GetSession(); 7 p$ G9 {2 Z6 z2 E- x5 W
PartCollection *partList = NXSession->Parts();
+ ?" n& T! d5 ] PartCollection::iterator itr;
0 O% W0 E n `3 M; T/ n8 S0 e3 A! X for ( itr = partList->begin(); itr != partList->end(); ++itr )! I& d! G( g* m) y& ?4 E! Y& r
{/ Y( N6 @! m- Y
processPart(*itr);% z. B; T* X! T- l9 D. l. z
}
* `+ B6 I3 q* @$ O- Hpart → list of solid bodies' f: v; t. c$ o# U) \
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.
- o) o0 x% w+ k$ v# Y* M+ L5 S; K6 Rvoid processPart(Part *partObject)6 d9 i- `6 ^: D( c, R
{
( I4 F9 d2 ]) N0 Q' O1 v BodyCollection *bodyList = partObject->Bodies();
* m- ]0 {6 T: o; i2 j; p BodyCollection::iterator itr;
$ x0 h4 l- J U6 p& X6 M for (itr = bodyList->begin(); itr != bodyList->end(); ++itr)
9 l! l& a: K t {
, Z* L! `$ k( k: z# S processBodyFaces(*itr);
! o; Y) P. y# _" b processBodyEdges(*itr);
* V. H- e! O# W- e! Y( w j2 k }
; z& d& _) [# f" r}8 b4 I3 v2 D& z& q. Z* S) p- H
solid body → list of faces
; }, L5 h+ U: H/ K; ^To access the faces of a body use the GetFaces() method to return an array of faces.
9 g$ K8 Y0 T/ B/ R$ s/ P0 gvoid processBodyEdges(Body *bodyObject). J( N5 ]. r! W* x0 d R
{
2 S% {6 z3 n6 y- K" |/ { std::vector <Edge *> edgeArray = bodyObject->GetEdges();
) R& U2 b/ }4 W! M* v$ `3 O for (int inx = 0; inx < (int)edgeArray.size(); ++inx)1 k; `$ Z, _1 {
{
7 N: |4 O6 x2 E/ O9 _; N processEdge(edgeArray[inx]);
0 ^+ t/ c1 e' s6 P+ ]- O- U }$ _% M4 r' ]$ Z3 d+ o1 C# }7 B1 @
} solid body → list of edges k' r- L k+ w2 e7 p, F$ Z2 o
To access the edges in a body use the GetEdges() method to return an array of edges.
( b- E' A+ @6 Xvoid processBodyEdges(Body *bodyObject)% n/ _8 d- G+ G2 v
{; z1 p% R U2 P+ s* n
std::vector <Edge *> edgeArray = bodyObject->GetEdges();
# [; u m5 J4 c for (int inx = 0; inx < (int)edgeArray.size(); ++inx)
9 g8 O9 C2 m0 m& C) P3 ? {& M8 z5 J, p# i4 ] L! k* e3 o8 m4 t
processEdge(edgeArray[inx]);% e4 k( o1 p0 @. z# X
}5 Z2 K8 F( D6 G/ H; D1 S$ Z. a: |
} face → list of associated edges
% R: u6 R* ?# Fface → solid body ( }2 T# t0 l/ N" @- P6 @' b- E8 j
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.
# K7 q) N. {4 M6 T7 S$ h3 gvoid processFace(Face *faceObject)
3 m6 P7 [0 O. y& K# v5 P' L7 x{
& Q$ n5 K+ c* N1 I: G3 W std::vector<Edge *> edgeArray = faceObject->GetEdges();
) i% J6 D, n) s8 a( W5 u for (int inx = 0; inx < (int)edgeArray.size(); ++inx)' |; b& v8 T/ o! Y/ u7 o6 G; J
{
5 j% o( X9 f$ V( x2 A8 U: l$ k processEdge(edgeArray[inx]);7 q9 X* z) T2 t* G6 K
}- ^. _2 { \% J+ _; \0 R) Q0 q; S ]
Body *bodyOfFace = faceObject->GetBody();
' i4 L0 D$ i, z* y} edge → list of associated faces
5 o5 e9 [2 }0 H }, Redge → solid body
U: p5 a9 T3 ?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., b4 c" F5 z4 A1 R
void processEdge(Edge *edgeObject)2 \1 n8 x$ Y# u
{* a' c( |/ `# U) ^4 }7 C( M
std::vector<Face *> faceArray = edgeObject->GetFaces();
% N, p5 A% Y# ~6 v for (int inx = 0; inx < (int)faceArray.size(); ++inx)& C6 i% N' r5 p# [
{7 e- V. e( E5 Z) s8 q8 u$ ]! d5 f
processEdgeFace(faceArray[inx]);& h: j0 K; @5 ]5 ?) z
}2 ]) x! S/ G, J. G8 e) V3 S
Body *bodyOfEdge = edgeObject->GetBody();
u, z* o1 \" p$ f+ \1 [" Y9 g$ w, [}NX Open for .NET' L0 G/ ?8 ^1 @* E4 z+ k
NX session → list of parts: T1 {' {8 d3 Z. s O
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.* {# g% `/ h4 f* r' R. W) i
Dim NXSession As Session = Session.GetSession8 a; C `4 i% ]) m5 z/ R9 u
For Each partObject As Part In NXSession.Parts()
) x. }" d) {8 X- ]9 {. m2 D processPart(partObject)
3 |3 p q* z: M# Y Next partObject, ?# l; O" L4 U$ H7 m5 e
part → list of solid bodies
( @5 A% z) |/ h. F8 g Y, zTo 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.# J# G/ Z" F/ a8 \
Sub processPart(ByVal partObject As Part)+ P1 a2 m! G7 A- q/ B# G
For Each bodyObject As DisplayableObject In partObject.Bodies
# A: O. H- Z+ J' B' L/ D( Z' b processBodyFaces(CType(bodyObject, Object))6 y9 o0 F* K! u- k
processBodyEdges(CType(bodyObject, Object))5 f! J' h/ w) B* A8 B5 g2 V
Next bodyObject3 Z( b# x( s; Z! ^ X3 b
End Sub) {" a& L- H) Q v& h( N6 J
solid body → list of faces4 D% D% N/ S _& s
To access the faces of a body use the GetFaces() method to return an array of faces.
+ a0 ~/ s9 z% Z4 y( s! F6 X2 |Sub processBodyFaces(ByVal bodyObject As Object)1 @' p% s" Q8 Y# C) @6 j
For Each faceObject As Face In bodyObject.GetFaces()* F* H( ]3 t5 a4 T# L- m- f
processFace(faceObject)
- `# A! r4 H# w+ i6 {) [2 j Next faceObject
& |9 V' J5 A- K! _5 KEnd Sub5 v7 N' m( ^4 h8 G9 i* d3 t
solid body → list of edges
; a! \; n' }, E) v( ?5 N2 lTo access a the edges in a body use the GetEdges() method to return an array of edges.
% @* X B/ y# M* o5 |Sub processBodyEdges(ByVal bodyObject As Object)4 m$ h3 r; V( j' j+ u# u. d/ i
For Each edgeObject As Edge In bodyObject.GetEdges()
" a" s; O5 `8 g7 S. }) E7 n processEdge(edgeObject)% l% t9 @3 K& m% \
Next edgeObject8 Q6 d# l% A6 t: }& o
End Sub8 A1 N" h) a) p1 }
face → list of associated edges6 P+ p3 U. y4 w& E
face → solid body ( b1 W8 B3 ?' e. x* q: Y
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.
; {, g- f& J1 s$ s W) k- PSub processFace(ByVal faceObject As Face)5 u6 p" Y* ?) z/ m: d. C$ M
For Each edgeObject As Edge In faceObject.GetEdges()1 o& ~/ R( K; Q" V5 A
processEdge(edgeObject)
4 @( J5 a& k* i& e Next edgeObject
" n! p+ D e d1 \/ V Dim bodyOfFace As Body = faceObject.GetBody()
2 I$ u4 Y' c1 O! X% O2 jEnd Sub8 Q) X! `, t9 P. Z% `3 |8 Q# d, J
edge → list of associated faces
7 H* Y. U+ A7 n$ \+ Xedge -→ solid body
& h2 p+ H/ e: n 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.
6 F. g5 F& I# x+ nSub processEdge(ByVal edgeObject As Edge)) d- a# X$ o: p3 i) N
For Each faceObject As Face In edgeObject.GetFaces() b5 ~% G( U7 P7 i0 K+ ^
processEdgeFace(faceObject)4 V. Z3 C. R0 K+ w% h
Next faceObject
' h& n- P' M6 l" F' c/ Q* E1 l1 h) k# A Dim bodyOfEdge As Body = edgeObject.GetBody()% E- e: ]0 a) W8 f
End Sub# m1 D9 s7 f$ ^) j S
NX Open for Java
! c) |/ o9 ^! G8 ?6 O1 I) K$ h4 L; PNX session → list of parts
4 J8 {8 R9 O# y- ]! y. cTo 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.6 B3 h: c' t# Q- D: ]
NXSession = (Session) SessionFactory.get("Session");& ^- X7 I; t) W. g+ i; h
Part partObject;
# ]( a& @* e1 }: A3 P# v U |' g* V PartCollection partList = NXSession.parts();
6 ]/ e3 x% |; k* |' q PartCollection.Iterator itr;8 C2 I1 Q4 {" ^" Q7 y
for (itr = partList.iterator(); itr.hasNext();) w( z' c) t( u% M2 f# l
{9 t5 _9 N& G1 n& {+ X0 v2 A
partObject = (Part) itr.next();9 z% V: Y; s$ q3 D: q; e; w# h
processPart(partObject);
9 u6 M3 r; j; C6 N }. E* z3 H- g( [$ f, b
part → list of solid bodies
x0 ^7 |& U) Q7 ] F0 PTo 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.
* j5 B' q6 y( ?! kpublic static void processPart(Part partObject)
% {6 |; w; Z/ J; \ M o{
8 C& T2 k* h. D BodyCollection bodyList = partObject.bodies();0 p2 N8 A+ ]. }6 w1 ]" S
BodyCollection.Iterator itr;
8 M0 Y$ w6 k' I; @9 T& Y0 E; ~# k for (itr = bodyList.iterator(); itr.hasNext();)7 ?( N$ P- I; x' `
{ + o/ A7 M. X' H1 D% U2 e- b
Body bodyObject = (Body) itr.next();. V" @, E# K$ S/ p% Q# E
processBodyFaces(bodyObject);
. J; Q. j, R9 b- L processBodyEdges(bodyObject); 0 Q+ D* z2 h) q, ]$ y
} 7 b0 k% e! Y# H* s
}
4 t9 e: ^! t! I5 B6 xsolid body → list of faces! @. y) |6 K" r4 b
To access the faces of a body use the getFaces() method to return an array of faces.1 g: Q" Q2 v' _9 ?0 a9 Z
public static void processBodyFaces(Body bodyObject) . P# J1 ~( a/ t) D& m. u
{
8 v+ J9 u1 b2 o* I) s# U7 b Face faceArray[] = bodyObject.getFaces();
" t* j6 J: Y: {+ Q* w for (int inx=0; inx <(int)faceArray.size(); ++inx) m7 p4 S c/ L2 G8 o
{
) X( U1 x0 C# Q+ n) G processFace(faceArray[inx]);$ z5 o$ [% T& @# Q6 r/ Z
}! v7 f& `$ F- F+ j5 C0 V
}
( Y. e: E( a8 j$ Psolid body → list of edges5 f% ^) J& r4 R* F+ R
To access a the edges in a body use the getEdges() method to return an array of edges.
; d# D0 a7 Q, l& N% Q, {/ _public static void processBodyEdges(Body bodyObject)
f" ^/ r! m D/ ]{ 9 g3 p& D, [! y/ v
Edge edgeArray[] = bodyObject.getEdges();
9 q) U$ {# @* A8 X& @
" x6 Q$ R1 @9 A9 w* ~ for (int inx = 0; inx < edgeArray.length; ++inx)
& K( E4 e, y+ b7 z1 X1 T { 1 ? }7 P6 K1 W4 ~8 ] [: H7 M- s
processEdge(edgeArray[inx]);
% {7 q$ H6 d4 S+ d; _2 W } ( [9 V1 F, W4 z% E/ F3 o. x
}
& ?7 E8 k& `+ k0 N2 ^% X+ R ; b& k) S4 ]+ [4 P
face → list of associated edges2 Y& G p5 A4 g4 y8 K$ b. H; f( L
face → solid body 3 J5 W3 I! F5 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.
% P1 O( o, |. D9 \8 ~5 l$ K5 U; Epublic static void processFace(Face faceObject) * R( m( K) W! \4 d/ X
{ " `. \/ M- F: I1 S$ z
Edge edgeArray[] = faceObject.getEdges();7 N/ \+ S. P( @$ q, D E+ m; @- c
/ g" u4 W* b" m: A. b# N$ M( q for (int inx=0; inx < edgeArray.length; ++inx)
$ i: \, W# } X& S$ V1 Z {
. Y: [2 j4 ^4 k: y8 n processEdge(edgeArray[inx]);
& ]6 m: I& }( R1 y6 x3 C5 f }
+ p( W+ R, x3 O( C0 V7 g P, v
/ e$ I3 n$ W" K4 \7 w0 ]9 _: S. i Body bodyOfFace = faceObject.getBody(); . l, K8 v/ | a. t7 j; x$ Z, B+ e
}1 ~3 e" ]& [- S7 N
edge → list of associated faces; d% j% H8 g' }: v- M* v
edge → solid body
& |. D# J- k/ I. _/ i% i) \7 qTo 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.! c* [4 _1 I: W0 T/ K- _" E
public static void processEdge(Edge edgeObject) 8 ]( o0 T0 Q# Y8 C* v
{ 7 S" T, S+ P' k$ x
Face faceArray[] = edgeObject.getFaces();
7 U5 y4 T) J0 { f- A& f$ h. i, } for (int inx=0; inx <faceArray.length; ++inx)- S2 V' Y( k/ u, j) r) L
{ # f% S/ P1 i; Z1 V. M5 ?( }
processEdgeFace(faceArray[inx]); 3 t# M! _, b! P$ D
}
- P: ~% j! N, h" |7 g Body bodyOfEdge = edgeObject.getBody(); 6 }5 e1 E* ^2 p H! a! ~- a$ O8 p
} |
|