PLM之家PLMHome-国产软件践行者

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

[复制链接]

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

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

admin 楼主

2013-11-4 16:53:51

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

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

x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息" X4 I5 c* C1 \: P+ n

/ ~! N3 G  ^1 s% C4 P$ {2 l; B( `4 j
  theSession->ListingWindow()->Open();
, k, [" ~# S0 B  theSession->ListingWindow()->WriteLine("Get information from all bodies\n");5 p- S& \7 ~4 I( C
     std::vector<Body *> bodies;
* K. O2 ?+ ]7 @" x  m  BodyCollection *bodyColl = workPart->Bodies();+ b: b5 z( U2 O  e2 J9 Y2 ]
  for(it = bodyColl->begin();it!=bodyColl->end();++it)8 ^; R$ @" M* Z7 m1 i
  {8 d+ ~4 J: d8 q
   bodies.push_back(*it);
" @8 n; W) G4 ^( T/ q  }
& y9 z5 E) R- q* F" V  ss <<"Bodies count = " << bodies.size()<< "\n";
8 h: O% }8 L+ C8 f; l   std::vector <Edge *> edges;. z; P+ I6 b4 f2 L: \* j
   std::vector <Edge *> totalEdges;; H" k2 A: [& g/ e2 C- @) ?& n
   std::vector <Face *> faces;8 ~# h, C/ l) k( I+ ]9 K/ R
   std::vector <Face *> totalfaces;* l5 f1 y" r2 m# w/ f) z- `& ]2 _+ z
   std::vector <Features::Feature *> Features;
: t- e. V8 `/ _6 R  r   std::vector <Features::Feature *> totalFeature;
) D% s' s& k2 C; q4 j7 g   Point3d vertex1,vertex2;
9 ~. n. z8 J# b2 V: r# N' q( ]   for (unsigned int i = 0; i< bodies.size();++i)
  O1 j8 A9 |, F6 I3 ~" `  A   {6 v. a& ?# O, Z3 C0 Q/ l  g
    edges = bodies->GetEdges();
, {& K3 b: A$ V$ r* q; ]    faces = bodies->GetFaces();
& Q. `* k* K: l5 x% Q    Features = bodies->GetFeatures();
2 C. l1 Y$ F/ _- [     for(unsigned int j =0;j < edges.size(); j++), h# W$ k3 R, y. S
     {/ N8 Q: }2 ~* e- L0 x, m9 R8 k
     totalEdges.push_back(edges[j]);( o4 a; H  K) Z% ~% C
     }2 _1 m, O9 Q9 Z: @# n
     for(unsigned int j =0;j < faces.size(); j++)! S! N$ }) R" A2 `0 J
     {: V: O. E. _  F8 k, w& J
     totalfaces.push_back(faces[j]);
  ?- Q1 C: _- U+ ~3 m/ T5 N' V     }
6 v. `& I# c6 P3 N% D# z      for(unsigned int j =0;j < Features.size(); j++)& _9 {& l( a$ d6 p: B6 I& L
     {" M( X+ }! q1 d; {
     totalFeature.push_back(Features[j]);
7 q5 @& d2 ?( w9 A     }
5 @" A' G3 U& P      
1 z1 k& K: s( a7 j5 w   }
% {; I7 N8 G6 b! b# {* ^" @    ss <<"edges count = " << totalEdges.size()<< "\n";
2 M4 a2 z' X0 y5 c9 l4 z   for(unsigned int j =0;j < totalEdges.size(); j++)
4 T$ D# [+ d& Z     {   . E) R4 g, B7 u' r  D! q" O2 J8 H
      totalEdges[j]->GetVertices(&vertex1,&vertex2);5 V) h% d7 B% B+ R' Q( h8 J  F& f$ Z
       ss <<"edges tag: " <<  totalEdges[j]->GetBody()->GetTag()<<"\t";
" {# u2 U4 P$ [# e/ L       ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";( {0 @5 z0 T, e: W% U" j5 ~
       ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n";
6 Z2 j( `  j" U/ n! P" O3 o9 L- L( |     }
1 T+ j( }3 g- g' z( h8 X, x/ J  q   ss <<"faces count = " << totalfaces.size()<< "\n";
0 Y! t; h+ F& l7 L3 v    for(unsigned int j =0;j < totalfaces.size(); j++)
7 |+ w, E% L, }" _( c    {  9 u4 }" K/ s6 B; W# @
     ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t";
/ h$ w; E8 ?/ f: g  Z& B. o/ K     ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";
: R  P. v2 f+ |( M1 f     ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";
" h" @1 ~! e# M: N) J3 m0 B    }+ H, V  `. e  S6 E
   ss <<"Features count = " << totalFeature.size()<< "\n";
, O+ ]; y* }: O3 B     for(unsigned int j =0;j < totalFeature.size(); j++)
" H  G: V; \8 h2 A: t+ T! ?* T    {  
- q0 v) J' o# t6 w5 S     ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";) O. ~2 ^9 U9 @7 P( b
     ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";
