|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息( d! x& m# Z! \! N9 E, H( E: E
& j B) B, Q9 V+ O, E
) Z4 r# L/ z! O7 c% O theSession->ListingWindow()->Open();
- e2 d; A& C( F! z+ E) O theSession->ListingWindow()->WriteLine("Get information from all bodies\n");: E2 g2 ~) E( t& z. U& n
std::vector<Body *> bodies;$ ~) U: N- j9 ]! M+ x8 ?
BodyCollection *bodyColl = workPart->Bodies();
7 i7 z, Y& X% l4 Y% p for(it = bodyColl->begin();it!=bodyColl->end();++it)
: V$ P( h# B4 q {/ Y. R$ K( s4 e# p+ }4 ~0 E X
bodies.push_back(*it);
0 m u5 M) f$ Q) {- k }
/ i, H# A, t8 C9 b3 e ss <<"Bodies count = " << bodies.size()<< "\n";
" ?1 e/ v" k( E f" I! g, c std::vector <Edge *> edges;
! z7 v5 h/ [+ D& M7 E* G std::vector <Edge *> totalEdges;
% x3 V0 X1 k6 V% A8 J% z' Q* J std::vector <Face *> faces;
: I! a h. B. v. n9 O! I std::vector <Face *> totalfaces;7 o7 i4 ?4 P5 Y7 d! |
std::vector <Features::Feature *> Features;
( Q2 r8 `0 O3 K1 m3 ]. T7 F/ P& a std::vector <Features::Feature *> totalFeature;
# U1 U6 P4 \, b R- ^* Y* r Point3d vertex1,vertex2;
, H; F0 Z, R0 M1 H6 f, L) o for (unsigned int i = 0; i< bodies.size();++i)! x4 l/ D, D" z. P
{
( Q& v$ K8 f) s edges = bodies->GetEdges();
6 U/ W" r$ n- c: b* G- U faces = bodies->GetFaces(); Z& t6 \$ _+ ?+ L" F9 H, b
Features = bodies->GetFeatures();
: r9 ]% Z0 h6 `( v( m1 s& {3 z for(unsigned int j =0;j < edges.size(); j++)6 {" f6 W% s" R& u
{
* |/ j L: ^, S# v- c/ O0 V totalEdges.push_back(edges[j]);
0 \9 n; P9 q& }' w }
0 c+ Y' n: T( N5 B! n for(unsigned int j =0;j < faces.size(); j++)
i8 d! @* z! L; E" Q- b {. N9 f: k0 F, g5 Q
totalfaces.push_back(faces[j]);
0 t# r9 t0 O& Y9 i }* D: k/ i' R/ t% B$ C2 {% F7 k, I
for(unsigned int j =0;j < Features.size(); j++)) Z2 p, p6 c3 B2 ^
{
9 [2 w z9 D8 T4 j2 W6 U' G1 j totalFeature.push_back(Features[j]);
4 v7 v' G, Z2 G5 o }
# K; l% I9 ~. I- ~ : [5 O7 l! f2 \
}
* V5 [7 G# Z, B; y6 ^. d ss <<"edges count = " << totalEdges.size()<< "\n";
( ]2 R( X5 d+ D for(unsigned int j =0;j < totalEdges.size(); j++)3 X# e x8 t7 d$ ^0 z/ u. b
{
' k8 k0 B9 n$ n# Y totalEdges[j]->GetVertices(&vertex1,&vertex2);+ ~ D0 z+ \" m$ P9 L' |
ss <<"edges tag: " << totalEdges[j]->GetBody()->GetTag()<<"\t";
$ E) r C7 R+ }( m ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";% d6 q1 `& o* r p! r* j# B" c+ v3 R7 @7 {
ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n";0 V& x8 v: {) s4 ^2 j
}
( I1 o9 [/ m0 o, M4 g ss <<"faces count = " << totalfaces.size()<< "\n";
s x8 v7 A+ @/ |. x! \ for(unsigned int j =0;j < totalfaces.size(); j++)
; s# ? ]" @+ G6 C- c% T& s {
6 K. ?7 A x& F2 a# b q( L2 P ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t";1 l% P/ R" y8 u9 B# A$ J! f& w* g
ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";. b; W/ m/ _( [
ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";
5 R& w( @3 @$ x4 r9 b# Y }# u& h# T l0 U7 V8 u
ss <<"Features count = " << totalFeature.size()<< "\n";
- F* u+ S9 S& }) ~! L for(unsigned int j =0;j < totalFeature.size(); j++)$ ~7 T5 W9 I# J
{
9 Q2 P: x/ ], f4 _2 x1 O9 F( Q ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";% J% I" {6 o. e; G
ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";8 q6 g; q. H. C# j! T: C
ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";
% \1 m, Q) g, N9 W }1 G# E) ~/ G" U3 k& ]' F
theSession->ListingWindow()->WriteLine(ss.str());! D; K* N2 D `, T3 z. E# z; s8 z, b
2 B2 Y) g' d, ^/ _! v$ z! J
4 }3 |, ?1 T# v+ P5 ]. H查询结果如下:( E9 a& Q# j, V
1 c2 G' |; |8 I* R6 J
9 {) J. A5 q9 R& }+ `Get information from all bodies& _: Z! v; Z' w8 N9 n; c: X
CYLINDERBodies count = 7
2 C: r/ Z) b# m, l9 |edges count = 22
9 o1 V( r4 g4 N. M; B% Redges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100)
% v. i% \& a. {; _$ B$ p. nedges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0)" v* o8 E+ a- e2 v
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)
3 ]1 ?' T9 x* n2 S3 _: D% Pedges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0)3 P4 ^6 ~' z1 b: R5 w
edges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100)$ U* n: w. v5 c4 b
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)$ G4 x" b2 A- u+ [2 F
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100)" b1 }# o" H1 ^; ~
edges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100)
- O; ]. i# M' J( d$ `+ g8 t, k# ledges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100)8 D4 c3 ?1 H$ L
edges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100)4 u0 C, o* |+ m/ Y9 M
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100)+ m& p( z# B p, l4 r
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0)# L& g6 } F/ s% \* l: ~- L
edges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100)( i T* j0 v6 ^. n0 K
edges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)
+ z9 z! C, s" @% g9 y) s8 @ A5 zedges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)9 A& X% q9 x V; D2 P
edges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)4 t" F* ~& k s+ r7 T" \
edges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
- v; _3 ~4 E" q* d9 Iedges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)8 x/ f+ I" c: ?% C
edges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)
" [2 }1 [$ [! N5 ledges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500)' v- P6 Z' Q2 q4 q1 ^6 h
edges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200)5 j& v! q3 L6 B+ \1 B A
edges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)7 G5 q0 v9 @& c+ H
faces count = 22! q8 Q7 `# \- l+ U2 M5 F8 N
Face tag: 41407 Face Type: 4 Face Name:
2 k. B* x8 J- L |( e! GFace tag: 41398 Face Type: 1 Face Name:
+ ^: p1 P. I! c6 A% I/ T1 N( kFace tag: 41376 Face Type: 1 Face Name:
8 V6 v5 H. Y* h* i2 bFace tag: 41391 Face Type: 1 Face Name: 1 o5 N$ w% z# H5 |
Face tag: 41380 Face Type: 1 Face Name:
% q) z& G; x s, p. ^Face tag: 41396 Face Type: 1 Face Name: ; k$ Y2 P3 d4 j/ Y
Face tag: 41397 Face Type: 1 Face Name: / B" C9 f2 H' S. u
Face tag: 40995 Face Type: 2 Face Name: : X2 G/ l" S" Z8 n: S
Face tag: 40965 Face Type: 1 Face Name:
1 A, j$ V7 A% zFace tag: 40997 Face Type: 1 Face Name: 1 ?/ F( E$ X* V% ~9 L( D
Face tag: 41351 Face Type: 1 Face Name:
' x9 F' J' [& BFace tag: 41352 Face Type: 1 Face Name:
/ Q: e8 q# U Y. ~- cFace tag: 41353 Face Type: 2 Face Name: * H8 x% X: |! X% R0 d6 w$ f
Face tag: 38479 Face Type: 1 Face Name:
0 f2 C* A+ |2 c& zFace tag: 38480 Face Type: 1 Face Name: 3 M9 E! b' z0 g0 g& O/ j
Face tag: 38481 Face Type: 2 Face Name: + K7 ~* N6 W1 n- O$ s/ f m
Face tag: 41207 Face Type: 1 Face Name: % y$ O! ~* R, c* u: o3 m6 l, b
Face tag: 41203 Face Type: 1 Face Name:
$ d% \# O1 u& FFace tag: 41158 Face Type: 2 Face Name: * @. \- {* h1 m2 I
Face tag: 40987 Face Type: 2 Face Name:
" w) K; l' L; L1 v% }Face tag: 41010 Face Type: 1 Face Name:
* d* d% Y* V+ L/ sFace tag: 41001 Face Type: 1 Face Name:
! h, y. y7 d1 t3 |, UFeatures count = 7
, g# x" D1 r- y; v8 u" X, ufeatures tag : 41280 features Type: SPHERE features Name: Sphere(17)
: {) ^- `0 V$ l7 s- Ofeatures tag : 41281 features Type: BLOCK features Name: Block(18)
; C# o9 b) J! l0 N8 tfeatures tag : 41307 features Type: CYLINDER features Name: Cylinder(19): x Q; Z- S8 @6 a: G$ J- ^
features tag : 41314 features Type: CYLINDER features Name: Cylinder(20)" g, M) _& y6 Z! ^5 @) r
features tag : 41322 features Type: CYLINDER features Name: Cylinder(21)1 e8 y# k) ~3 F9 m' V% ~
features tag : 41330 features Type: CYLINDER features Name: Cylinder(22)
6 q( r" |1 `" @; jfeatures tag : 41338 features Type: CYLINDER features Name: Cylinder(23)
8 D- i, J% U; w& E7 K9 D" k3 c4 b3 F+ J& a1 `+ a' m
|
|