|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息
) M" P- s' F4 Q. k/ ?( m0 }/ l* B " t5 R* B8 L7 e; u
& E2 U. N8 y, l8 N1 Q' h theSession->ListingWindow()->Open();
3 g$ D) u! A- Z6 d% p6 w; l: P theSession->ListingWindow()->WriteLine("Get information from all bodies\n");4 ~' e8 }0 u0 ^. I
std::vector<Body *> bodies;) S: m! |! W# y4 M. e% U: t
BodyCollection *bodyColl = workPart->Bodies();
1 @; k/ U$ I$ b- \( q5 e! h$ F for(it = bodyColl->begin();it!=bodyColl->end();++it), S, F7 o) y' c& A; e) g- P
{
4 ?/ `! o* m; e2 E4 h- B | bodies.push_back(*it);
W3 F" n* K! Y- p! y7 H w }
/ T; E3 B- V: }! z8 y ss <<"Bodies count = " << bodies.size()<< "\n";4 ]: n# f3 O: k4 h1 ?1 c0 q
std::vector <Edge *> edges;/ T7 B& \; [1 e2 f
std::vector <Edge *> totalEdges;
]+ n8 |8 B" J% ~7 h std::vector <Face *> faces;
; M4 r0 @2 F& B0 }7 ] std::vector <Face *> totalfaces;- T0 m9 e' Y* s( ^- N, b( B& T9 X
std::vector <Features::Feature *> Features;
7 {0 m: k; ^' z7 V, ^& J std::vector <Features::Feature *> totalFeature;
6 f" g; ~1 {" ?0 B Point3d vertex1,vertex2;! }; l$ v$ R0 f; H7 O
for (unsigned int i = 0; i< bodies.size();++i)
* S) R' A- i5 T {
! l) C% Y* C" h& m. T edges = bodies->GetEdges();
: h3 m4 R, @6 _$ `4 I% W l faces = bodies->GetFaces();- ?; y6 V. ~3 d G" k; V3 M$ r- Q! K
Features = bodies->GetFeatures();
8 I& u9 }/ E7 Z$ D) d0 @ for(unsigned int j =0;j < edges.size(); j++)+ f5 M- [! e: ~( U3 V3 L) `$ G
{
8 `" p) z0 }, @5 y) X" a" ^$ u4 h totalEdges.push_back(edges[j]);
) X- p+ v5 [8 G8 O# C4 _; @ }9 {8 v3 W% N; P- @1 }
for(unsigned int j =0;j < faces.size(); j++)8 t; O4 ?! `3 [8 n) h; ?! C/ A# U! s
{
6 V# l3 n( x; I5 n6 r6 ~* ` totalfaces.push_back(faces[j]);9 _/ Z! p E9 o+ t" d
}2 R# {8 ]% H) Q. D7 I6 {9 v
for(unsigned int j =0;j < Features.size(); j++)
; Q1 ?8 @. s9 S$ n1 ^3 y) s1 } {4 B. l# N1 U: Q6 d* e) v
totalFeature.push_back(Features[j]);; @8 c4 v0 n' N% V" H% q- c
}' g$ E; @! {. ?: K
' l @4 `; z- Y( s: W# t } i' J/ z3 W, D% z" J% p. t" I8 K3 j
ss <<"edges count = " << totalEdges.size()<< "\n";/ {; v b) x6 W( z9 [! Z" r4 }1 W
for(unsigned int j =0;j < totalEdges.size(); j++)
. i0 J( t7 \' a6 g {
: I- y/ {, S& C totalEdges[j]->GetVertices(&vertex1,&vertex2);. D8 f M! L5 I$ ^
ss <<"edges tag: " << totalEdges[j]->GetBody()->GetTag()<<"\t";
2 C9 C8 Z7 B4 O: V5 }8 G ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";! D1 J! W5 D4 J$ U* P+ T- |9 b
ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n";
0 \! y5 D# n( [& t }
" b$ S4 F8 h( ~/ s* c* ] ss <<"faces count = " << totalfaces.size()<< "\n";: \7 p* l S- f& v& r# j
for(unsigned int j =0;j < totalfaces.size(); j++)
9 I& p: T7 g: q: {- D { 9 Q9 [* ~6 P s9 `" m
ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t";
) b8 C- _ Y" F+ I% n0 ? ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";' k7 r; L9 k( q6 [$ ^0 C. _7 C
ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";3 R/ A# I& S3 N, R
}
/ t" e! J/ o" ?3 b- A K7 _1 a v ss <<"Features count = " << totalFeature.size()<< "\n";/ h$ l- S, L4 T4 U$ y6 z
for(unsigned int j =0;j < totalFeature.size(); j++)( o1 u% q: n. w" g1 V( L
{
. t1 v. ?, `& a. h, m ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";
. j/ Z a( y; j: P ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";
( b) V7 F. ~2 \ ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";- b0 p9 j. x( _% z6 P$ s) c4 ?
}, j' V8 O( q* N2 |' `
theSession->ListingWindow()->WriteLine(ss.str());/ z6 P) G; k0 _! I8 r
- j [3 A3 F2 Y' B
' l1 F* y# |# m t$ e' ]查询结果如下:/ C) E' E2 T+ D7 a/ L- o
/ M1 c" V3 D8 n4 x5 h* _( V+ P
) s! b* A6 p3 U7 d4 eGet information from all bodies
9 k% T/ ?! A$ F2 cCYLINDERBodies count = 71 I# E3 ~8 P3 u$ |! Y- l; K# q. N
edges count = 221 R" M: D) @) H/ }9 n
edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100)
$ r2 m' g/ A5 @& v6 N* K0 Q% bedges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0)- C9 {+ m% C) ^$ Q
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)
9 b: e+ V! w+ fedges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0)1 H' i, b, O- Q: h
edges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100)
8 u3 G/ g2 @" ~ z; Sedges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)7 h# Z/ ?+ D+ e! q: D" J6 I8 g
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100)
& v, S) C7 R8 Jedges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100)7 Y( A5 @4 t- F7 k0 s% G
edges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100)
3 @, L! E# ]) l. qedges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100)' M$ g+ H8 W+ S& g
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100): Q8 M- C1 K0 o$ |5 Y, l7 d
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0) t. y! E5 I) V
edges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100)
1 X% q/ ?+ h6 i2 Nedges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)
: g5 y! z" N: w: vedges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)
# S @5 g7 a. }0 k, x! g9 E' w xedges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)* q3 e( w& u% A" \
edges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)6 ^0 D3 L& k- j! Y
edges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)7 v. U C/ C2 z# s' G: R; _: ^: Y
edges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)
# r9 s: M! X, q) n& v; s. Z2 Zedges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500)$ e2 I- g0 C: \0 [2 p: E
edges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200)# v/ F2 M3 H2 W1 M9 L( Q( t+ D4 e
edges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)
% c, ~4 n0 d% E* b: zfaces count = 22
- ^5 G( B" j* a' s! \; H+ C5 O8 NFace tag: 41407 Face Type: 4 Face Name: & r% K2 K7 D0 E9 f# ^: c
Face tag: 41398 Face Type: 1 Face Name:
" O0 p, k) x+ ~) H. PFace tag: 41376 Face Type: 1 Face Name: # q9 f# s; h8 c
Face tag: 41391 Face Type: 1 Face Name:
! v! p& ^: w7 i4 a/ aFace tag: 41380 Face Type: 1 Face Name: : x S. Z7 r- {! ^
Face tag: 41396 Face Type: 1 Face Name: ; y# M; S G( L/ [6 C: D
Face tag: 41397 Face Type: 1 Face Name:
8 Y7 o. q, [- G. NFace tag: 40995 Face Type: 2 Face Name: 2 F) J( X! r3 T3 ^( H3 i
Face tag: 40965 Face Type: 1 Face Name:
# |* I0 D0 `! G4 YFace tag: 40997 Face Type: 1 Face Name:
! R; ^ @( q8 y uFace tag: 41351 Face Type: 1 Face Name: 6 Z7 ~& w) f9 |3 H
Face tag: 41352 Face Type: 1 Face Name: 0 Y+ J! k& N& k5 P5 H
Face tag: 41353 Face Type: 2 Face Name: P. U9 n/ B: }0 t) m
Face tag: 38479 Face Type: 1 Face Name: - N: Z$ E8 }0 Y3 o8 x: K
Face tag: 38480 Face Type: 1 Face Name:
0 r: Y0 P. j4 n+ q+ KFace tag: 38481 Face Type: 2 Face Name:
4 c1 {- a7 ?4 Q# e$ G0 b4 @6 U* aFace tag: 41207 Face Type: 1 Face Name:
- f; D5 y: @2 W! y: zFace tag: 41203 Face Type: 1 Face Name:
) T, t" }. f- V% x C' |Face tag: 41158 Face Type: 2 Face Name: - E: c& B4 R! K2 V! u& t- h: A
Face tag: 40987 Face Type: 2 Face Name: 1 O$ a4 l) j9 h7 Q2 F' X4 D
Face tag: 41010 Face Type: 1 Face Name:
, U: b4 f. s, L+ n3 i: DFace tag: 41001 Face Type: 1 Face Name: ; m# v' V. R# c3 Z) w- Z
Features count = 7
# p. P9 z! q; w- w- i3 Xfeatures tag : 41280 features Type: SPHERE features Name: Sphere(17)4 B/ S: R7 S! ]6 Q8 N
features tag : 41281 features Type: BLOCK features Name: Block(18)5 Y- n. r0 W3 U/ X8 B# I! K
features tag : 41307 features Type: CYLINDER features Name: Cylinder(19)
3 U8 n8 {1 `3 ^1 Y) Y- ~features tag : 41314 features Type: CYLINDER features Name: Cylinder(20)- S0 b. C& }* `' q8 h7 `; y
features tag : 41322 features Type: CYLINDER features Name: Cylinder(21)0 Z4 E4 P/ A) ?2 [: B: ]* C
features tag : 41330 features Type: CYLINDER features Name: Cylinder(22)6 S2 q0 @# W& d3 [$ I# s
features tag : 41338 features Type: CYLINDER features Name: Cylinder(23)
& e! k; I: y% m" S/ a, e
" p0 Z) [" m0 m2 v$ d |
|