( J3 l  A) }& ~) Q6 I     ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";+ `" `6 Z* H0 B, e3 ]' }! J2 H- ?
    }
2 A5 L! b$ A9 \" g; w2 M' L  theSession->ListingWindow()->WriteLine(ss.str());
" \: c; W: |- R! E
# e0 s  q6 P, a! L
6 z3 I' ]" o( x$ {1 l4 t查询结果如下:- p7 B+ x: ]6 J
$ F7 m7 T$ t! u& X% z  {& s( r' A
1 ^6 m0 B5 j0 A  c( I
Get information from all bodies
2 U; x4 f4 P4 S) t. w3 jCYLINDERBodies count = 7
8 x% w4 X, U. X* y! K7 s2 Vedges count = 22  x0 K0 y/ o* x' o# a
edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100)' j4 H$ M. n& ^3 H8 a
edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0)0 [& J. B0 x' E% J, A4 Q
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)
; M- V1 ?" n7 o4 Vedges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0): H3 F1 e6 U! V- U4 l* x
edges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100)
9 b* N$ G/ l7 J8 Q% ]" oedges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)) ]/ a; k' }6 U1 L
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100)
; L! {  L$ S& X2 p  N7 O. y5 T! vedges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100)
2 k8 a' u3 a0 hedges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100)" T' A# k1 }3 P/ L
edges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100)! x8 q( u$ X. O' v
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100)
4 q; D( y4 W' R/ x0 c, h% |edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0)
9 V! r4 J. S- u0 _' R4 Ledges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100)
9 ^- n1 [0 K) _8 Z! @edges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)
  e4 ]4 t# Q( d8 \/ Xedges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)5 m8 u" r! c- n( L4 f/ A
edges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
, ?% C9 u' P% A" e+ Yedges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)% v  {8 W3 i6 u3 l9 x7 x
edges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)
, l0 f# A& N( D# m% i3 I# G# kedges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)& ?8 e9 _4 _, N2 W: X. ]3 f% @
edges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500)7 |5 t# F, z7 P# o; [6 \0 P) `
edges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200)  H# [% v6 I5 o
edges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)( \0 L+ e* I" ^7 G
faces count = 22
! d* u* j5 j6 m' @/ t! c. AFace tag: 41407 Face Type: 4 Face Name:
3 j+ F$ Z, m+ F2 H3 @Face tag: 41398 Face Type: 1 Face Name: 1 j  N9 _4 K6 ]6 G8 ]4 X- j/ j
Face tag: 41376 Face Type: 1 Face Name:
# Q5 X4 `2 H' a$ p9 L) i+ YFace tag: 41391 Face Type: 1 Face Name: 0 E0 q4 M% w$ m/ l; ?
Face tag: 41380 Face Type: 1 Face Name: ( b- S* ]! b7 H/ B2 F
Face tag: 41396 Face Type: 1 Face Name: 5 y! a" F6 m* e! E
Face tag: 41397 Face Type: 1 Face Name:
3 ?1 F2 W% \3 Y! X0 \3 iFace tag: 40995 Face Type: 2 Face Name: ! ~) u4 J8 H  z( b0 K
Face tag: 40965 Face Type: 1 Face Name: ; h" q" A6 y  P" H7 `: i
Face tag: 40997 Face Type: 1 Face Name:
0 V3 b6 Y& G' D! |* ?7 aFace tag: 41351 Face Type: 1 Face Name:
0 v6 F3 v! }. u# [2 HFace tag: 41352 Face Type: 1 Face Name: 6 T8 m4 ?; z' z
Face tag: 41353 Face Type: 2 Face Name: # p% K) [2 o6 O+ L# e
Face tag: 38479 Face Type: 1 Face Name: $ }5 I6 c& Y$ j0 Q7 F
Face tag: 38480 Face Type: 1 Face Name:
0 B% W1 E1 f8 g) [% CFace tag: 38481 Face Type: 2 Face Name: 1 e: t2 S! W: J/ [, y1 A
Face tag: 41207 Face Type: 1 Face Name: ) H" }  k( r, g5 \  S7 v  c
Face tag: 41203 Face Type: 1 Face Name: 8 o& a  `+ L8 J
Face tag: 41158 Face Type: 2 Face Name: 7 S& h! j- b: E3 }3 X3 d
Face tag: 40987 Face Type: 2 Face Name: & c+ x: k: Y/ S+ e4 S$ N
Face tag: 41010 Face Type: 1 Face Name:
- g4 g1 E$ p& X# @9 GFace tag: 41001 Face Type: 1 Face Name:
' o( f! Z- a' SFeatures count = 7( L% U* W7 d' H
features tag : 41280 features Type: SPHERE features Name: Sphere(17)2 }; f# @8 e  k- \
features tag : 41281 features Type: BLOCK features Name: Block(18)8 _8 A" w) y) j
features tag : 41307 features Type: CYLINDER features Name: Cylinder(19)
7 ?3 P0 b: g  A; V6 f8 Lfeatures tag : 41314 features Type: CYLINDER features Name: Cylinder(20)
: p/ o4 {( U5 Z8 n6 d8 gfeatures tag : 41322 features Type: CYLINDER features Name: Cylinder(21): B; u8 P8 f; ]6 r3 ~
features tag : 41330 features Type: CYLINDER features Name: Cylinder(22)- Q6 _% }7 S& ^4 q* y- b
features tag : 41338 features Type: CYLINDER features Name: Cylinder(23)8 U# m; J9 |  m* b, Q( C3 j# a
! ~( Q! k/ c$ ^1 h" f, B
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复

使用道具 举报

发表回复

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

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

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

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

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

    我知道了