|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息
- q! S5 w! X9 I! g* m! ` 7 S% b/ [! d) c2 ~3 O2 n
! p; z, k9 T' o* k0 g; ~
theSession->ListingWindow()->Open();6 {' M- x( T% n) P6 B* {
theSession->ListingWindow()->WriteLine("Get information from all bodies\n");' |: m2 X, Z5 z2 S9 f* k& o
std::vector<Body *> bodies;
3 l, p% i6 ^& w0 y" k* }9 ~, T BodyCollection *bodyColl = workPart->Bodies();
$ G7 i7 u) C9 I/ b# R3 V for(it = bodyColl->begin();it!=bodyColl->end();++it)" O* ]6 G# g( ?; n3 _
{
9 h6 r+ a! `7 d0 D$ r; [6 f w bodies.push_back(*it);
2 n2 L4 P5 f G" p }$ j) G" k: Q( z; @* w
ss <<"Bodies count = " << bodies.size()<< "\n";4 ~' j0 b+ F% H& `6 H! r- U
std::vector <Edge *> edges;
$ g" a7 a9 {3 ]) B" X+ ^8 I, k% m std::vector <Edge *> totalEdges;4 r- m, |5 ~( c) S4 m
std::vector <Face *> faces;
# c! y8 w4 a- U, A6 G std::vector <Face *> totalfaces;' d5 H" {) C- q$ y! A; q [5 H7 _
std::vector <Features::Feature *> Features;
7 c4 G' c' f1 g3 p) }2 i std::vector <Features::Feature *> totalFeature;$ N: |* I7 I/ J
Point3d vertex1,vertex2;
4 d; N2 q; x/ b7 r: K: R6 e+ e for (unsigned int i = 0; i< bodies.size();++i): t2 }$ \ u! J
{+ N3 |; D6 X; L
edges = bodies->GetEdges();
- ]( A* I7 f4 I$ j4 L; v) K faces = bodies->GetFaces();
$ k, e& t4 W& d2 r Features = bodies->GetFeatures();7 U- _# R' e# ]! ^5 d' `6 k
for(unsigned int j =0;j < edges.size(); j++)7 w/ n4 o3 g& j, ?$ y
{
% m' V( y9 T @- M! b totalEdges.push_back(edges[j]);9 j2 B0 Q/ m: r, m" V
}
/ A9 A( m( S) Q2 b for(unsigned int j =0;j < faces.size(); j++)# G8 q# u9 e4 s' B7 r6 y* C/ c
{
! N: G' R* P: A9 h0 S, O totalfaces.push_back(faces[j]);
: g# Y2 s, E) n. p7 m }
8 j2 D' X% t1 b+ Q for(unsigned int j =0;j < Features.size(); j++)
9 S, w/ c+ a1 M8 C {
+ e1 e" p. ]0 m5 D# {: g! E totalFeature.push_back(Features[j]);
: e, l1 M( \$ m* X# S3 ?. r }
( w m: |" t3 ?8 T: I3 C4 W
% C7 O/ a& f; Q$ {. X5 d3 a }
+ s- i& q3 \" d# o- J ss <<"edges count = " << totalEdges.size()<< "\n";
* c3 T2 O) C' K* Q9 l for(unsigned int j =0;j < totalEdges.size(); j++)% A. `* W! ~: W0 M3 B# D) {
{
4 R3 x3 b* C8 t7 e totalEdges[j]->GetVertices(&vertex1,&vertex2);
( b/ m8 m+ p. @ S- @6 n# B ss <<"edges tag: " << totalEdges[j]->GetBody()->GetTag()<<"\t";
6 c0 c' U8 H) P' m ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";, j! x9 ~: I9 m& F# `- m
ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n";0 G$ `# q. Z# u' N% c+ x/ R# V: M( c$ A
}3 X9 H: v( b/ r2 b, s7 m5 x9 t
ss <<"faces count = " << totalfaces.size()<< "\n"; l/ e$ b) \- F, W$ `& A
for(unsigned int j =0;j < totalfaces.size(); j++); ]1 }; n* v% e8 }+ f
{ 9 v3 q* V1 v% g2 k& p b
ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t";! {7 D f0 O2 s
ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";5 y2 D [1 N$ G' O
ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";
; A8 n% l% o' I }
9 G: r2 E m. U0 B+ Y! a# x' a ss <<"Features count = " << totalFeature.size()<< "\n";& w* }. H' s( d) @+ j
for(unsigned int j =0;j < totalFeature.size(); j++)& n+ }5 N6 S; x
{
o* i$ B9 W+ \" |0 c) N ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";: |, l: H) j$ M/ n$ z
ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";
# R0 `4 {0 B- l; G0 F; h5 L* H ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";" Z# D- S( ?$ x% a5 b4 l/ {
}1 G0 S& ^) D/ `
theSession->ListingWindow()->WriteLine(ss.str());5 f% e$ O8 {7 O C% z3 ?$ H( B" s/ h
7 E8 l: z+ Y' R
3 \. @) k" |9 i/ d8 K0 ^
查询结果如下:
7 K+ R5 K, [4 k& k. a( P8 Z& o) s4 G& A; F2 D
5 x& o. O$ v: zGet information from all bodies8 \0 z" O$ n- ~, c4 J$ O
CYLINDERBodies count = 7
; z# D( N/ g( K' b* ]edges count = 22
. ~5 S5 u. d! Eedges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100)0 ^1 [( j. b5 C$ W# S
edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0)# X3 l7 W! ?$ T2 s' g. |) k
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)
5 w, c% F0 I. Xedges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0)
3 N: X4 P) i" v( F, `edges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100). D* o W- a) p1 K. q5 j
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)! j8 F; r4 R% w1 w1 J U: s
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100)
4 t- j6 G W/ sedges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100)+ _* {3 \' F: R/ U0 m3 C9 y
edges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100)
# l5 _4 K9 _; `; e( W6 Sedges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100)
. |& `% l( A+ X7 q" _edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100)
8 d0 a! T3 W0 \: redges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0)+ N+ A( C" X! D7 }7 x
edges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100)
3 L3 k& T6 y( X/ s- P! kedges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)
8 }: Q7 K& d& u4 v$ c- v# Nedges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200), k8 s( u4 @. M3 F$ E
edges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
2 O ~& g5 n' K, K3 j$ `edges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)& }/ s! N/ f1 p& { B
edges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)8 N) E4 F6 a4 r' I# c/ ^% @, H
edges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)
. i O& a( I h" Y% @. Redges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500)
5 m' Q9 o6 c4 ^4 i c* H) ]1 Dedges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200)
( \ W5 k+ N7 }5 g8 o4 Nedges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)
* P- w9 h) c- ~( U* t+ T( `faces count = 22; Y4 D: u f1 Q
Face tag: 41407 Face Type: 4 Face Name:
7 @8 X5 P8 h; e; L/ wFace tag: 41398 Face Type: 1 Face Name:
: v! t' }* y2 U9 CFace tag: 41376 Face Type: 1 Face Name:
$ q9 W6 o2 I, X1 dFace tag: 41391 Face Type: 1 Face Name: / \0 `) v2 E; x Z% @
Face tag: 41380 Face Type: 1 Face Name:
/ X% f! q5 Y" N& v: P4 o* F) XFace tag: 41396 Face Type: 1 Face Name: . J- D- y& E( l
Face tag: 41397 Face Type: 1 Face Name:
0 {5 g, [/ r& L; H) S; [3 YFace tag: 40995 Face Type: 2 Face Name:
" C9 S. ~7 b$ ^. a H$ @1 t: ~Face tag: 40965 Face Type: 1 Face Name: / n$ `8 V- Z9 _6 b' R5 x6 h: C; {
Face tag: 40997 Face Type: 1 Face Name:
; @5 c8 K4 B2 n+ |1 E" DFace tag: 41351 Face Type: 1 Face Name: 3 M$ c& W9 O* j+ p3 d
Face tag: 41352 Face Type: 1 Face Name: $ P' d" s. Q& H b" a) A
Face tag: 41353 Face Type: 2 Face Name:
, C& y) Y: z% ]) AFace tag: 38479 Face Type: 1 Face Name: 0 u+ F! S$ F! D+ U
Face tag: 38480 Face Type: 1 Face Name:
+ B# W Z: u/ X. V$ h. xFace tag: 38481 Face Type: 2 Face Name:
6 p$ U0 B& w% {% q$ Z; B- K2 sFace tag: 41207 Face Type: 1 Face Name:
9 U+ V7 ?. I& x. eFace tag: 41203 Face Type: 1 Face Name:
& H! Y" v! v: o" W$ uFace tag: 41158 Face Type: 2 Face Name:
3 e/ n, d7 E+ b: A5 A7 ?1 OFace tag: 40987 Face Type: 2 Face Name:
9 h3 w+ }. {( AFace tag: 41010 Face Type: 1 Face Name:
' Y3 v9 E/ |" ^, A+ s' T" |5 }0 OFace tag: 41001 Face Type: 1 Face Name:
; }; i8 P/ b& k& W+ l' u2 G/ u& aFeatures count = 7
9 F; Z# v0 D# @7 H3 ffeatures tag : 41280 features Type: SPHERE features Name: Sphere(17)
/ C s9 s$ x& h" N* h5 s: Dfeatures tag : 41281 features Type: BLOCK features Name: Block(18)
% O+ a" K1 Q4 N1 M* Y& g, I8 ]/ D4 _features tag : 41307 features Type: CYLINDER features Name: Cylinder(19)2 L& m% L) n9 y# @" j
features tag : 41314 features Type: CYLINDER features Name: Cylinder(20)
4 w O2 W2 o. B9 ?8 W- b) A( ~7 Qfeatures tag : 41322 features Type: CYLINDER features Name: Cylinder(21)8 o% x! C6 M Y! O/ A
features tag : 41330 features Type: CYLINDER features Name: Cylinder(22). P0 y) U H. C( M7 Z5 [+ Z( r
features tag : 41338 features Type: CYLINDER features Name: Cylinder(23)+ S: q0 G# o1 ~! {' c( s
' k; F4 d! {7 X y D9 i, @
|
|