|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息
+ ~" x+ h' I3 E( N ) ~+ v1 ] N6 R- m7 h
# Y% _& z% C$ J. W& |
theSession->ListingWindow()->Open();
3 A8 X* D- n$ |8 r8 N0 c0 m theSession->ListingWindow()->WriteLine("Get information from all bodies\n");
6 r, e4 K @5 b, ]1 r) C! a# ]6 n std::vector<Body *> bodies;
+ D7 ?+ D {& F2 b0 L: } BodyCollection *bodyColl = workPart->Bodies();5 E7 |* E' o# l$ k J9 _$ I
for(it = bodyColl->begin();it!=bodyColl->end();++it)& i% @, Q1 a/ z6 d
{& X$ ?& i/ e' |
bodies.push_back(*it);
0 l8 Z4 b# O: @( d% s! z( Y8 i }
3 J/ M7 @7 k7 Q9 `# D0 P% d: C ss <<"Bodies count = " << bodies.size()<< "\n";
+ W; ?/ I# d/ y9 a& ^" m std::vector <Edge *> edges;
) w* x$ W6 v2 |8 c$ X4 j) G' ?: W7 E+ Q std::vector <Edge *> totalEdges;8 g6 |& m; p }1 e! u; M! t1 e- |
std::vector <Face *> faces;
2 `8 d1 D' @8 e( P std::vector <Face *> totalfaces;) v+ p$ r7 k! n: X+ B
std::vector <Features::Feature *> Features;/ l0 `' |: X* V s
std::vector <Features::Feature *> totalFeature;5 a7 V% [1 _' A
Point3d vertex1,vertex2;
) F) u! b. B5 A" Y- _0 B! {( j% V$ F for (unsigned int i = 0; i< bodies.size();++i)
( K% @ J$ I8 R! a3 C6 v {
# x" B2 |' o3 s: T# ^) d# p0 F% | edges = bodies->GetEdges();% c! q; H5 S9 h" L
faces = bodies->GetFaces();
6 m; X7 ]' h! f# R5 x Features = bodies->GetFeatures();
1 A, [, i& E7 n: v for(unsigned int j =0;j < edges.size(); j++)8 R& P* p# T: k
{
0 }2 E$ `/ u/ T6 _+ V totalEdges.push_back(edges[j]);
3 Y; p2 \! p. V* a0 s }
5 Z$ }& |& s+ O for(unsigned int j =0;j < faces.size(); j++)! z$ T! O* \3 @& o
{/ i2 O1 N1 Z4 ^$ u, q0 o- f; K$ Z
totalfaces.push_back(faces[j]);* C! @: k' \# G4 l0 b
}# y6 J8 o9 \2 w
for(unsigned int j =0;j < Features.size(); j++)' o; B- J- H! c, V$ K' B
{/ _: h) `$ ^* _; |+ w" J% ^
totalFeature.push_back(Features[j]);1 y8 d- p& C- V) ]1 [& j
}$ Z6 w* b* b4 C; _
s0 ^8 F1 }9 ~0 c. x2 R
}
. d0 Z* Q' i o, M ss <<"edges count = " << totalEdges.size()<< "\n";
) J6 w$ V' [7 [( L/ z for(unsigned int j =0;j < totalEdges.size(); j++)
9 W6 M( n% A @2 o* M { ! y+ |9 h6 h1 ]& L& |9 E
totalEdges[j]->GetVertices(&vertex1,&vertex2);
. n5 l W: H" g4 s& p# _0 |' a ss <<"edges tag: " << totalEdges[j]->GetBody()->GetTag()<<"\t";/ P- X# v" S4 n( H N
ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";
4 w) W* K7 v, ?5 d8 a3 V ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n";
% ]& M8 t$ i* I }9 n( d( @) T- g+ o1 @/ q
ss <<"faces count = " << totalfaces.size()<< "\n";
8 G9 K. u0 Y4 X' H7 F; m for(unsigned int j =0;j < totalfaces.size(); j++)
3 I4 Y8 j. I1 d1 G7 v4 ` { - D. }% U' @& U. g; Z1 H1 n
ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t";- Z# w) f- C! O) j
ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";* E" M! W6 [! H# \
ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";; h+ e4 R: p6 q/ [$ G! p' X
}
, J7 _' _( G* X' o ss <<"Features count = " << totalFeature.size()<< "\n";
+ O* l. Y% B3 X' u$ a for(unsigned int j =0;j < totalFeature.size(); j++)
* @3 u' k$ s5 l. C C {
5 K8 P8 p( Q- r" l; d& I ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";
- l$ w1 x6 T) h* ^, I) G5 d$ n ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";
( Q9 x' P% d4 x% t6 {$ D) C, L ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";
1 F3 u1 b/ R5 [% G }
5 K D! S) S6 k* P theSession->ListingWindow()->WriteLine(ss.str());
( w" S7 n4 l/ D/ T( b9 r" a0 d7 u/ [1 s+ M1 k
5 t1 h; ~ t4 h, g! q$ [% N查询结果如下:
- F$ v. ]3 y. z7 e0 i/ u5 ~6 l$ T- \8 j0 E
5 B( L6 n5 [5 D8 fGet information from all bodies$ H* _# C8 Q$ s2 Y
CYLINDERBodies count = 7) @( A z- G* k$ b
edges count = 22
/ Y! e7 Z4 T/ E+ t) ~, W. Gedges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100)0 s+ J$ H) o! f6 a( d7 X
edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0). K; T( Y3 F7 _* E' N
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)
1 |( f; m. l, t2 D k7 w7 [edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0)
# t3 ^" d9 r8 v2 f* |. gedges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100)% |7 \7 n! \$ A4 R
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)
' Q% w. }2 P; kedges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100)
' T k: V* `' q3 N' I: s% medges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100)% P7 k9 F4 A5 f3 w0 N
edges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100)
' O8 `! o7 @0 z* sedges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100)
" o: {9 u) P' d1 _1 {: y2 ledges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100)2 f; A* W6 H" N$ x2 G
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0)% H6 q9 v# t3 |9 Y! A
edges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100)
; q9 S5 i; F& T$ J- O' vedges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)5 ?4 A! w! Q1 X$ C) J+ I* Y
edges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)& u$ R9 W7 v8 ~* L1 A
edges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)7 g9 R3 { N2 c% u+ p/ m) @
edges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)8 z2 h( \! W9 a6 B( @- `
edges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)
2 M! `% q x8 [& [edges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)9 E, _3 F1 C! H# x
edges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500)
8 r- ?$ S- D0 n: \0 N1 }/ eedges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200)' F8 x/ ~8 l4 S. w
edges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)
: n- q& ?2 k$ Hfaces count = 222 h+ d( q3 m, X# s4 y
Face tag: 41407 Face Type: 4 Face Name:
& i- ?% t+ T5 A& F, tFace tag: 41398 Face Type: 1 Face Name: ; G: L/ P# I. x0 `6 _. s* J
Face tag: 41376 Face Type: 1 Face Name:
& E7 [/ @8 h8 VFace tag: 41391 Face Type: 1 Face Name: + f/ {# W4 N: W5 Q
Face tag: 41380 Face Type: 1 Face Name: - u5 M. d2 E+ `5 e
Face tag: 41396 Face Type: 1 Face Name:
& q8 r. N4 k Q: f( rFace tag: 41397 Face Type: 1 Face Name:
( R8 C/ ~) s! [! yFace tag: 40995 Face Type: 2 Face Name: ; B; u, W( y9 \% t% F; {
Face tag: 40965 Face Type: 1 Face Name: 6 y; r# p* Q+ h/ g
Face tag: 40997 Face Type: 1 Face Name:
6 l8 w; |3 `5 k; J6 Z. jFace tag: 41351 Face Type: 1 Face Name:
* X$ p4 Z7 w! d9 R% CFace tag: 41352 Face Type: 1 Face Name: 4 C0 G+ a5 Y n6 R" A
Face tag: 41353 Face Type: 2 Face Name: 6 x( u1 r% `2 ]: ?5 D$ F# W
Face tag: 38479 Face Type: 1 Face Name:
- m" f% l4 T C- [+ j! q/ A' l' }Face tag: 38480 Face Type: 1 Face Name: $ f& ^3 M0 @. n, z# `. V+ T
Face tag: 38481 Face Type: 2 Face Name: ) e' | e: F! Q& B8 ?- F
Face tag: 41207 Face Type: 1 Face Name: 8 l/ F( u& o+ C3 Y! M
Face tag: 41203 Face Type: 1 Face Name: 1 }! ^8 u* J6 I
Face tag: 41158 Face Type: 2 Face Name:
7 N1 H ?: A: q$ LFace tag: 40987 Face Type: 2 Face Name: . @* R$ Y9 H- V- F/ y
Face tag: 41010 Face Type: 1 Face Name:
5 z( w3 n$ ~0 WFace tag: 41001 Face Type: 1 Face Name:
2 [" h* K" Z, b1 n. Q/ [Features count = 7
t# o0 |' J/ ^* e3 H4 [features tag : 41280 features Type: SPHERE features Name: Sphere(17)
$ Z) U: v, Z q7 j: R2 C# p v- [$ S, Nfeatures tag : 41281 features Type: BLOCK features Name: Block(18)
0 p& \6 y4 A# X& g" Yfeatures tag : 41307 features Type: CYLINDER features Name: Cylinder(19)' ~) }3 L- k7 f& f* r
features tag : 41314 features Type: CYLINDER features Name: Cylinder(20): M9 s% R, V: y/ w# H2 Q G
features tag : 41322 features Type: CYLINDER features Name: Cylinder(21)6 _& r R1 @. \2 y
features tag : 41330 features Type: CYLINDER features Name: Cylinder(22)# O1 H1 t( g+ B2 h Q
features tag : 41338 features Type: CYLINDER features Name: Cylinder(23)
/ ^, c) G7 P4 I$ j
% l" ?. o, @& r) j |
|