|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息
) e: o8 m2 P* \3 I: o |, d! H5 ] M+ s: b6 ?& \2 j6 |
/ ?( U3 P5 o, R D$ O Q( @% a& P
theSession->ListingWindow()->Open();
% y" G1 ]# L: T theSession->ListingWindow()->WriteLine("Get information from all bodies\n");
- m; g4 f% f8 Z$ ^! V% x2 K std::vector<Body *> bodies;+ x; g% B H& b% u( a
BodyCollection *bodyColl = workPart->Bodies();
% D6 l) p6 O" f3 s% p for(it = bodyColl->begin();it!=bodyColl->end();++it)
8 C4 H1 E+ F, r$ ~$ i: E {5 e8 e' s9 M2 T! Z" S
bodies.push_back(*it);
; Q# _: d3 n1 i) q }' t r( d$ }2 o
ss <<"Bodies count = " << bodies.size()<< "\n"; z z z) {$ C! |. G
std::vector <Edge *> edges;' B6 E; n! U5 s" ?1 v9 I# o$ m
std::vector <Edge *> totalEdges;
0 {" l) ^5 l, B7 z" ]- H std::vector <Face *> faces;
8 d- C6 t' _' j7 H6 O. K std::vector <Face *> totalfaces;' W0 r+ l; o, Q P, [) n) D
std::vector <Features::Feature *> Features;
! A' ~- Z) a% t6 c3 ~ std::vector <Features::Feature *> totalFeature;& u2 O$ j. ^7 J) E* Y
Point3d vertex1,vertex2;3 O/ _1 k& p, i* k$ U
for (unsigned int i = 0; i< bodies.size();++i), @. Z3 ?* A1 W7 V6 i4 g1 }3 @$ r2 Q
{
9 V5 e2 l" ?5 Z( z2 D edges = bodies->GetEdges();
6 s( [+ n9 n0 l' a/ P. m) e, F faces = bodies->GetFaces();( b. p/ ^4 t$ E' ~# L
Features = bodies->GetFeatures();1 N2 h- n* a7 W( F2 Z' V
for(unsigned int j =0;j < edges.size(); j++)
) x. r6 {, \( A# r1 |9 a {
+ k3 x1 z- J6 B6 z' J; V totalEdges.push_back(edges[j]);
0 M; A$ S# g5 J% k3 J# H' d }( D( V9 ~6 k' d9 m x) p
for(unsigned int j =0;j < faces.size(); j++)* `' j8 G) R, d P6 \) i2 c3 w
{; ?, j: l$ F' C' z2 b
totalfaces.push_back(faces[j]);
! m7 X* z1 ]. j' f8 [) k7 m }
7 N j5 x5 p9 o7 q# c* K( J. F for(unsigned int j =0;j < Features.size(); j++)0 w: S* n4 H' a& w, E) V9 L
{0 j7 i% K5 K. [" `! N
totalFeature.push_back(Features[j]);
1 n: D/ X9 z, x; O: [ }
9 g) B; r* S5 r4 s- @5 T 6 Z5 D8 N' A s- d j
}$ M/ d: R% ^; D- w+ W( W' U/ Q$ W
ss <<"edges count = " << totalEdges.size()<< "\n";
- s1 v4 x& g; J+ T" z' G for(unsigned int j =0;j < totalEdges.size(); j++). f3 S+ V$ r2 O: @" y) E
{ - { O; b @+ k7 _! G; g6 G. i6 t
totalEdges[j]->GetVertices(&vertex1,&vertex2);
& P" O6 u2 U2 B5 s ss <<"edges tag: " << totalEdges[j]->GetBody()->GetTag()<<"\t";% g5 E9 n4 O( r& Z4 F9 \
ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";) t5 }7 _& U1 ~) V7 E. V. q
ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n";
Q4 i+ P3 t# G( G/ V) F G8 Q7 m }6 w7 |& ~* H* W1 N( f
ss <<"faces count = " << totalfaces.size()<< "\n";
' n7 m$ P% l+ e) A3 J/ n _ for(unsigned int j =0;j < totalfaces.size(); j++)
: |0 X$ H$ J' n1 K& G' q2 q { 8 f' N/ N5 n9 o t2 z6 s& q/ n( Y( l
ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t";
( [' ?, n! V7 I0 l. K8 K, { ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";
; S9 P/ F/ e* h& N ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";" A9 H) v# H, ^
}/ I4 `2 ?+ x8 R
ss <<"Features count = " << totalFeature.size()<< "\n";& J- |5 ~8 x, G G, r% O: ~
for(unsigned int j =0;j < totalFeature.size(); j++)
, _9 e. G f! @+ G1 L; N8 ~ {
# d9 H4 c! i9 h1 P$ y ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";
/ o& o) {& n2 s$ X ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";
( i4 G4 X" V# g/ B( h7 {. g% u ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";; s& D# w2 n+ z
}
& v$ [7 V9 q! N0 V theSession->ListingWindow()->WriteLine(ss.str());
; C4 s/ z. R4 @- T
3 B, B# {8 n* o, w" j( A1 X( Q
" f8 O ^1 N( C! B) m0 @5 z: F9 t查询结果如下:: r6 v* H, {6 W$ w7 P% q
; \; I) ^! [. E) S& I. t! `! \9 ~+ l* U `' t- ~
Get information from all bodies& l9 D. E1 q, X# F3 y, w+ L
CYLINDERBodies count = 72 ?& k+ d: }, Q
edges count = 22
% [; C w! c: qedges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100)
( `: L- E2 F' U/ f9 S2 K" Cedges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0)
* Y) H1 S7 y% F3 r0 Gedges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)+ L7 ?' s) o6 o2 n% [8 h( ~
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0)
. Z. Z; F& ~8 }% S) ]edges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100)% D+ n+ W* l8 u
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)+ v1 t! ]4 l) ?/ I+ l
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100)
% A B m u- q: S- @, Pedges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100)
0 N! d7 b: m4 n \6 T8 ]edges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100)7 M# M9 ]8 o) o5 q, W. n$ ?
edges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100)
Z/ _7 H& V0 }4 i- Y1 Kedges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100)0 b k% F/ k- h: U: I/ I
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0)$ j7 m: K, l4 H8 [# x( M
edges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100). W* u9 h# o, s$ o1 N! V9 m
edges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)
- j! T# l3 y& l8 m/ q6 Q% pedges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)' z4 f; s3 p1 i; r7 _7 _* o. C; m
edges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
( I$ y$ f) h) U2 K& l, v- \, iedges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
3 g) U7 G$ S# }( g' x: c+ u% oedges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)( y# |/ w+ [7 W+ ^, U
edges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)8 L3 b6 d. y0 t/ N5 o) }0 Z
edges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500)
: m8 t- D: t8 t3 I, kedges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200)
* H% e# i# B7 y7 j a$ kedges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)
3 p: i8 L/ J4 G3 v, W m9 Q1 _faces count = 22: w: [. b' \( a; l0 S5 q
Face tag: 41407 Face Type: 4 Face Name: 3 r" e$ ^+ ^8 l& O5 B) M9 z
Face tag: 41398 Face Type: 1 Face Name:
& y1 |2 r$ m. G6 LFace tag: 41376 Face Type: 1 Face Name:
: R: C" ~- s4 i1 yFace tag: 41391 Face Type: 1 Face Name: ' m. \$ ^9 d+ L' h$ r
Face tag: 41380 Face Type: 1 Face Name:
) W4 f1 P8 S( ^+ N* `% y; xFace tag: 41396 Face Type: 1 Face Name:
' U8 J* z3 i3 c; l8 D6 T1 fFace tag: 41397 Face Type: 1 Face Name: 7 @7 {& }7 o% `! \6 O) T( {
Face tag: 40995 Face Type: 2 Face Name:
# [! T! h& S% a$ w% t9 DFace tag: 40965 Face Type: 1 Face Name:
( l4 h1 F* N# ^: R0 @7 }: c& H9 i% r AFace tag: 40997 Face Type: 1 Face Name: ) y0 H1 {/ q2 Y1 T6 T
Face tag: 41351 Face Type: 1 Face Name:
' L# q0 ?% w5 z4 K8 M5 j2 \3 BFace tag: 41352 Face Type: 1 Face Name:
`% g; I; s/ d( `6 GFace tag: 41353 Face Type: 2 Face Name:
+ J5 q7 y6 f- N, G* D' MFace tag: 38479 Face Type: 1 Face Name: 2 h8 x7 @$ a' d( g, `( o6 I# v( m! s
Face tag: 38480 Face Type: 1 Face Name:
1 ^/ M* k" E! K6 P5 A0 M& qFace tag: 38481 Face Type: 2 Face Name: 0 \% r0 q% _( }: D
Face tag: 41207 Face Type: 1 Face Name:
# X, M5 F( v) ]# ]& D# b' J& J, FFace tag: 41203 Face Type: 1 Face Name: 3 b1 L* ]" L8 w
Face tag: 41158 Face Type: 2 Face Name: 1 e: O! y L) C+ u3 \
Face tag: 40987 Face Type: 2 Face Name: , V( ~, Z- y3 K( G7 }1 O8 K
Face tag: 41010 Face Type: 1 Face Name: : f; q/ i% N7 g; ]
Face tag: 41001 Face Type: 1 Face Name: 3 y- E( T0 x/ j) w$ R' Y/ ?
Features count = 7, t$ }, i: E0 }" o: b7 L5 ~
features tag : 41280 features Type: SPHERE features Name: Sphere(17). a% T7 ]8 j& f& E2 ]& K1 G1 z
features tag : 41281 features Type: BLOCK features Name: Block(18)
' r( d7 \8 J; z) ~' |5 s( bfeatures tag : 41307 features Type: CYLINDER features Name: Cylinder(19)% v" v$ o( M0 B
features tag : 41314 features Type: CYLINDER features Name: Cylinder(20)1 R" B' W" `5 C. w8 R
features tag : 41322 features Type: CYLINDER features Name: Cylinder(21)
2 M2 H1 ~6 L g B0 kfeatures tag : 41330 features Type: CYLINDER features Name: Cylinder(22)" F' A/ x9 A9 f3 B u
features tag : 41338 features Type: CYLINDER features Name: Cylinder(23)
0 S/ A; z0 |! ]- c/ y6 W* L
% p2 E; F' Q9 g k5 \ |
|