|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息
3 T/ F6 i) N) P& l9 O; Q# q+ U - t/ k! I% \4 Q: J8 a. [# D3 m: X
9 {5 U: v* ]: q1 g
theSession->ListingWindow()->Open();% C2 @2 Q2 k: C, b0 i3 y
theSession->ListingWindow()->WriteLine("Get information from all bodies\n");
}) Z$ ^; g- i+ A2 ], e2 W std::vector<Body *> bodies;; ^5 \3 V6 o% L- ~+ M
BodyCollection *bodyColl = workPart->Bodies();
7 H7 g0 f7 K. j( f! M4 z/ S: r for(it = bodyColl->begin();it!=bodyColl->end();++it)
' r; v3 x' {: r `0 @/ @ {
' x7 d, ]1 c" O0 y5 F7 o bodies.push_back(*it);
4 {% Y7 p8 [$ \0 _ } o" I/ W) k7 T$ o7 [ g
ss <<"Bodies count = " << bodies.size()<< "\n"; n4 t( J! N8 b8 l/ d/ ?4 Z% q
std::vector <Edge *> edges;9 r+ F7 g' s8 m( n# W
std::vector <Edge *> totalEdges;
. f: \# X* d2 ?3 R2 x% a- b std::vector <Face *> faces;
$ |4 h9 ?# w; h+ E std::vector <Face *> totalfaces;$ @: E2 r6 ]4 Y: o
std::vector <Features::Feature *> Features;, b+ Y9 R8 i! |2 y6 C
std::vector <Features::Feature *> totalFeature;
5 N. e& }+ B1 w' n# V Point3d vertex1,vertex2;
- X8 `+ o7 F+ ^1 |( H for (unsigned int i = 0; i< bodies.size();++i) u' r( i4 I- z- x y, P x2 G
{" [: C- V( ~: ~$ ?2 g+ o
edges = bodies->GetEdges();
8 i7 O, c1 [% T' w faces = bodies->GetFaces();
. t6 m1 J8 B4 x& J% O! b7 ~ Features = bodies->GetFeatures();" y9 [$ `$ k$ R( d. O/ b7 U1 y
for(unsigned int j =0;j < edges.size(); j++)4 Y( ~; Z& P% Q! N0 `
{) y& ]/ @6 M; ^' k V4 b
totalEdges.push_back(edges[j]);
6 h# R3 a: d' q1 D3 x1 D) f: y }
5 X& A: a5 T$ P1 s) c for(unsigned int j =0;j < faces.size(); j++)
4 N9 |) |: B/ v4 a {3 B- C, a0 R( i& t0 m, J3 p
totalfaces.push_back(faces[j]);- u8 m ], W& O: i7 u1 a: t" u
}
9 w7 }6 T% l5 j/ w9 t/ C' \ for(unsigned int j =0;j < Features.size(); j++)
0 O( W2 f4 U( a5 b' u {
3 H2 P: m3 V: z9 x totalFeature.push_back(Features[j]);
8 g# {9 |/ K1 x8 V* m1 {* B }
* Z2 R+ ~- ] m7 P+ H8 ^/ j
1 a0 O1 y* F% x' R* s }% ^! S8 O+ S. s8 c9 Z
ss <<"edges count = " << totalEdges.size()<< "\n";
: s: g0 N; e5 C/ t7 M for(unsigned int j =0;j < totalEdges.size(); j++)
6 x6 l& X* \+ i K/ ~! q6 M% S {
/ ]. u6 n# u1 J; R# w totalEdges[j]->GetVertices(&vertex1,&vertex2);; b8 G7 S" A% \" H' u2 I
ss <<"edges tag: " << totalEdges[j]->GetBody()->GetTag()<<"\t";
. l. N! D3 l$ p: n( S) z5 v: `' r( n ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";
0 e l1 p# F k) b8 } ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n";
6 t# g7 W# e3 O6 I* V. B }
$ ]# ?4 H4 }' w; Y ss <<"faces count = " << totalfaces.size()<< "\n";+ Y- D8 U7 W' ~" H9 [$ J
for(unsigned int j =0;j < totalfaces.size(); j++)" M p7 h3 U8 P) r, _ w; J; I+ d' _* ]
{ 3 E9 h* Z2 x4 w7 {" k/ a* O
ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t";
' Y' s& }2 f. D' b$ Y k U ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";3 y2 S1 f* y! U$ l+ _5 B
ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";) z m- v) G6 s1 _, O P, ]+ Z @
}
) P: y0 {( |* @9 ^: [( R4 K$ i ss <<"Features count = " << totalFeature.size()<< "\n";' B4 R# ?! Y8 o1 O) C& ]
for(unsigned int j =0;j < totalFeature.size(); j++)8 |2 Z) `. |) `+ x% ~
{ [0 [4 o2 Z- J3 h- W
ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";8 D3 a3 B" D* T# _: D2 m' c
ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";
$ ]% A& S& a2 Q ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";
6 b2 f2 x- s5 H @/ ?0 i$ O }
7 c) t& f r% J! O& }4 V1 J' p theSession->ListingWindow()->WriteLine(ss.str());
0 n' B+ v1 B. B8 }0 l* c
* |7 r6 y" s6 |0 J: T! F% j( ~) ~, c- ^7 i- t9 [: t$ n
查询结果如下:
; y( e0 x# i8 [
8 K' {1 i7 h! D* Y
1 k C! |6 S4 v9 J( T, X$ U& v. t, QGet information from all bodies8 b" h: u/ x# J) X) h0 C/ f, I, Q& q
CYLINDERBodies count = 7
_0 e7 c c" oedges count = 22
: n k" K7 O$ ]5 e! w$ H% S* X" Qedges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100)* }1 Z0 i' ^/ T' `9 X
edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0)6 w* r4 d, \4 x- i! m& K `0 G
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)
0 M1 r6 {1 \: |4 dedges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0)
* V5 M2 }3 }0 m) w- j4 ]1 Vedges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100)4 e j) m- V G# z) o F
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)
! H& c6 e9 m% _4 k4 C: v3 z! ^edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100)
. z4 G( z# |) p4 M% L2 Kedges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100)
8 s- Y* B% _' L4 c! @5 hedges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100)5 g2 x. q; j. ~! C2 N5 a$ {
edges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100)
) F. H7 A0 M" Xedges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100)
0 y: b* Y: G( I) Redges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0)
: P+ u1 ]6 @# n, s, ?! P1 `" dedges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100), b$ Q" B+ y! D6 E8 v
edges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)
9 a5 j( U! `3 Q7 l# d Qedges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)
; `- J) h% \8 X( D$ sedges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
: c R8 c4 \5 N# Dedges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)- Y8 S# ^+ a2 Q4 @
edges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)
- {" I+ S5 e5 @edges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)# D1 ^+ E( b1 [$ B8 ~5 J1 G1 S
edges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500)% G, g* F( G3 L& b/ f
edges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200)
) Q9 V! Z' D c! cedges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)- }5 f) l l2 j5 [: F! ^# b. r
faces count = 22
/ O! y/ w y$ b* wFace tag: 41407 Face Type: 4 Face Name:
2 N3 J' W! K! u6 c: l. E6 Z- qFace tag: 41398 Face Type: 1 Face Name: 7 g7 I( z8 |/ f$ w9 ^( I
Face tag: 41376 Face Type: 1 Face Name:
, p$ q- f4 f4 J* n7 C2 g+ S" ]Face tag: 41391 Face Type: 1 Face Name:
" v/ {+ R. B- {Face tag: 41380 Face Type: 1 Face Name:
; f/ g/ y. P# ]1 j0 jFace tag: 41396 Face Type: 1 Face Name:
% n I0 L* U! W& A) P* BFace tag: 41397 Face Type: 1 Face Name: , F. [- k% _4 Q3 p7 \) [
Face tag: 40995 Face Type: 2 Face Name: , f. w) [4 b' b# L0 T
Face tag: 40965 Face Type: 1 Face Name:
5 }" I' g: Q! p0 q9 aFace tag: 40997 Face Type: 1 Face Name: ! A) F4 ~, I; \- C$ Y
Face tag: 41351 Face Type: 1 Face Name: 2 F0 ~% D* g5 [/ \. W/ y, W/ J
Face tag: 41352 Face Type: 1 Face Name:
% q4 S/ p$ F1 G2 t, s: hFace tag: 41353 Face Type: 2 Face Name: 4 y; k: }' v6 ]( g$ A
Face tag: 38479 Face Type: 1 Face Name:
9 h& D& V3 B$ I4 z/ ~6 DFace tag: 38480 Face Type: 1 Face Name:
* B8 r! n! k6 V0 q. n. yFace tag: 38481 Face Type: 2 Face Name: $ [: |5 r! ]( X5 c8 J7 k ^/ y* ]& ?# a
Face tag: 41207 Face Type: 1 Face Name: & g& H' d( a8 \9 h' S
Face tag: 41203 Face Type: 1 Face Name:
! U+ }: O9 u4 K4 c/ I" F/ bFace tag: 41158 Face Type: 2 Face Name:
* ]/ N$ v. j3 j0 JFace tag: 40987 Face Type: 2 Face Name: 8 u; |( C: ^5 o& t; p* f1 R
Face tag: 41010 Face Type: 1 Face Name:
( K6 r) ?3 J) d# XFace tag: 41001 Face Type: 1 Face Name: / |3 b- o) R6 n* q) u) ^# n% h
Features count = 7
/ u# R. t5 q) pfeatures tag : 41280 features Type: SPHERE features Name: Sphere(17)
* y3 F2 H1 _$ ?& m9 }features tag : 41281 features Type: BLOCK features Name: Block(18)5 {7 K- ^0 t8 j- \8 \
features tag : 41307 features Type: CYLINDER features Name: Cylinder(19)
7 p( c% b8 `- \/ g2 @+ |features tag : 41314 features Type: CYLINDER features Name: Cylinder(20)$ i6 ]( |) g. G6 S
features tag : 41322 features Type: CYLINDER features Name: Cylinder(21). z* ^% w0 m) P9 L) j* [
features tag : 41330 features Type: CYLINDER features Name: Cylinder(22)1 r5 G- [ I. z5 v ^8 C6 I
features tag : 41338 features Type: CYLINDER features Name: Cylinder(23)
2 m5 _& J( f, c( E- u, m5 p" o2 X" ]5 H0 p6 R% C1 ?! R P+ d
|
|