|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息
8 E8 n* x9 q& x1 |5 T / G- s4 o+ A: a r8 C7 C3 Q
1 ~$ N# J s2 ~; }9 g, w
theSession->ListingWindow()->Open();
9 |& _% b! j o( t theSession->ListingWindow()->WriteLine("Get information from all bodies\n"); T: f' [* i2 Q0 h
std::vector<Body *> bodies;1 G, I8 H8 P) B+ Y9 K
BodyCollection *bodyColl = workPart->Bodies();
; n4 E1 M, }) T for(it = bodyColl->begin();it!=bodyColl->end();++it)( z* j0 e: D, _. L) s
{* o' e& v) x) l( `4 d0 c
bodies.push_back(*it);
. r: ^! _* s$ u* k }
% {& Q P+ ~8 V ss <<"Bodies count = " << bodies.size()<< "\n";, d6 A. ]* ?1 c' s+ w5 `
std::vector <Edge *> edges;0 V* x+ |( A3 D K6 i
std::vector <Edge *> totalEdges;0 G3 ?! u( Y- Z a4 a" C/ b- }
std::vector <Face *> faces;: f# b4 b7 a7 [+ F* b& }$ V5 I s
std::vector <Face *> totalfaces;2 d' L: \& T& G1 l$ L p" T, Y, |
std::vector <Features::Feature *> Features;
& Z" Y8 ?4 ?! p8 {$ }. z std::vector <Features::Feature *> totalFeature;6 i; U" o/ X2 Z+ `4 f! L
Point3d vertex1,vertex2;
- {8 W3 ~" T5 c: d) v7 `; u# g for (unsigned int i = 0; i< bodies.size();++i)
$ D# s$ p; x% J C1 h {, E: p p. A, _
edges = bodies->GetEdges();5 [6 [8 o0 q. T' t/ D% Q
faces = bodies->GetFaces();
. e1 |& d3 \( ` e" o4 T$ v, A9 g Features = bodies->GetFeatures();
& E; S# |) R" x# x x+ u! O for(unsigned int j =0;j < edges.size(); j++)
4 r$ e" l( e# Q! b5 |8 E3 T {8 Q/ m/ L) q) D7 I
totalEdges.push_back(edges[j]);
+ v: e3 Z- y s }
5 S" W. m; \0 h: P8 B* d1 q! Y/ g for(unsigned int j =0;j < faces.size(); j++)1 j; s3 s/ f+ G B3 Q" @2 ?3 `+ A
{
, C# E3 b5 f! p+ y totalfaces.push_back(faces[j]);
1 N% C8 X; a3 B; q& R }
% y/ d( P8 s5 i for(unsigned int j =0;j < Features.size(); j++)
* @$ m8 g7 m& s" Q {
; F5 g7 X/ p0 e$ v8 d3 t7 { totalFeature.push_back(Features[j]);
5 c4 X3 S- l' r# L1 o$ ` }
7 P3 M6 X4 ]: ?; a
2 i! T7 |( X) P3 d }
# a1 O0 M0 M- i/ c$ e$ X1 | ss <<"edges count = " << totalEdges.size()<< "\n";
4 |9 E5 g- C% A4 K for(unsigned int j =0;j < totalEdges.size(); j++)5 k; w N+ q! J9 H1 i: ]% R& f& N
{ / L9 V- N: \0 T* o4 L
totalEdges[j]->GetVertices(&vertex1,&vertex2);
& x8 L$ Y- K H2 V+ a8 n6 L- L ss <<"edges tag: " << totalEdges[j]->GetBody()->GetTag()<<"\t";
/ N3 i$ e* C4 U5 r! g/ q, y ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";8 j! ]4 z7 [& ~ H+ u
ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n";
& P G M& z0 ~4 T9 e }2 N% N6 U+ Q7 f
ss <<"faces count = " << totalfaces.size()<< "\n";! a/ e1 H: K, o' G9 t( p
for(unsigned int j =0;j < totalfaces.size(); j++)6 ?/ D4 X) J! p9 _9 o- a
{
9 N; v- q% [# n" {3 Q ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t";1 ?" |2 v9 v3 M& t; L+ A1 i0 U
ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";) o% s, m+ M$ w/ d. {/ }$ _2 E0 ^
ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";
1 M. F7 T9 k1 a4 C8 ] }
2 ?1 O2 p" P7 y: e. q3 B9 z. a ss <<"Features count = " << totalFeature.size()<< "\n";
3 E5 e7 ]6 j" ?8 L for(unsigned int j =0;j < totalFeature.size(); j++)1 N# S' M6 F. k* B% }5 r" x& q
{ 1 ^% `0 n0 P, A& ~' }
ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";
2 h X: A: }$ K' q$ s ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";% O: q# f( v0 R
ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";5 G, a) E/ \ J3 ?8 T, q
}- D1 d: x0 d" Z# L
theSession->ListingWindow()->WriteLine(ss.str());
. E; Z# C2 V2 r$ ?+ |
7 [: K" Y4 E2 x7 q! j9 P' s7 q4 `! m0 [5 K' c
查询结果如下:$ u: b# k; T* D* X8 s
5 z( h5 u. Z* U
* o. r# Q6 _8 l% Y4 U# H) }' }Get information from all bodies
: L; f, ~* j4 x1 b5 W2 B1 U5 gCYLINDERBodies count = 7: o, S+ n& |: U2 Y
edges count = 22
+ {* p# ^1 P3 q1 D" y' _edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100)
/ j. k- {, }3 @' Fedges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0) y& W4 {2 m: ^1 c% N6 q
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)& a' G+ F2 |8 @( D n* c$ T9 e% |0 r
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0)
. Q4 D$ P. y6 P: v& k! vedges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100)
# H7 y/ E% B/ P5 `edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)9 ~" j6 I3 P7 v* \! s
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100)
% ]$ Y0 Y* m% a Y- X9 oedges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100)( S8 e) Q2 _; Q! j
edges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100)1 P. V3 t# j' E
edges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100)! @& x/ y9 Z' j' l) j3 c+ V
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100)
- P( p: i2 [2 a6 D& J# O6 N. {edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0)! E! m4 R2 E/ S
edges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100)
% L3 R/ S+ c/ H1 e7 G/ Q% J' W: jedges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)" D5 u" _% {7 ]) R9 D$ [
edges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)3 t! v: R9 c2 `5 ~8 q
edges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)8 d$ M4 z) Z/ M) @) Q
edges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
/ _7 T8 u3 b6 h; Uedges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)5 W- }2 n6 a5 Q! N
edges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)
; m4 X" n# V/ n/ z. {/ [6 ?3 v: F% \. iedges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500)
5 @9 t! a/ B' H9 M8 X- Gedges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200)9 c! g0 ^0 i/ ~- J2 |2 _* D- f9 F
edges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)
+ Y6 v! d. l2 N5 hfaces count = 22
y& V0 d G% f/ o4 nFace tag: 41407 Face Type: 4 Face Name: $ c) K2 O3 T% I* }" i" d
Face tag: 41398 Face Type: 1 Face Name:
. o- R$ @) _# \; MFace tag: 41376 Face Type: 1 Face Name:
/ p! E2 y4 @, e5 YFace tag: 41391 Face Type: 1 Face Name: 4 d& Z" _- U- w/ c
Face tag: 41380 Face Type: 1 Face Name: ( K/ A) Q% s2 F: w
Face tag: 41396 Face Type: 1 Face Name:
& Q5 c( f1 }: SFace tag: 41397 Face Type: 1 Face Name: ! I6 U) {* x0 u+ r
Face tag: 40995 Face Type: 2 Face Name: 1 n6 H. m' v" A; E) B
Face tag: 40965 Face Type: 1 Face Name:
1 W) J1 a _4 Z# ]& _Face tag: 40997 Face Type: 1 Face Name:
2 \8 |* z- ]( _# tFace tag: 41351 Face Type: 1 Face Name:
7 `- w( A- Y# l2 e: PFace tag: 41352 Face Type: 1 Face Name:
+ x& I; B) h' h8 d @8 o; o- n' FFace tag: 41353 Face Type: 2 Face Name:
! H8 r- J) P# T* k: tFace tag: 38479 Face Type: 1 Face Name:
9 ?3 S! u+ C9 Y% g- jFace tag: 38480 Face Type: 1 Face Name:
: L! N, V A3 y$ F: WFace tag: 38481 Face Type: 2 Face Name:
$ o D4 {! D4 B) C/ z5 E( Z2 Y, Z) t9 bFace tag: 41207 Face Type: 1 Face Name: , i( q+ w, \) m/ s# W( V
Face tag: 41203 Face Type: 1 Face Name: 5 e @2 X( }, n0 r' C
Face tag: 41158 Face Type: 2 Face Name:
, q& K# w8 B, x$ w% h: M/ nFace tag: 40987 Face Type: 2 Face Name:
" W; r- @" F; IFace tag: 41010 Face Type: 1 Face Name: & Y2 z0 }. K1 c+ [
Face tag: 41001 Face Type: 1 Face Name:
q, S8 q7 U: k# @Features count = 7
- n+ v$ B5 f' a# {' S3 ]2 nfeatures tag : 41280 features Type: SPHERE features Name: Sphere(17)8 w& S4 l9 z# w$ z% n' S8 n8 U
features tag : 41281 features Type: BLOCK features Name: Block(18)
6 C- h9 w" A7 U& H% Z vfeatures tag : 41307 features Type: CYLINDER features Name: Cylinder(19)
+ r1 t7 H/ o* G# ]features tag : 41314 features Type: CYLINDER features Name: Cylinder(20)
$ S" @1 F" u2 D0 Mfeatures tag : 41322 features Type: CYLINDER features Name: Cylinder(21)
% J; H2 [. l, ~7 Dfeatures tag : 41330 features Type: CYLINDER features Name: Cylinder(22)
/ { R% D& o- T& i6 E1 zfeatures tag : 41338 features Type: CYLINDER features Name: Cylinder(23)9 m( d1 u/ }) [9 z, o
2 Q a4 z: e9 r |
|