|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息* `7 }* u# Q7 M! A0 q* U' u
3 O/ x+ O+ s0 H
. m. ?+ g5 q, o9 D+ t5 v } theSession->ListingWindow()->Open();( s! i8 f, \% o: g6 y: ]
theSession->ListingWindow()->WriteLine("Get information from all bodies\n");( ]6 Y g( G6 \% W I
std::vector<Body *> bodies;
6 R, s+ g# }+ u8 T BodyCollection *bodyColl = workPart->Bodies();
/ u. \ v2 D! M6 P9 r2 h* c for(it = bodyColl->begin();it!=bodyColl->end();++it)8 y! f5 T7 H- z4 f* a# C
{
2 v: x# L# r/ w$ O. L6 {5 e bodies.push_back(*it);# r) C! ~7 q* c% c" o5 `% ^
}
# @4 ^0 W- A" L3 U7 D& Q, z9 C ss <<"Bodies count = " << bodies.size()<< "\n";- ?. r" ?1 Q$ U% l# P
std::vector <Edge *> edges;
, R" g8 j0 [% A4 d) n* x- a# K4 t std::vector <Edge *> totalEdges;
$ n$ Q" W/ C/ M" b- t n: B std::vector <Face *> faces;5 x( E4 L+ b8 y% \# h
std::vector <Face *> totalfaces;; }: {2 Z/ s* ^( ^$ |, ^/ P
std::vector <Features::Feature *> Features;
! k; S8 u4 K3 L" E std::vector <Features::Feature *> totalFeature;* D3 {. O* d1 r9 v5 U
Point3d vertex1,vertex2;
5 y/ a6 A' N- n- Z0 Y for (unsigned int i = 0; i< bodies.size();++i)
. Q' |" g r6 C; _; J( J {
0 f% M5 \1 Q+ } edges = bodies->GetEdges();
% q( E% @4 s; }6 r9 m- v faces = bodies->GetFaces();; n+ p, ]# P' _* ?9 W2 Y4 a: i7 x
Features = bodies->GetFeatures();
; v; [5 F3 X; w" a for(unsigned int j =0;j < edges.size(); j++)
# t6 O; Z; j l3 ^# H {! R6 H* K8 D9 c7 l' k/ I/ b* B' o
totalEdges.push_back(edges[j]);
7 R: C# I; Y& {! S( _ }
5 \3 T0 y+ J' `) z, t; a for(unsigned int j =0;j < faces.size(); j++)( o- ?/ v" [; Y+ i
{$ \, |* {- a/ [1 o4 `
totalfaces.push_back(faces[j]);* h5 u1 P0 n% y2 o0 v
}
/ D9 t5 ~4 [3 M for(unsigned int j =0;j < Features.size(); j++)/ x( W( ^/ l$ F$ U
{+ y @5 k' @4 A& i7 Y
totalFeature.push_back(Features[j]);: c5 i% f2 C! o, O2 D+ s H
}
* ]# I! h/ C6 O- n & e! k; g- X( t# T. B
}
, J: d! s+ d& j! b ss <<"edges count = " << totalEdges.size()<< "\n";
. Y* @! s; W4 u% ^ for(unsigned int j =0;j < totalEdges.size(); j++)( b2 Z. _1 [# W9 K* P. D, A8 G! D
{ & X4 U4 e& C# |) h* i
totalEdges[j]->GetVertices(&vertex1,&vertex2);9 g* z$ z0 G+ g8 m& {9 I/ k
ss <<"edges tag: " << totalEdges[j]->GetBody()->GetTag()<<"\t";8 d; X8 D! r1 I. D
ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";
. ~7 B' c) ]4 A& e ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n"; r; X$ B, M% ~& Z
}
' b; a1 V, C0 O, j' J: Y+ L, { ss <<"faces count = " << totalfaces.size()<< "\n";
, [! A$ {2 @1 ^# n$ L' z4 M for(unsigned int j =0;j < totalfaces.size(); j++)
2 Y# }7 ~9 S6 y2 j) i {
8 c& e( c$ Y) a1 v8 a! W0 W) f ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t";3 S+ K8 j. k% E" }
ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";& \* O8 h5 X" B. Y) d
ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";/ y" i ^+ e$ W8 f: y
}0 D$ P5 b* z- t J; f
ss <<"Features count = " << totalFeature.size()<< "\n";
; \1 W' _$ S- I' n# M7 H4 ] for(unsigned int j =0;j < totalFeature.size(); j++)
- Q: I; r; A% F! L {
: z9 a8 k9 Q+ S ~7 V( t' E ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";
/ g( a8 T- ~* y; T$ @4 n" t9 x' O ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";
% r# l- v$ V6 J% P; W; f# C ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";7 x' ~ F' b' }" E+ N
}
1 m. y! D2 i: W7 P, P% b/ M theSession->ListingWindow()->WriteLine(ss.str());+ |2 v7 d( B$ j, H; t5 S+ D
9 a* ^1 |* D, [8 T( |
5 L2 Y6 N# D+ R" v2 _查询结果如下:
! {4 d S. V. P/ W; k+ R8 Q% c+ E4 B* d% C
9 ?/ t! H, m/ S4 O- bGet information from all bodies, [6 S$ L' Q7 P* w$ N" t3 p
CYLINDERBodies count = 7
1 v! H6 U# q+ {0 P7 hedges count = 22( V; j" o. _* f$ Q/ H
edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100)
/ u) c" O$ V g9 M1 y w% Iedges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0)
; x2 Q/ B/ R- a0 X8 Eedges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)
5 n! A! |! @- C4 R: Y/ Redges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0)
3 v( [* J! U+ [# H! Hedges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100)0 [4 {9 `/ \4 I) m- }+ j2 n9 e
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)& g' G0 n2 S/ R* Z: e/ H/ o0 z/ g1 X8 S
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100)
3 X* {# M% ^/ e5 z$ ^edges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100)- B9 R# s( V$ f
edges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100)0 [4 g7 z/ Z* K! n$ W ]' O6 u
edges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100)
% i* v4 e& e8 }$ dedges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100)+ _7 L L) G' R. g2 \& c
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0); ~) ^" A6 Y- j1 G
edges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100)
5 v% A3 Y0 d. z$ v' @edges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)4 [2 A4 G# M. L' O# @7 M4 n
edges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)
( p7 b% b8 z. @edges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
' p- M8 x: L) K Vedges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
$ U8 P/ \7 m2 f6 p# U ^, E7 Cedges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)6 A4 s* O/ ^* U" d
edges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)
2 V0 S3 A" G5 { d6 x7 V: ]edges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500)
0 Q, E9 M: |2 A4 F% x' O, ?edges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200)
% s2 Y, {; l0 Tedges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)
% ]/ a4 g2 T1 ^! ~! Vfaces count = 228 O$ Z3 H3 Y. Z1 s& L- N
Face tag: 41407 Face Type: 4 Face Name: 3 a* U' q+ O. Z a5 k
Face tag: 41398 Face Type: 1 Face Name:
0 J( V5 V+ X3 @% p, G& gFace tag: 41376 Face Type: 1 Face Name: * T" {# g& T; Q5 c) H8 _8 R
Face tag: 41391 Face Type: 1 Face Name:
. ~9 k, v2 Z7 M$ @0 H% t( ]2 QFace tag: 41380 Face Type: 1 Face Name: 2 [6 O5 |; H1 w8 e4 v" b+ L/ ^. {7 j
Face tag: 41396 Face Type: 1 Face Name:
/ M0 I9 `# [7 \9 }" j ?Face tag: 41397 Face Type: 1 Face Name: / k. `8 J* p6 _! J, H1 b: h' H
Face tag: 40995 Face Type: 2 Face Name: - `3 P1 ~6 o0 E" `
Face tag: 40965 Face Type: 1 Face Name:
9 Z- w9 D9 _* \Face tag: 40997 Face Type: 1 Face Name:
( z0 G! y$ P- k/ c# q' C% m) ?7 VFace tag: 41351 Face Type: 1 Face Name: 1 k. U$ E' p7 h, F; w U; f
Face tag: 41352 Face Type: 1 Face Name: , C+ m4 g8 D& N
Face tag: 41353 Face Type: 2 Face Name: " d1 V4 a" K; e. Y2 G# U
Face tag: 38479 Face Type: 1 Face Name:
. e& |& s1 A6 s: IFace tag: 38480 Face Type: 1 Face Name: 5 K) D, T1 N$ [1 y. D q8 B% J2 W- D
Face tag: 38481 Face Type: 2 Face Name:
, a7 I$ D! ]1 d! bFace tag: 41207 Face Type: 1 Face Name:
0 i8 l5 l( e& w! R& y! z qFace tag: 41203 Face Type: 1 Face Name: % G, a/ [! U% `9 t8 Y: J0 T& X2 v
Face tag: 41158 Face Type: 2 Face Name:
! R# J. K, S2 w7 TFace tag: 40987 Face Type: 2 Face Name: ! U' E9 {9 Y6 H/ B; i8 D
Face tag: 41010 Face Type: 1 Face Name:
/ @& \: v1 n$ r/ D- yFace tag: 41001 Face Type: 1 Face Name:
- Z( T7 f$ p, Q Z- s$ j- HFeatures count = 78 u8 `) f' o( r% |0 ^$ J* m; a
features tag : 41280 features Type: SPHERE features Name: Sphere(17)
" G& D, K2 Z1 q& \5 ufeatures tag : 41281 features Type: BLOCK features Name: Block(18)
+ i' e0 `3 T( `3 S- Zfeatures tag : 41307 features Type: CYLINDER features Name: Cylinder(19)
8 |4 A0 j& Y Bfeatures tag : 41314 features Type: CYLINDER features Name: Cylinder(20)# c, w3 M, }; G& b- W3 u; S" C
features tag : 41322 features Type: CYLINDER features Name: Cylinder(21)% s+ s4 M: j' R. m7 a/ f
features tag : 41330 features Type: CYLINDER features Name: Cylinder(22)
0 q/ H, ^7 U3 F- K/ bfeatures tag : 41338 features Type: CYLINDER features Name: Cylinder(23)" O0 b c0 u8 Y
' y2 H g2 j" x$ [1 j3 K9 v& Z! K: e
|
|