|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息4 v5 P/ u5 z1 d/ _
( B( ~2 V/ C. d4 j" r: B
& M8 d+ y, |; _% p theSession->ListingWindow()->Open();6 T* {; A) { m6 ]& Y
theSession->ListingWindow()->WriteLine("Get information from all bodies\n");
; f( D* ? c, c std::vector<Body *> bodies;- l+ C4 j; N1 u# v. ~! E, a
BodyCollection *bodyColl = workPart->Bodies();
2 Y% o* ]" F, K2 ?7 P for(it = bodyColl->begin();it!=bodyColl->end();++it): I0 q# r0 }1 u" n8 I
{9 |6 I: D! y6 Q+ ^. K" H! W
bodies.push_back(*it);7 v" c- s# W. ] s1 f( S0 z
}" G4 o, \* j' N% L2 [
ss <<"Bodies count = " << bodies.size()<< "\n";7 R5 E) G7 D6 _; _. b
std::vector <Edge *> edges;# Q0 A0 Y) V8 B) O; o; [
std::vector <Edge *> totalEdges;
& l; J, E/ Y6 q i std::vector <Face *> faces;
5 M+ o2 O& p% n' ~ std::vector <Face *> totalfaces;8 Y4 i' c" |3 U" I' U/ u
std::vector <Features::Feature *> Features;& ~" e* J# t, S q9 N& f) n
std::vector <Features::Feature *> totalFeature;! M% \! W1 \; A3 M& X9 c( y
Point3d vertex1,vertex2;5 x; A0 l/ m+ V, r" H7 _! p8 y
for (unsigned int i = 0; i< bodies.size();++i)
! j4 n4 V' |! w+ h {7 f7 Q" P9 I% ^0 g) p. J; v
edges = bodies->GetEdges();
8 O" x5 o2 V" m7 `4 O faces = bodies->GetFaces();
; ~- P6 N/ m; o& c( ~2 b( A Features = bodies->GetFeatures();" O. X2 [& W! H4 r* }% P5 s
for(unsigned int j =0;j < edges.size(); j++)
4 t9 l/ v" ?% W, m: s {
/ K; }) l; e2 M# F5 C& x totalEdges.push_back(edges[j]);
# |3 [' l. d0 y3 U* _! q" B; K }
& k# {! t2 v2 ^( @) X* a6 Q for(unsigned int j =0;j < faces.size(); j++) {) j p/ X4 H
{1 x" [: j/ e. T
totalfaces.push_back(faces[j]);1 @! Q4 Q, \( H
}
4 R' {$ o$ x' c8 \7 k' E for(unsigned int j =0;j < Features.size(); j++)* L% a( P8 E3 m' V+ r) z
{+ x2 K" |- f3 }! }0 Z
totalFeature.push_back(Features[j]);
: N) \% m, z2 S" l5 ] }
3 F/ ~# L& w7 B p2 R3 e" q
# ?1 ?# E/ d& m8 ^8 R( J& j. [& Y, A }/ ~3 a7 C: N6 A+ o Z4 W
ss <<"edges count = " << totalEdges.size()<< "\n";
# u. l4 j, v6 B4 f& [3 ^! s9 m# g for(unsigned int j =0;j < totalEdges.size(); j++)
1 V) P1 t; Z- `, ?0 | {
4 O% m/ m. E, G: l3 w6 @3 U totalEdges[j]->GetVertices(&vertex1,&vertex2);* f% k O, m/ F/ A
ss <<"edges tag: " << totalEdges[j]->GetBody()->GetTag()<<"\t";
; ^/ T, x4 r9 Y+ } ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";
9 l0 n6 K2 d, ~) I! l" `/ R ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n";
2 g3 t. v; h4 E9 \+ T }
8 V7 N0 ?( ? |5 E. i( J ss <<"faces count = " << totalfaces.size()<< "\n";& M1 g; Y% e" k3 z& {! B+ C
for(unsigned int j =0;j < totalfaces.size(); j++)
, R! Q3 _% P& H$ n, E3 Y" i {
7 }0 C W8 q( k+ F& d- g2 D ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t";
6 \( }% A& E( ~6 L ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";
2 H# s7 Z) s8 y4 `6 t ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";0 [* M: W0 I; j) r0 j
}. b" O( a; N' }! ^
ss <<"Features count = " << totalFeature.size()<< "\n";8 X' w4 H9 q3 P% o% ?7 R
for(unsigned int j =0;j < totalFeature.size(); j++)6 l$ Y0 \0 r9 y' ~, f0 G
{ + n! @* r/ _% F: }" |
ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";
3 C5 H/ S" H! L* I2 T ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";! C. } T0 H3 c3 b$ a: ~' V
ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";* a+ U% n7 Q! a; _+ s! L
}: W8 [5 {0 n8 {0 T
theSession->ListingWindow()->WriteLine(ss.str());
" @/ J D/ p+ ]- R* ?4 T) H) w/ F# ?
6 r9 R" Y4 h+ E0 s: S( \) H3 W6 v$ c查询结果如下:
7 R8 ~. k/ A/ C9 ~7 f! `/ g I4 w& N. L* g" O5 X$ ^% @
6 J; {8 V. [2 @2 b
Get information from all bodies2 l& S: |5 z7 p$ @, x, A
CYLINDERBodies count = 7
4 S) c0 z$ N- kedges count = 22% h' l6 ~! l- a; A3 c7 ^
edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100)3 R0 }9 \$ \! \4 s
edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0)
7 ^( m$ ?+ ]) u) A5 J0 f4 I8 ^/ ^edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)
?* W3 X, W- e. b' Bedges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0)7 l9 b/ Z$ p: Z1 M# i
edges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100)$ q7 u/ h6 j/ V: r# ^
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)( r S% o, k, x9 K
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100)
2 ]% f, ?1 R( I- J& S# {+ @- medges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100)- u& r) c7 h( W, l' m% n7 W
edges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100): N7 j7 ]8 t0 W/ Z" a& J
edges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100)
2 T8 `, E$ \4 x% F+ ^3 cedges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100)
$ h# v- Z0 ~& u) Xedges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0): I9 r% ?7 e" n, p& ?5 ~2 x6 Z, @
edges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100)
% s/ [. w; W4 c5 e( b$ s4 K! ledges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)8 c! @ I7 o4 F. T# H
edges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)
# |; ]$ G' ~9 iedges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)# u3 ~9 C) K: A; z& M9 V
edges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
4 X" \6 n# w& M/ t( ]2 N. F6 _% cedges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)+ x, b, Z0 d8 p9 H6 j/ b% N
edges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)% o8 v+ R g, t9 c4 R
edges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500)
, `7 G7 f/ p# b0 a5 D$ E# T tedges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200)& l* K$ ?2 A7 j7 i; X. F5 b
edges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)
6 n4 q) K% V# X% q mfaces count = 226 B; z/ `5 T- n) ?
Face tag: 41407 Face Type: 4 Face Name:
+ g9 p) d ^/ ]4 ?6 N' U% d$ cFace tag: 41398 Face Type: 1 Face Name:
6 G8 q- @) r& H" t0 mFace tag: 41376 Face Type: 1 Face Name: * q" z3 K8 f0 U% M3 q" W2 V
Face tag: 41391 Face Type: 1 Face Name: ' p6 }1 {7 n# K* T+ b [
Face tag: 41380 Face Type: 1 Face Name: : g& ]: E& {' b/ F
Face tag: 41396 Face Type: 1 Face Name:
y+ [2 i$ m3 |4 _! Y- pFace tag: 41397 Face Type: 1 Face Name: $ \ U q2 n: L' \
Face tag: 40995 Face Type: 2 Face Name: 0 \, D) D1 Y# Z( ~' D& p7 {
Face tag: 40965 Face Type: 1 Face Name: Y$ Z/ [8 x/ {! e3 u" [
Face tag: 40997 Face Type: 1 Face Name:
& A9 u$ d! j* c3 sFace tag: 41351 Face Type: 1 Face Name:
" Z! L/ I3 P) ?9 yFace tag: 41352 Face Type: 1 Face Name:
_# \1 d3 z" v* @: B6 QFace tag: 41353 Face Type: 2 Face Name: 9 \. |+ `4 r8 z
Face tag: 38479 Face Type: 1 Face Name:
5 z! o! e6 q4 x; YFace tag: 38480 Face Type: 1 Face Name:
$ J& G# G8 x3 F) a7 wFace tag: 38481 Face Type: 2 Face Name: # ?& n! @/ M# l2 U. O
Face tag: 41207 Face Type: 1 Face Name: ) r; M( V0 o |# _6 G0 k
Face tag: 41203 Face Type: 1 Face Name: 8 B6 @+ Z3 q2 P% k# L& U# l
Face tag: 41158 Face Type: 2 Face Name: 5 o2 R1 J; j+ j% L
Face tag: 40987 Face Type: 2 Face Name:
5 f& C4 M) x) E$ i2 tFace tag: 41010 Face Type: 1 Face Name:
' t$ B7 B8 ?! gFace tag: 41001 Face Type: 1 Face Name:
8 D) S6 ]+ h4 L& s: s0 P/ B! fFeatures count = 7
" V4 f- g2 A2 pfeatures tag : 41280 features Type: SPHERE features Name: Sphere(17)' w$ P0 ^. q* G2 f0 W2 z8 b6 d$ J
features tag : 41281 features Type: BLOCK features Name: Block(18)5 r8 Z0 q- o) _! i% w7 O
features tag : 41307 features Type: CYLINDER features Name: Cylinder(19)
/ T1 _- S: Z+ D* w$ G" K. W2 Efeatures tag : 41314 features Type: CYLINDER features Name: Cylinder(20)
# _# x4 y' n+ H8 o7 }) q: Cfeatures tag : 41322 features Type: CYLINDER features Name: Cylinder(21); \6 m$ q+ |5 h) Z' j0 x
features tag : 41330 features Type: CYLINDER features Name: Cylinder(22)1 M1 f. B; |2 G0 P
features tag : 41338 features Type: CYLINDER features Name: Cylinder(23)
9 }" u1 y0 X+ X! S; H4 d) p, t: E" W
|
|