PLM之家PLMHome-工业软件践行者

[二次开发源码] UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息

[复制链接]

2013-11-4 16:53:51 6324 0

admin 发表于 2013-11-4 16:53:51 |阅读模式

admin 楼主

2013-11-4 16:53:51

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息
" u6 w6 z5 m7 r7 L" M7 Q! |
+ H0 M: F8 g: H* T8 A9 N; B4 C7 w+ \3 F1 d# D; i
  theSession->ListingWindow()->Open();( F/ g  G, K! ]4 S: r/ x
  theSession->ListingWindow()->WriteLine("Get information from all bodies\n");3 m/ R1 o( c) y! w. s
     std::vector<Body *> bodies;7 l' k& r+ I! z2 r, T: D
  BodyCollection *bodyColl = workPart->Bodies();
- z' W; N* B* G6 q' B# Z: n8 ]  for(it = bodyColl->begin();it!=bodyColl->end();++it)7 J) D7 s9 L  S7 ]. c
  {3 _, F3 X) x) A3 L
   bodies.push_back(*it);* L8 g! e4 S( b8 Q- ^) N3 a: I. B# i/ l
  }
0 E. Y* G6 y! P7 o) f  ss <<"Bodies count = " << bodies.size()<< "\n";
' J5 j; i2 {9 B   std::vector <Edge *> edges;! @) R  C, j2 z* Z8 V0 u
   std::vector <Edge *> totalEdges;
