|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息
2 V) h, ]! D8 G- u" y7 t" t # j7 j' O5 ]# o, @" `6 y9 H0 w
; v% u* J% m! e8 ^. Y$ w* a' X0 _3 K
theSession->ListingWindow()->Open();
( j( `( s, Q$ v D) l5 u0 V) B theSession->ListingWindow()->WriteLine("Get information from all bodies\n");
6 u# e/ M: B K* P( |% l std::vector<Body *> bodies;! {8 ]+ ^% f" a/ N0 M
BodyCollection *bodyColl = workPart->Bodies();
, w6 G3 D# L' W* C: |7 L for(it = bodyColl->begin();it!=bodyColl->end();++it)
. d* y4 q0 v o" X6 h6 R. x {) t6 ^$ R# j0 o
bodies.push_back(*it);5 O, t1 j5 v( S: p9 F/ r
}
; t" c( `" X. v, W5 m& }# ]( j1 A ss <<"Bodies count = " << bodies.size()<< "\n";
* X, M* d6 K& q; T; q std::vector <Edge *> edges;4 L, y! M8 z) I
std::vector <Edge *> totalEdges;
: `2 ]0 g6 w$ S% v9 i std::vector <Face *> faces;
) F( T% V+ m( u: A6 q4 l9 U. ^/ D1 C std::vector <Face *> totalfaces;) k; O& X5 F* C8 m: _. f/ C
std::vector <Features::Feature *> Features;
, S' {, G0 l6 F' j$ ^5 y std::vector <Features::Feature *> totalFeature;$ v% v% Y' y3 u% }4 |, O
Point3d vertex1,vertex2;* H; K& _# J4 f6 A8 o _3 Y! Z2 K
for (unsigned int i = 0; i< bodies.size();++i)
% o0 [( L$ p! b; r {: a. M' g4 G/ h" Q: ]* \# M
edges = bodies->GetEdges();
& r5 W3 N4 s2 B4 i' A" v% c faces = bodies->GetFaces();9 o4 V% |8 K5 o/ }
Features = bodies->GetFeatures();
1 y9 I8 A3 X3 C9 ~4 F0 C for(unsigned int j =0;j < edges.size(); j++)
: d* r% F) z" }- |- Z {
- _( C2 W+ ~; d. U$ c totalEdges.push_back(edges[j]);
" ~0 S: X0 v" N& t, ]# H: e }
, @: i+ `1 e' C; ?- u; ]# ~" [ for(unsigned int j =0;j < faces.size(); j++)3 \3 }! \7 ]0 S P7 N9 T
{. o3 k7 T$ j3 R8 j2 X2 ?1 A6 B
totalfaces.push_back(faces[j]);
. @5 ?5 |5 q' ~ L+ ]4 W* ^ }
3 E, D; x: d( f5 B* M- V for(unsigned int j =0;j < Features.size(); j++)6 d y- M3 I' C- N9 r8 q
{
' x# e1 P1 D6 V u$ m: y totalFeature.push_back(Features[j]);$ S8 f7 J7 A: m; [3 ?
}4 ~! X" L5 I" Y& _
2 t' @/ y/ I; K$ d: ]+ x }( u4 E9 K/ b" y, c5 y) W
ss <<"edges count = " << totalEdges.size()<< "\n";
! Z) @- e; Q: u7 y" }3 e0 y0 ^ for(unsigned int j =0;j < totalEdges.size(); j++)
: H, [6 q% x: V$ t { ( {+ j, a( n" C& A& i7 b
totalEdges[j]->GetVertices(&vertex1,&vertex2);% k; l0 L, e: E+ W# b7 x1 c' J
ss <<"edges tag: " << totalEdges[j]->GetBody()->GetTag()<<"\t";$ S) J& S F6 G, W& R
ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";
% L6 ]# V& P# a2 q1 y( Q( e" p ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n";
( p5 S/ s F, d& h5 `" j5 v$ j }8 j: N* H7 Z5 `
ss <<"faces count = " << totalfaces.size()<< "\n";
, b+ I1 I- Z; t7 `( V: x* h for(unsigned int j =0;j < totalfaces.size(); j++)
7 ?8 G5 p/ b. N. r6 o% R* d {
, [: |- A: P% g( r5 ` ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t";
, P. u0 A+ Q, I ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";& t( a( q8 [6 k, e6 N0 V
ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";3 |" _& G" } ]3 n' C5 H6 C! z
}1 S* |7 v5 f) i( ^7 w& N, s; ^
ss <<"Features count = " << totalFeature.size()<< "\n";3 x1 o# {% h/ C m0 l' } {
for(unsigned int j =0;j < totalFeature.size(); j++)3 u3 f* T( W1 F1 c: A4 |; K
{ , Y* i" e3 I- z! x5 r
ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";
1 ]7 v' v& w) e( _$ r4 n0 _$ y ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";4 ~* ^, s' N x1 K7 j+ X
ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";
% W) F* Z( q; ]0 i/ u# Z }2 X' F+ i; t% a, s& V8 K% G
theSession->ListingWindow()->WriteLine(ss.str());
- v" m% p# l# N# X3 S, ?5 {
[! ~0 o: I" G0 _9 h$ V6 t# t# S! c- G( I) X
查询结果如下:- N# G% V8 X; |7 P6 }
" A, M* t( v5 ~9 \2 B$ y
! U+ o5 X$ l. B, U* Y. Q
Get information from all bodies w" M: k$ A8 g3 D. P, ~; l1 z9 Z5 `0 h
CYLINDERBodies count = 7
2 U; I! y( k' b) P: ]edges count = 22( s6 @" ?' w' i" V7 o
edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100)( s6 c: X3 f7 b3 F+ a1 R
edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0)
( a& z- A5 _( iedges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)
( n G1 J7 x6 C Q1 ?edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0)! C$ w8 g+ e6 R* f6 j
edges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100)
6 `8 ~1 ~+ G! i; \! ?6 medges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)! O( u! ~4 E: ~2 f8 e$ S% R
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100)2 c+ P( i z% Z' [0 k
edges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100)8 I' x+ ?3 }$ ^; O
edges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100)+ t7 C ] c: |* f5 D
edges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100)$ l& w) ?* j% D. b
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100)6 y4 b) r4 W4 |! g6 y
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0)( I" @ P6 Z5 E" a0 K
edges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100)$ V7 I. u# Z( S* F7 B/ ]* ~
edges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)1 B# N3 n. B" |& ]% _
edges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)' Z: t6 o, C4 t, r7 x: J6 |# N' Z, G. Z
edges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
4 {, W2 [9 g% Fedges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
8 S# k& R+ |1 Vedges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)
, P0 u& f+ u) n7 I! z5 ?/ U l. ]edges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)4 v- r- n x7 ?6 a# K* A" r1 F! |
edges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500)8 p- P% E. Y1 g% }, J
edges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200)! h! m ?' S2 f
edges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)
- c8 @ W1 y" ]6 y: U( d2 q6 ?faces count = 22( m0 e' @2 Z0 ^7 @* q& j
Face tag: 41407 Face Type: 4 Face Name: 5 t# b0 j! R& Q$ \. s6 `& I
Face tag: 41398 Face Type: 1 Face Name:
) O# I1 L1 y6 }6 t3 kFace tag: 41376 Face Type: 1 Face Name: # s u& ~! A! M7 d* }" n2 b' n
Face tag: 41391 Face Type: 1 Face Name: 6 m9 B* w; _- W8 _( u- a& s
Face tag: 41380 Face Type: 1 Face Name:
- x9 @2 s+ \ n. U# C9 UFace tag: 41396 Face Type: 1 Face Name: 5 ^5 w4 R/ N9 T& \9 Z i! @2 u
Face tag: 41397 Face Type: 1 Face Name: 7 l- T! F+ g" a
Face tag: 40995 Face Type: 2 Face Name: 8 C3 _2 s4 _: v, ]; v8 B
Face tag: 40965 Face Type: 1 Face Name: 1 Q$ F! a5 z2 a! m, ~9 I
Face tag: 40997 Face Type: 1 Face Name:
2 ?( w! K! e' Y& w9 s4 h. FFace tag: 41351 Face Type: 1 Face Name: 2 _: i1 r& i2 V' `2 {0 e
Face tag: 41352 Face Type: 1 Face Name: ) e- E2 H' y% Y7 z
Face tag: 41353 Face Type: 2 Face Name:
+ U, k- J2 _* t' o0 n+ S& M+ M5 qFace tag: 38479 Face Type: 1 Face Name:
8 V, t! |. \% SFace tag: 38480 Face Type: 1 Face Name: 2 W* _& M8 g9 k' W
Face tag: 38481 Face Type: 2 Face Name: & `+ L4 T* k8 J/ T, g6 u
Face tag: 41207 Face Type: 1 Face Name:
( r7 R4 u( P* ^$ M [Face tag: 41203 Face Type: 1 Face Name: W, [' L! ?% `6 J& u* n
Face tag: 41158 Face Type: 2 Face Name:
8 @& x; B5 o7 y& e/ VFace tag: 40987 Face Type: 2 Face Name: " B7 {7 d- V8 o/ m# B5 f* Z
Face tag: 41010 Face Type: 1 Face Name:
: o& \/ C; V: N5 B6 k* {Face tag: 41001 Face Type: 1 Face Name: / n0 c5 K' b( r2 F9 ?
Features count = 7: k8 d4 t ~, R* l6 D+ w
features tag : 41280 features Type: SPHERE features Name: Sphere(17)- i- h6 n2 v! d- a
features tag : 41281 features Type: BLOCK features Name: Block(18)
1 }4 v% ?# N9 @, } j+ d$ A+ xfeatures tag : 41307 features Type: CYLINDER features Name: Cylinder(19)5 ?6 E$ d4 O; Q9 q3 [7 k
features tag : 41314 features Type: CYLINDER features Name: Cylinder(20)
6 l3 G' }5 D s8 Kfeatures tag : 41322 features Type: CYLINDER features Name: Cylinder(21)
, p" w, a3 _. u9 \8 nfeatures tag : 41330 features Type: CYLINDER features Name: Cylinder(22)
' U- j) P; x& q& E5 Efeatures tag : 41338 features Type: CYLINDER features Name: Cylinder(23)
6 R$ @$ }$ a& ~& }% j3 I: _/ C' ^1 n( m) {
|
|