|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息
6 T3 |5 n0 {- V8 [
. Y4 J7 ?) C. @8 c* e4 T5 W9 ?' i) z1 L* {0 y4 ^: V+ S' c
theSession->ListingWindow()->Open();
; V+ `6 J$ j9 s) K# S( Y7 e( Q theSession->ListingWindow()->WriteLine("Get information from all bodies\n");; Y X( z5 K- C# t
std::vector<Body *> bodies;
; b3 q/ K, v8 s/ g) { BodyCollection *bodyColl = workPart->Bodies();5 x7 X8 g) P( D z& i8 z
for(it = bodyColl->begin();it!=bodyColl->end();++it)! F' a& B0 m. ]) ]- p$ w
{
% {4 ]" u: g! E! R& `+ @3 ]* x bodies.push_back(*it);) \, x" ]* `+ T6 T. V, q6 E7 @$ d
}
/ [3 P& E( a" W0 c* n8 e ss <<"Bodies count = " << bodies.size()<< "\n";5 B9 {( z' z+ O% ?
std::vector <Edge *> edges;/ n O$ ^7 q. u' b
std::vector <Edge *> totalEdges;
! q7 }2 v+ z/ G& } std::vector <Face *> faces;* I3 A% I. {$ s. h+ r
std::vector <Face *> totalfaces;
! x5 L' h3 k6 p# G+ o8 W4 L std::vector <Features::Feature *> Features;
5 i6 F! O# i" s B2 ] std::vector <Features::Feature *> totalFeature;" A5 T1 F G9 b6 K! l! c" P8 C6 \
Point3d vertex1,vertex2;& t+ j& T) d" S# j2 s
for (unsigned int i = 0; i< bodies.size();++i)3 J1 ^7 P- G9 j( ?6 V% X, o
{- _! e8 N E2 o" L. S9 p7 w. i& Q
edges = bodies->GetEdges();
' `# W6 j: [; Z* [9 B( m faces = bodies->GetFaces();
* ^& L% y, g/ k8 H4 e! i' ^ Features = bodies->GetFeatures();: I9 Y! c& {, w0 X0 n, R) a
for(unsigned int j =0;j < edges.size(); j++)4 g! ?2 i" g) |- k+ f
{
/ k, E# D* N" u7 v- d totalEdges.push_back(edges[j]);% ?: _! j4 t7 }* Z# m. Y
}
0 Z Z7 c! s9 f: J, t for(unsigned int j =0;j < faces.size(); j++)
1 [# L& X3 D: ] x {) H, O* Y3 r1 l" C, i4 d/ c' o- i
totalfaces.push_back(faces[j]);# @1 B5 W+ q7 a+ i9 D3 Z
}8 X. i" ]% L$ `# K* L
for(unsigned int j =0;j < Features.size(); j++)
# \& Z1 W9 U/ Y/ B3 a8 B7 o9 W {
/ f( Z" a* E. g1 u! I& j2 J. c totalFeature.push_back(Features[j]);
" U1 \+ p4 D& }7 O# ]! d }
8 J( t& z: @: l9 l2 h: P $ O. n p* M' F: u
}
, A4 _4 h3 w, D' Y1 T ss <<"edges count = " << totalEdges.size()<< "\n";
4 z% y2 Z5 I7 U* \ for(unsigned int j =0;j < totalEdges.size(); j++) X5 P0 W9 ~+ s8 ^8 p. g
{ % ]3 i w7 j l
totalEdges[j]->GetVertices(&vertex1,&vertex2);
- O$ L3 j( Z( N% V6 C7 P% m ss <<"edges tag: " << totalEdges[j]->GetBody()->GetTag()<<"\t";
' V$ k2 n& ~6 S. k ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";$ c' n/ e# m5 M2 B" n; N! |
ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n";7 x+ v. A- z5 _! Z ]
}0 j8 [. C+ H1 n8 t+ Q; R8 W& a
ss <<"faces count = " << totalfaces.size()<< "\n";: o2 |* j# T3 `$ N& S
for(unsigned int j =0;j < totalfaces.size(); j++), e8 d) h9 B9 Y5 b
{ " R/ ?# ?0 _; F0 N: T
ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t"; m% p: Z9 L& \4 m X
ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";
; l E" l; q( O9 Q: q# L3 t ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";
% g7 @5 m5 ]( I* U4 F0 a: F }$ `9 c" g" {" x4 z' b5 E& N
ss <<"Features count = " << totalFeature.size()<< "\n";: o+ K( S1 w3 C
for(unsigned int j =0;j < totalFeature.size(); j++)
7 ^; O& ~: ?! m7 s8 O8 ~ { $ E" i/ ?1 s3 [! s2 b$ i" z
ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";
6 G/ S2 y/ M4 L ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";- D/ H( x8 G+ X' @
ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";
" G7 D+ }- s L' j6 R; j* e }
% ~& G) [) A6 ?3 u: R) h, }6 r theSession->ListingWindow()->WriteLine(ss.str());+ w5 ]+ j: L9 o( w) _
i2 i# T t4 Q5 W- t
1 G, ]' `7 b' A; Q" b5 |查询结果如下:
! M9 V5 f& ]3 i# l, d% q% r( X3 n1 q. Y- y8 k
( F L& ?- c5 M9 `% ?
Get information from all bodies
( D V# ]9 [, a' s$ `! c0 H0 x9 dCYLINDERBodies count = 7
: l1 X4 {' U7 S4 redges count = 22, [ U4 Y" _4 A: d3 i& X) m
edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100)3 m( J8 i7 m: q* y
edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0)
1 D6 o& t+ O. U0 @( \* ledges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)+ Q0 L. }: p! z. E
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0)1 o$ P0 G5 E) c, {, Q
edges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100)- t7 m9 V) U$ u
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)
! W' P# ^5 A5 @9 D& gedges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100)
5 z; W+ }4 ?, E# x* Q! i6 W7 sedges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100), u8 T; _# P7 P& s1 w
edges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100)
^1 a7 g; K1 C$ z/ d' d- u& ~edges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100)
$ b4 x* X9 V5 G$ Vedges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100)
/ b0 c4 J) i9 Z' s) I' yedges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0)
& u- _& D* a: u9 ? T' B! K/ K* nedges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100)
& M8 q, M. H* B0 L7 a; K, [+ s, Qedges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)
. ^5 G3 K$ N& R7 ~" Eedges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)
- E+ ?% _( x* t, H) vedges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
1 X" i6 J R. N1 gedges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)+ J5 o$ b9 h9 j/ {! t% P' R$ H
edges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)
. U9 k( U- E9 d3 U; ledges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)
: Y# v4 p% H) n/ Fedges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500)7 I$ g. R9 j, d5 R# k/ ~2 m/ j
edges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200)' j7 y/ ]+ \6 W6 ]0 j
edges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)
. d# A& G* ?0 x! U& kfaces count = 22
8 z& \% n5 {. `Face tag: 41407 Face Type: 4 Face Name: 3 W' P9 X. o& k! T+ \; b8 Y$ q
Face tag: 41398 Face Type: 1 Face Name:
/ W& ~1 C3 R! v2 F" B3 j5 X1 H" ^Face tag: 41376 Face Type: 1 Face Name: 7 G: ^; F1 p) b4 Z) P7 C9 V2 b
Face tag: 41391 Face Type: 1 Face Name:
' q6 y, ]4 y/ N6 T6 Y1 YFace tag: 41380 Face Type: 1 Face Name:
; s+ @3 ^ C. z3 U9 z. d: X0 @( CFace tag: 41396 Face Type: 1 Face Name: ; c9 t2 c8 X l/ a% M2 s
Face tag: 41397 Face Type: 1 Face Name: 4 {* X4 y+ o: K: j( m" v! H
Face tag: 40995 Face Type: 2 Face Name: @2 n; m3 x+ Q* }* q4 U( H( m) J
Face tag: 40965 Face Type: 1 Face Name:
8 Y$ \% R) q+ h6 CFace tag: 40997 Face Type: 1 Face Name: y1 x9 W8 x1 p" z
Face tag: 41351 Face Type: 1 Face Name:
( e3 s- a% n' R& z1 QFace tag: 41352 Face Type: 1 Face Name: % ?# ~6 W' E, Q: l' a
Face tag: 41353 Face Type: 2 Face Name: " u& P" _$ d1 m
Face tag: 38479 Face Type: 1 Face Name:
9 ` H% q( q4 C8 m, w G1 wFace tag: 38480 Face Type: 1 Face Name:
, R' ]6 F4 v/ a1 O. M% b$ n8 sFace tag: 38481 Face Type: 2 Face Name: 7 y, K* P) b: {$ J
Face tag: 41207 Face Type: 1 Face Name: : d- e1 @4 y1 d# O
Face tag: 41203 Face Type: 1 Face Name:
8 o( c2 B' ?1 x2 d+ a* }Face tag: 41158 Face Type: 2 Face Name: 6 ^% ?- j B! Q2 b$ u
Face tag: 40987 Face Type: 2 Face Name:
, f9 i! o8 S9 X7 K R" zFace tag: 41010 Face Type: 1 Face Name:
) ~5 N% @, b; {) F" W8 UFace tag: 41001 Face Type: 1 Face Name: # ]7 h$ _" @5 ]- S5 z2 }
Features count = 7
- p9 y4 G8 O7 }5 f5 xfeatures tag : 41280 features Type: SPHERE features Name: Sphere(17)
5 }% t5 J1 {# }; d# ofeatures tag : 41281 features Type: BLOCK features Name: Block(18)6 E1 q5 _& e s/ Z) E2 A
features tag : 41307 features Type: CYLINDER features Name: Cylinder(19)
8 S) [% o! h( X$ cfeatures tag : 41314 features Type: CYLINDER features Name: Cylinder(20)! X; ?* K. h" \) _
features tag : 41322 features Type: CYLINDER features Name: Cylinder(21)0 ]1 G2 E8 q1 Q' k; I/ ^
features tag : 41330 features Type: CYLINDER features Name: Cylinder(22)
2 A/ O% J( W5 K! F/ s5 E jfeatures tag : 41338 features Type: CYLINDER features Name: Cylinder(23)
7 [. ^# i% r" R- x9 B5 Z2 ~, c$ K t8 B
|
|