% j1 V7 N, u/ Q9 W# d- ~   std::vector <Face *> faces;( _5 J8 U3 X4 {1 V/ q
   std::vector <Face *> totalfaces;( I) \9 _# P/ F+ Y! ^3 i6 r
   std::vector <Features::Feature *> Features;0 Q( S! i$ A$ Y1 M; V
   std::vector <Features::Feature *> totalFeature;
) [% X& |" m) y% z   Point3d vertex1,vertex2;
5 \: A$ C6 `3 m1 s: U4 p   for (unsigned int i = 0; i< bodies.size();++i)' e7 s7 b* S! |% f9 g
   {1 k0 i% T, m5 L; Y# r% o* B9 v3 T
    edges = bodies->GetEdges();
, i2 u0 _% t/ e, [    faces = bodies->GetFaces();
, r& X# A; P! q7 b    Features = bodies->GetFeatures();3 a8 X" _+ @6 s0 p; T) G9 [% o
     for(unsigned int j =0;j < edges.size(); j++)1 g5 o9 w1 [4 J- C" k/ b
     {5 u6 E  c& Z$ L# m( X1 T
     totalEdges.push_back(edges[j]);
  ]5 E, R! `$ G     }
  r+ c9 X! P  P% b     for(unsigned int j =0;j < faces.size(); j++), [  ]$ e5 }: P+ O( K
     {5 {, k" ~2 D& R( C# j
     totalfaces.push_back(faces[j]);
/ v; p( n& V, P9 t1 m     }
/ M3 D! f0 J! L      for(unsigned int j =0;j < Features.size(); j++)
/ [0 r1 L' Q1 v. ?  p8 }) O" m     {3 A3 F' w" f, u' T; @; F
     totalFeature.push_back(Features[j]);
- w3 j$ U( ~  {3 B, ^  c  m     }
3 \" H, ~) X/ e% B" g4 J4 h      * t/ E, u# W3 r- q  O$ p# ?9 e
   }
+ W2 Q( m( t& Z    ss <<"edges count = " << totalEdges.size()<< "\n";
0 G2 p3 ~0 _* Z* s: a, b; y1 {   for(unsigned int j =0;j < totalEdges.size(); j++)4 [: C+ L' ^$ p0 Y# b. c) b# y: t9 T
     {   
! x5 n) l! r* K      totalEdges[j]->GetVertices(&vertex1,&vertex2);
' L- S& }+ G0 l  k/ g       ss <<"edges tag: " <<  totalEdges[j]->GetBody()->GetTag()<<"\t";* j* b3 I7 q2 |) F( C
       ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";# X! H, M  u2 Y* @( F! C
       ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n";
% S" ]# L0 i- N3 k  x     }
$ l& ~5 @8 x0 W' ]9 S& h* B   ss <<"faces count = " << totalfaces.size()<< "\n";
0 ^2 l% s7 d6 a* B3 G    for(unsigned int j =0;j < totalfaces.size(); j++)1 V2 C% M. \( K- m, u% y
    {  
2 j& ^, O0 w8 K) \% }- j' K     ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t";1 A$ Y( u8 K8 L+ p' U) Z% F
     ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";9 b. b3 @) \* G  h) Y$ I
     ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";" Q/ @' q1 X# Y3 O; o
    }
7 y# h, \0 F; L  f3 e* K/ c' U   ss <<"Features count = " << totalFeature.size()<< "\n";
" `* }" X: G  W0 {; z- M     for(unsigned int j =0;j < totalFeature.size(); j++)
  e3 i+ {% |  }3 f* D0 o    {  
1 H2 U& y, J$ P9 M7 a9 Q) Y% \     ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";
7 i; i( j$ t* K4 |7 K1 M) ~  ], O     ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";
8 ~( D0 |# h- x4 k     ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";% H$ X5 I+ k+ B
    }' Y, z) w7 _6 m
  theSession->ListingWindow()->WriteLine(ss.str());- O) S4 @0 l/ _6 O. o' L

0 @/ Y/ \. l! T. ?! ^) @
4 {/ T9 W( W  ?) g( `查询结果如下:5 W6 T4 Z; K  U$ ~* X, y- m, \
1 C# j. X7 I! e

. z! ?0 M3 r& p& AGet information from all bodies
1 W5 u* W) b2 B, L0 rCYLINDERBodies count = 71 k9 c0 e0 Y" o7 W) U7 n* v' |
edges count = 22
8 n" v5 F1 K( ?  _) I/ q" Zedges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100)
9 T/ z7 A7 `( L: |" Vedges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0)
) C' [7 M; V  A$ v* x7 d# Redges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)- W1 F+ J1 a  o
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0)5 X' V) v  H, T( K7 i1 J4 [# i3 q
edges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100)6 [8 h  Z; _1 m5 f9 u9 ?
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)/ p$ g4 j' u1 L7 W
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100)
1 J- x7 p/ `1 o' ?$ gedges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100)
: f% q% p1 `* M2 Sedges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100)9 ^( \/ G$ a1 w" |$ D
edges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100)) Z: h$ ?& l" P6 |& X
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100)& a# S" N9 @3 C0 B$ g
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0)' R- b! r4 D6 P) _- c1 T
edges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100)
$ F$ W: [  q, yedges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200); B* u% _1 q! o3 Y% T
edges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)
" s" H: `0 Q* l7 a  S1 L3 Cedges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
/ Q4 w( [. x* ]: Y  ?/ ^edges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
1 d2 i. m) M9 N4 Q1 {! H  h6 cedges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)% {/ U0 b' ]: d  P" u3 |
edges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)  H8 p  h7 s  G( o" D+ x/ ^
edges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500)
( C. U" i* L1 Q- y$ R+ ?edges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200)
5 x% l" Z" }, o! _edges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)3 l5 Z" D# F* L4 b2 f! H3 o
faces count = 22" Z1 f/ r/ q7 T; l' F2 A  O
Face tag: 41407 Face Type: 4 Face Name:
9 d8 [) ]0 ?( z# k: j: Q* b( EFace tag: 41398 Face Type: 1 Face Name: / Z% q) d4 J! |% f- F/ }
Face tag: 41376 Face Type: 1 Face Name: 1 K/ v9 t9 |- @6 P, V# y0 v
Face tag: 41391 Face Type: 1 Face Name:
" y6 p: G: a, z  u3 ^Face tag: 41380 Face Type: 1 Face Name: 5 X* n" }: h' w9 L+ ~) W
Face tag: 41396 Face Type: 1 Face Name:
7 f3 A' x& `! m/ H- Z, nFace tag: 41397 Face Type: 1 Face Name: 4 d% O5 H4 K: O1 d
Face tag: 40995 Face Type: 2 Face Name: + s) S8 m$ m4 ]4 }: A
Face tag: 40965 Face Type: 1 Face Name:
6 G7 s1 z% f3 cFace tag: 40997 Face Type: 1 Face Name:
: ^1 A. T. n7 W$ n0 l; g6 c1 ^* iFace tag: 41351 Face Type: 1 Face Name: ! D7 B0 H6 n# ?( S( C5 m
Face tag: 41352 Face Type: 1 Face Name:
! n; N% k3 W' I( M/ o5 a0 q( vFace tag: 41353 Face Type: 2 Face Name:
. r9 o2 L5 b! F+ {2 |; vFace tag: 38479 Face Type: 1 Face Name: 7 \, T- ?  |3 f1 }7 m$ @; }
Face tag: 38480 Face Type: 1 Face Name:
% }0 ^, k4 c/ E. @Face tag: 38481 Face Type: 2 Face Name:
( S" r. S  g& p) x0 m# ]3 b9 Y8 ]Face tag: 41207 Face Type: 1 Face Name: 2 Y  X0 q) Q0 Y
Face tag: 41203 Face Type: 1 Face Name:
! o5 _) R% O4 H+ PFace tag: 41158 Face Type: 2 Face Name:
. F+ q; p3 a7 q! P% Q/ @, l2 ZFace tag: 40987 Face Type: 2 Face Name:
; V7 _/ j) F: D0 C+ {Face tag: 41010 Face Type: 1 Face Name: 5 z$ Y, S+ S' j( T
Face tag: 41001 Face Type: 1 Face Name: ' M9 l/ U. W) p
Features count = 7
  l0 i& S. C6 d6 O' H% a2 Zfeatures tag : 41280 features Type: SPHERE features Name: Sphere(17)
! h- h& a/ Y2 t# Z5 x! a9 Ffeatures tag : 41281 features Type: BLOCK features Name: Block(18)' h: s+ D2 H9 P) g+ s5 Z9 D' B
features tag : 41307 features Type: CYLINDER features Name: Cylinder(19)7 A: m2 L+ G9 [5 j
features tag : 41314 features Type: CYLINDER features Name: Cylinder(20)% @7 I8 \1 U$ y% L( ^7 i" M' L
features tag : 41322 features Type: CYLINDER features Name: Cylinder(21)# k  T7 U' ^  M0 }! v5 \9 H
features tag : 41330 features Type: CYLINDER features Name: Cylinder(22)( K, S/ S' W  }% s& \" G, B( g
features tag : 41338 features Type: CYLINDER features Name: Cylinder(23)
! Y# o, ?  h9 b! i, I- O- ^2 |8 T1 d- b9 m4 r
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了