|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息
. @- j3 {3 w# b+ {* d" ]0 v& y ( b* `2 T4 i1 J( Z- B( ~* a
" j& p8 j) N1 N! F8 N1 U4 c8 K. k theSession->ListingWindow()->Open();
4 W, S9 Y! @7 K8 n- w theSession->ListingWindow()->WriteLine("Get information from all bodies\n");
5 j4 g" M6 h# ^+ G5 F: X std::vector<Body *> bodies;
3 S1 v* [7 V- S D# e9 g BodyCollection *bodyColl = workPart->Bodies();* i, X* t& j3 V3 h4 D2 c; `. B
for(it = bodyColl->begin();it!=bodyColl->end();++it)
4 Y4 p& [, n+ @$ \& c! O. ]) a k {4 D: f6 [$ l& M+ j# O
bodies.push_back(*it);
, b' N, C5 |6 t }
" D9 }9 d0 x$ I! W ss <<"Bodies count = " << bodies.size()<< "\n";+ x ?' c8 N- O9 @1 i, V Y4 n
std::vector <Edge *> edges;. e" @+ {7 H1 l* `' x. t
std::vector <Edge *> totalEdges;
. b! s7 X# G1 A6 i- z. K std::vector <Face *> faces;
7 d% d) Q x& C& h8 S" [% k std::vector <Face *> totalfaces;+ K# G0 u# X# P# C& q
std::vector <Features::Feature *> Features;9 L" C! g) T0 H' {7 V6 Y$ E
std::vector <Features::Feature *> totalFeature;& F% I9 P/ M6 Q" i: g, T. \
Point3d vertex1,vertex2;! `" {# l& q3 U- x6 ]/ ~( |: v4 n
for (unsigned int i = 0; i< bodies.size();++i)
$ t+ Z8 S2 I* d( n; r {
( x8 A" w3 F/ n edges = bodies->GetEdges();4 G* i* O$ |* t6 L4 H; H
faces = bodies->GetFaces();
* G \* U. L, J, u n Features = bodies->GetFeatures();
' ]# J+ [) Q* W; k7 } for(unsigned int j =0;j < edges.size(); j++)
5 j, r1 y* |6 {. m6 \! A {
- x3 F* O) } F) | totalEdges.push_back(edges[j]);) M1 b! W$ X0 c
}7 ^7 Y: H5 \6 f' _8 e
for(unsigned int j =0;j < faces.size(); j++)
' v+ I* X9 X4 B {
2 D- [+ k9 H! ?: ]) S totalfaces.push_back(faces[j]);4 H$ y5 B, j6 B' ~' q4 P
}$ e( f9 `9 q# A, ~' i2 y- x3 z6 @$ }
for(unsigned int j =0;j < Features.size(); j++)+ n# X1 U% p! e) r' e+ y+ M
{
7 E) ^6 |0 `: a1 `+ z3 {% x totalFeature.push_back(Features[j]);( W# h/ K: N% w; a1 P. M
}9 {- S. C0 j( M- k/ Z$ s6 d7 {5 d
% W/ Y: A3 g/ b9 F& V } n* g3 g9 z& x+ p! p* g9 H+ ]/ Z
ss <<"edges count = " << totalEdges.size()<< "\n";6 f* U/ R3 j1 X$ ?. }
for(unsigned int j =0;j < totalEdges.size(); j++)
+ C! v% m" u) J4 L {
1 u. R) {, k, F totalEdges[j]->GetVertices(&vertex1,&vertex2);9 v/ w; n1 L1 e# y5 c1 L$ V% m
ss <<"edges tag: " << totalEdges[j]->GetBody()->GetTag()<<"\t";* O+ _. E7 g: e! C- a
ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";, t) E g, }- @
ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n";
n# h2 z+ F( c" t& M# i }, I: C0 u) T7 M0 P/ V, I* D* G; }( R
ss <<"faces count = " << totalfaces.size()<< "\n";
* I7 {7 y+ p7 b2 v6 s9 x for(unsigned int j =0;j < totalfaces.size(); j++)& S3 X% j$ G- m& d M/ `* {+ e
{
+ m4 M7 P) v* A7 v, V ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t";# E. I; H- B# H. i7 x$ X8 v
ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";1 w5 m8 x) s% J2 t( e) d6 S
ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";* R8 m0 T% n' u4 E. m4 _
}, A& h" c2 y/ F6 p3 c: _# a( x/ l# h
ss <<"Features count = " << totalFeature.size()<< "\n";3 \# F8 ~3 s8 y6 K |
for(unsigned int j =0;j < totalFeature.size(); j++)9 e+ @, O% m( N& B& u& S, _
{ : b* }0 ?: Q" \6 ?
ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";+ N; S- q |$ J) H' n( M) W. Z v
ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";* a& Q7 N! E, N% o9 r& Z; n2 T+ y, `
ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";
+ ~) o: B* N# j: u6 ]" Y }! D# a x9 W/ c* w& k9 ^
theSession->ListingWindow()->WriteLine(ss.str());
' j' P8 {2 s+ ~; @" D; G
# S' Q3 f" [& p, z) {! f8 g$ t) j/ H h5 g6 L
查询结果如下:
/ R: C6 N6 V9 \
* `3 A6 H w, j4 H2 J: ^/ e; {+ O$ y }( J( ~/ Z5 b: J* Q
Get information from all bodies
! I9 U' p6 z8 L3 z2 ?5 ^, r( j2 r5 KCYLINDERBodies count = 7
+ @6 F" Y* U- c) ~+ }edges count = 22
1 l0 U$ B/ ?, T# a1 G) Hedges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100)
* Q1 N# c5 ` v# A9 Vedges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0)/ A- s% u: b; _! K" ~5 p6 s+ l
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)
& h ?! x. Z. H7 Y; M, S4 R- L1 iedges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0)) e+ d- P7 P* V5 M! Y
edges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100)3 _8 `; R9 K& m: o
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)5 ~1 @' J G% O% t9 r! U; n
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100)( l# W# ~! [* V2 k# x
edges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100)& i# G9 a) R# ~/ u; g7 G) k
edges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100)- z! j/ X# g- g
edges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100)
5 l* I7 S2 A# D6 b6 b d) Y% t, S2 cedges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100)" q6 l7 ^ Y* `* A' T: e
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0)9 r+ o: Q+ {; x$ b U# U
edges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100)5 a$ {' w3 B: X4 m4 b
edges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)
+ K1 n( a, R$ tedges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)
) s% I- P+ d2 P' Zedges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)8 e( L7 e* E9 Q/ [1 Z
edges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
0 C0 C0 V( ^2 n: p) xedges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)6 d @ o4 n. F' ~. f
edges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)
; F& ]8 U# Q! x' V7 ~: |edges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500)
* d( K% `- c' A% }edges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200). v$ M, D) C8 j# G. s* t
edges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)
$ Z+ @0 @: b. a. Z: Lfaces count = 22) S- [! m) K; s$ b0 y
Face tag: 41407 Face Type: 4 Face Name: " T2 o* o4 l. P% F% `: y; a. A# }
Face tag: 41398 Face Type: 1 Face Name:
( o9 |5 |" g# ^& YFace tag: 41376 Face Type: 1 Face Name: ( N' T2 | A2 r3 c+ D
Face tag: 41391 Face Type: 1 Face Name:
7 g5 g2 o7 x' ]5 _Face tag: 41380 Face Type: 1 Face Name:
, q; {& Q. n$ H& E) N* nFace tag: 41396 Face Type: 1 Face Name: & R* ]! x/ c' {' I" D
Face tag: 41397 Face Type: 1 Face Name: 7 {" `- `& D3 b2 e' K, j2 }* Y' e3 b
Face tag: 40995 Face Type: 2 Face Name: ) b, l( L( ]' Q* e2 a4 W# O
Face tag: 40965 Face Type: 1 Face Name: 0 h2 M5 N* w5 U+ \: M) D/ n
Face tag: 40997 Face Type: 1 Face Name: A+ ~4 l9 |- h2 \) s6 B2 z
Face tag: 41351 Face Type: 1 Face Name: `& s& z: n5 n% {3 H, i8 v
Face tag: 41352 Face Type: 1 Face Name: 5 ]4 A0 i& i& T$ K4 {6 I. q
Face tag: 41353 Face Type: 2 Face Name:
" u) e5 Z- q! X$ zFace tag: 38479 Face Type: 1 Face Name: + t. ^0 V; ]& E7 Q
Face tag: 38480 Face Type: 1 Face Name:
" k1 S, h1 R8 u, d FFace tag: 38481 Face Type: 2 Face Name:
/ e; r: M! k4 xFace tag: 41207 Face Type: 1 Face Name: 8 J, f3 ?( V' i9 \6 i L1 @/ P S
Face tag: 41203 Face Type: 1 Face Name:
/ V; J T& L9 lFace tag: 41158 Face Type: 2 Face Name:
& L5 O7 W3 @" G# Q( bFace tag: 40987 Face Type: 2 Face Name: ' `" J6 \2 Q( n c
Face tag: 41010 Face Type: 1 Face Name: ) T: h, a' w, S' a' y/ X
Face tag: 41001 Face Type: 1 Face Name:
9 q- ?* {0 F6 @ A7 i6 i& R4 NFeatures count = 7/ C) A4 R/ T# e. L, Q
features tag : 41280 features Type: SPHERE features Name: Sphere(17)2 P q% q7 `. b
features tag : 41281 features Type: BLOCK features Name: Block(18)1 I: h h" n' k7 v; c" q
features tag : 41307 features Type: CYLINDER features Name: Cylinder(19)1 [0 b2 s) R4 s8 F" z: V
features tag : 41314 features Type: CYLINDER features Name: Cylinder(20)
; v: N8 S. m, S' k! wfeatures tag : 41322 features Type: CYLINDER features Name: Cylinder(21)6 I0 f4 c2 M& Y" e
features tag : 41330 features Type: CYLINDER features Name: Cylinder(22)
8 m" r( g/ g3 x8 ?0 tfeatures tag : 41338 features Type: CYLINDER features Name: Cylinder(23)# d; V0 G8 H3 N) H8 c. g
& v6 b. \9 _* W( l! f
|
|