|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息
4 Q d+ H6 Z' m, Q4 K0 b; u$ k & d, H% R, g5 P- {% R
# ~8 ?# w/ z {
theSession->ListingWindow()->Open();
# H) J& d* r5 y4 [4 r) f0 | theSession->ListingWindow()->WriteLine("Get information from all bodies\n");1 q5 Q! I3 i" h
std::vector<Body *> bodies;
! C& D8 J7 m8 a O BodyCollection *bodyColl = workPart->Bodies();
/ H1 h% g: X( K2 s- J( h for(it = bodyColl->begin();it!=bodyColl->end();++it)) s$ n! S {1 A
{3 {3 u' J P( i1 z9 A
bodies.push_back(*it);7 s% L& _0 S' s* j2 z; }
}
8 L0 e2 F) U; ?6 F& [ ss <<"Bodies count = " << bodies.size()<< "\n";, ?+ K a, V; X4 ]8 Z. T5 D
std::vector <Edge *> edges;
" i# {# k: t4 [% p: U std::vector <Edge *> totalEdges;% a$ w0 v: H& f( f5 V$ i
std::vector <Face *> faces;$ @0 ]& [0 @3 \' F0 b
std::vector <Face *> totalfaces;' E* J/ b/ E" a
std::vector <Features::Feature *> Features;1 L5 C6 v6 C! l, m- L5 ]
std::vector <Features::Feature *> totalFeature;
5 I; V: H* \6 p+ t, _ Point3d vertex1,vertex2;; ^1 g- G+ |% D$ a
for (unsigned int i = 0; i< bodies.size();++i)) a8 o/ L- o* P) ?5 y
{
# J! k, }) q$ U# I: E/ @" M edges = bodies->GetEdges();5 X( |! A+ F1 g5 J9 P2 v
faces = bodies->GetFaces();
) {# D1 w1 {; c7 C5 o1 d$ n Features = bodies->GetFeatures();$ M+ Y& Q1 u1 V4 C5 r
for(unsigned int j =0;j < edges.size(); j++)
. `: @ S( g P {: h a" H; ?5 P
totalEdges.push_back(edges[j]);
. n" R9 Y% N. j3 _ }
7 J$ ?9 \( {2 r8 [" t9 y for(unsigned int j =0;j < faces.size(); j++)
* m1 r1 C) m" N {" t* E7 M2 q- C: h5 I' b2 ^. I
totalfaces.push_back(faces[j]);5 q4 _8 m$ `' p. t7 H2 a$ |
}/ [+ w' A$ f8 g! W+ z
for(unsigned int j =0;j < Features.size(); j++), Y, ^* n6 D: ~# l. \
{
# W0 r {! @! B, u( l6 l totalFeature.push_back(Features[j]);; r. L- t! y7 z, x) t
}1 ~7 L2 G* |7 B% L) A7 K
" Y8 x$ I% o2 C( j- M! S }; U: x! e2 Z0 f0 G0 |: H
ss <<"edges count = " << totalEdges.size()<< "\n";% S1 G: I5 K% g. M6 H6 L+ j. Q1 M
for(unsigned int j =0;j < totalEdges.size(); j++). s8 E: T* \: f
{ , p6 O: t' e8 U! t$ m* O
totalEdges[j]->GetVertices(&vertex1,&vertex2);4 z, Y7 Z& \. p* F1 I
ss <<"edges tag: " << totalEdges[j]->GetBody()->GetTag()<<"\t";
# M/ w- t9 {( D; N- A4 R+ x% y ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";
2 r# b# K# n5 l; ^ ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n";
4 L$ C+ c, U5 m# t+ Q! J* T }1 ?3 m$ S3 n0 ?3 C$ x5 D
ss <<"faces count = " << totalfaces.size()<< "\n";) r& i7 K* ^+ L1 \+ }3 z
for(unsigned int j =0;j < totalfaces.size(); j++)) s* f1 n9 o i# Q* c& O2 }( F
{ ; P7 U, f: B! R6 N1 b7 y/ V% b
ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t";
: z B% u6 h, V5 m/ [- n ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";4 Q+ `8 R# {! t2 G: h
ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";2 K& p% _ s+ g3 l: K8 z9 h
}0 C- t R# a; S4 G9 ~9 C3 L* d$ f
ss <<"Features count = " << totalFeature.size()<< "\n";
: z5 o7 Y. w" u3 Y0 y for(unsigned int j =0;j < totalFeature.size(); j++)
, N" g# ^. u, ^" [( S( X2 t0 w4 ^ { 2 H4 t# M, {/ p7 F& ?6 V$ p# g- q
ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";! J; ? `( }( D& A0 W# i6 k
ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";$ T( I' `" H& S* V# P
ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";( \; M7 p% N$ p. b$ m
}
. O x4 J9 q6 K( P theSession->ListingWindow()->WriteLine(ss.str());
# _1 W! o3 \' l8 B
( L5 O. B, T' q/ ^ }# j8 R/ n& W3 L$ [# y& r* |9 f
查询结果如下:
# r4 ]/ T O9 R6 D) k3 ?$ A2 W7 I( L& v. a" b6 A
5 @- T" D* k5 b' r( Z, N% h) C* n! @Get information from all bodies
8 \3 A% E& i' n8 B% S g3 uCYLINDERBodies count = 7
, M7 l4 F6 l4 redges count = 22" m, Y1 @/ L1 l$ j9 _9 @9 \1 |
edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100)
8 B3 [# X3 d+ q8 V" Qedges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0)3 ]' q7 e3 S- Z1 J" L5 {) e3 p
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)
0 X* l H4 w6 K/ e# Y$ M( H8 ^edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0)6 [+ V1 c7 u" t
edges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100)& j% s3 k; G. m$ w1 |
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)
9 f3 R+ ]6 T1 N, R/ G- Gedges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100)# i3 d ]; @4 K, n9 K- `
edges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100)
4 V9 m7 L& I4 uedges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100)
/ Y1 S2 R, e% g ^ medges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100)% i+ x) R! n6 @; I7 h
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100)3 ]- Q2 a8 i0 p
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0): [* M X$ I" e5 `
edges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100)
% \' g2 U; M/ U) c& ^edges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)$ _0 O5 i1 `9 S( J e
edges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)" {, c* M! I; k- w6 o: c, {+ ~
edges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)0 g- [! ?5 i( y3 q! T ^$ o9 o H
edges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)8 |4 Y" i6 e9 G+ i
edges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)
& h. ?) L& `: e, w6 \. @edges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)3 O& H2 ~6 I6 \. u! w) W, i( I
edges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500)" l% Y# B- _. Q
edges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200)# L$ Y) t* ]) q8 ^4 d
edges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)9 Y' }# J6 W4 F" Y* j- k' l
faces count = 22% _) M2 m3 ^- H. p( i( x4 m! x- i
Face tag: 41407 Face Type: 4 Face Name:
' M5 S3 `+ ]% V# f8 KFace tag: 41398 Face Type: 1 Face Name: $ D- K$ P6 t( ?
Face tag: 41376 Face Type: 1 Face Name: ) G4 w. V+ n+ @. N1 U. _) @$ p& D
Face tag: 41391 Face Type: 1 Face Name:
$ E# Y! M! f. J3 PFace tag: 41380 Face Type: 1 Face Name:
5 h x* Z, S2 Q6 Y! L( Q7 JFace tag: 41396 Face Type: 1 Face Name:
( a" ^, O3 Q( z$ V# F7 |4 SFace tag: 41397 Face Type: 1 Face Name:
7 d- @0 a$ h& o: x# [Face tag: 40995 Face Type: 2 Face Name: 4 V1 O8 ^$ d4 Q, [; r/ h
Face tag: 40965 Face Type: 1 Face Name: 6 o7 Z+ N6 H& A5 j) S1 y$ {
Face tag: 40997 Face Type: 1 Face Name: : w7 T$ S% M! J, l8 O
Face tag: 41351 Face Type: 1 Face Name:
$ W7 @3 ?. C, w7 x, ]Face tag: 41352 Face Type: 1 Face Name:
' c; c& B/ C' E& H: d# oFace tag: 41353 Face Type: 2 Face Name:
2 n9 d X/ m+ T6 v. ~Face tag: 38479 Face Type: 1 Face Name:
7 X7 p' w6 J' l# ~0 |2 \Face tag: 38480 Face Type: 1 Face Name: 1 p, J( U3 w1 k5 U* N! Z/ Y' \% M
Face tag: 38481 Face Type: 2 Face Name: 8 V" t: P! X% }# |/ _
Face tag: 41207 Face Type: 1 Face Name:
) R6 i6 C' m& e1 x1 d( bFace tag: 41203 Face Type: 1 Face Name: * s: b- k3 ]- p9 x; Z( ]. ?4 h
Face tag: 41158 Face Type: 2 Face Name:
1 J4 N$ R# o% B5 w0 V( l+ m& L3 UFace tag: 40987 Face Type: 2 Face Name:
( U. ^: P( [1 X. K5 B8 h6 w- [Face tag: 41010 Face Type: 1 Face Name:
9 s0 i' @2 Q6 q0 ^$ C7 U4 IFace tag: 41001 Face Type: 1 Face Name:
8 ^6 R/ `, F7 ZFeatures count = 7
3 ?" ]6 q+ O9 W2 T l4 Kfeatures tag : 41280 features Type: SPHERE features Name: Sphere(17), Y- n- `6 u8 A" h* c0 f
features tag : 41281 features Type: BLOCK features Name: Block(18)8 P. Y8 h. o- {5 ^3 B1 k/ a( v6 T. ~3 B
features tag : 41307 features Type: CYLINDER features Name: Cylinder(19)
7 J. N i; B$ Y5 S3 c# L- kfeatures tag : 41314 features Type: CYLINDER features Name: Cylinder(20)& G' m/ E" |4 }( R2 D: c
features tag : 41322 features Type: CYLINDER features Name: Cylinder(21)
6 i( |& Q, ~- {- pfeatures tag : 41330 features Type: CYLINDER features Name: Cylinder(22)
# l0 C: n& i# ifeatures tag : 41338 features Type: CYLINDER features Name: Cylinder(23)
' K9 {6 @7 ^2 q: {, X4 L
% ^. k3 q8 d0 L! q# | |
|