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

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

[复制链接]

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

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

admin 楼主

2013-11-4 16:53:51

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

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

x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息9 O  d1 j! h( w3 D3 E  D+ v
7 G' X5 g+ s. h6 ~: n8 M
3 ]! m- u7 y/ i0 l  M0 |  _
  theSession->ListingWindow()->Open();( G3 T7 M1 Q: g/ z! g
  theSession->ListingWindow()->WriteLine("Get information from all bodies\n");9 p' t4 a9 @$ t) z# r  I
     std::vector<Body *> bodies;# }9 ?+ w3 @. d; a& ~4 {2 v+ t
  BodyCollection *bodyColl = workPart->Bodies();
0 ]2 l  b0 o, |, \; j4 m7 ^! C2 c# F  for(it = bodyColl->begin();it!=bodyColl->end();++it)
; Z% Z9 [, e1 D  {- }0 L1 r8 c7 \7 `
   bodies.push_back(*it);
9 T4 X- J/ ]8 ~3 f  }/ Y$ {6 j7 ]* I, N2 l2 A' Q1 W
  ss <<"Bodies count = " << bodies.size()<< "\n";
0 l, |4 P' t, U+ k   std::vector <Edge *> edges;5 n3 D3 ]( e7 e5 p6 T
   std::vector <Edge *> totalEdges;. L; D# w0 j7 [) E$ h
   std::vector <Face *> faces;: [3 a: k) S/ V2 g9 G9 }
   std::vector <Face *> totalfaces;
/ j; Z# l- c  ]) U- p- R   std::vector <Features::Feature *> Features;
7 {$ ~2 c& m* ]   std::vector <Features::Feature *> totalFeature;
; v8 e  Q$ L3 j   Point3d vertex1,vertex2;
! A+ E: i: }" D   for (unsigned int i = 0; i< bodies.size();++i)
. u: a; z; F. \   {
8 q# U9 O  x7 P* {9 B- t    edges = bodies->GetEdges();6 k3 M( O( u" {: s% m) i
    faces = bodies->GetFaces();7 ?3 p- l* H6 ~; M" Q- v- W
    Features = bodies->GetFeatures();
3 v, M, K- K8 u, @8 P1 R) @     for(unsigned int j =0;j < edges.size(); j++)
+ C: o) ?  r3 }- M6 b8 L1 _5 G     {# K  d( s8 t/ A2 Z. K
     totalEdges.push_back(edges[j]);
9 v8 R  K8 I1 f8 D9 U     }
2 P7 u& Y* J. ^; b     for(unsigned int j =0;j < faces.size(); j++)1 O1 l; F( y- h% J
     {
/ a' P2 c0 s. B     totalfaces.push_back(faces[j]);
2 E4 G  f# \% S     }
8 c2 {7 K$ H- {9 k& T: F5 ]9 j      for(unsigned int j =0;j < Features.size(); j++)
1 l9 z7 k, k& k  q( G     {
3 o$ V# p6 T9 A' ]/ b5 W+ C     totalFeature.push_back(Features[j]);
! a5 N' U/ p$ W/ g4 K, f; L     }+ D, A( `9 b% f% Y7 _  w3 w6 Q2 k( t
      
2 S6 @5 W& t$ Z6 G) e! n# ?9 c   }* H) |, Q- @, ?4 b0 l9 q
    ss <<"edges count = " << totalEdges.size()<< "\n";9 r; e1 C1 k# u! o0 a
   for(unsigned int j =0;j < totalEdges.size(); j++)
8 Y8 q! d4 M) M1 I3 m     {   
6 ^1 n; L+ _' m$ i1 F7 w      totalEdges[j]->GetVertices(&vertex1,&vertex2);
# g+ l  R  _+ ?. ?+ O9 S       ss <<"edges tag: " <<  totalEdges[j]->GetBody()->GetTag()<<"\t";
( T. W: z3 r  v8 ~6 |       ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";
) d% Y  r: u" J) P2 m( X       ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n";5 N3 J1 o2 {/ N1 l! z# p, r
     }$ C  N/ p! L/ `- J% E, j$ s
   ss <<"faces count = " << totalfaces.size()<< "\n";
' f9 ]! w! f# d* s- s    for(unsigned int j =0;j < totalfaces.size(); j++)
+ X- ^2 Z9 S9 {4 ^- x    {  
4 y  ^0 s% V0 l/ h+ h' B( v, F     ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t";' j1 Q4 O( b) ]9 g' v# t9 Q2 I
     ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";* w% {1 P; r" N
     ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";
$ B) L$ f' T8 Q; \& q    }
& k3 z; S8 u6 m! c! h$ C/ T   ss <<"Features count = " << totalFeature.size()<< "\n";
: L3 a* J8 E% w$ j     for(unsigned int j =0;j < totalFeature.size(); j++)
- X* \8 l+ e5 s6 x. r* \0 ]/ d$ a    {  
: }; |& E# j6 u4 F     ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";: f1 l; o* g  a8 o
     ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";
: G- W0 ^: U1 A* ]     ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";
, I2 k0 q; W0 \# L: a    }3 [+ e* m. }1 w( l
  theSession->ListingWindow()->WriteLine(ss.str());, Y2 i5 V: Q( `4 w' a1 ?& |  e  a7 Y

! `0 Y' L+ H  ~, `* N: k, I  U/ b' S3 B0 p/ j1 j# L5 w
查询结果如下:
2 A5 H7 Q9 X) I" ]  c- d9 e3 J
! ?/ f% Y: r/ K) h- a* m5 O; Q5 f& }1 A7 u
Get information from all bodies
, R* r; U/ [5 ?6 uCYLINDERBodies count = 79 N$ C% d! a" p- q3 ~  K+ M
edges count = 227 a, w$ A! J+ n8 K$ |$ u
edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100). R6 P% J$ ^. C8 `
edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0)% M: g! R2 k6 B# [' t" D" {9 y
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)5 v" e: L; S  z% z0 n" L& a
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0)
: b. w; j+ h+ z' X- J6 z) M* Xedges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100)
6 f, D5 C- A0 U% Y% N& i2 y: vedges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)2 \3 X) I8 ~2 B
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100)
  S& V) G& B: \edges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100)
1 C$ n2 }) W! p" c" r/ Q) kedges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100)1 J( ]4 f% ?9 H
edges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100)
' e3 E6 F7 H+ n$ vedges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100)
# Y' j& c1 Z1 N; R. pedges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0)4 E* P5 X, H# \' z( Z
edges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100)
( A# ~( K1 x& fedges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)
# C, k1 F8 V; A# C7 F9 @/ sedges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)
7 v0 W8 I4 m- D. I' m4 nedges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)  w4 O" L2 z4 A+ j$ S
edges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)8 y' \: u  ^" f
edges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)8 @7 R+ C2 N1 \) q
edges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)
  u; c* D" Q. o' a. `% \4 jedges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500)
5 ^2 S( ]  L; Oedges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200)$ e9 l" K+ Z2 l
edges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)3 }" r. D6 q: I1 q2 [
faces count = 22
* @+ `5 e: G8 G' o* a6 ~( C/ OFace tag: 41407 Face Type: 4 Face Name: ( k+ E  R8 q% `, x, B2 f# j
Face tag: 41398 Face Type: 1 Face Name: & P* {6 k  l. }9 `& ?. Q
Face tag: 41376 Face Type: 1 Face Name: ! u- ^- O3 I9 v% `( h; Q
Face tag: 41391 Face Type: 1 Face Name:   L/ y3 E: N% R5 t/ F3 F
Face tag: 41380 Face Type: 1 Face Name:
0 T4 B7 d9 Z  d1 B3 O5 h4 FFace tag: 41396 Face Type: 1 Face Name:
- g7 c4 M4 Z, u# b# H8 GFace tag: 41397 Face Type: 1 Face Name:
& z( e# S6 a+ h- k/ e. sFace tag: 40995 Face Type: 2 Face Name: 9 `! ]4 w+ a6 D; U9 B& R3 r
Face tag: 40965 Face Type: 1 Face Name: - Z8 r, \7 h, j8 g0 P3 N- b$ \4 W, G
Face tag: 40997 Face Type: 1 Face Name: $ t# A! `$ `7 S- ~
Face tag: 41351 Face Type: 1 Face Name:
; w6 F2 X% }- r0 _8 d5 ~Face tag: 41352 Face Type: 1 Face Name: 3 ^, F% ]( u' _' Q
Face tag: 41353 Face Type: 2 Face Name:
5 U6 d2 L, E8 P* z( }% P0 m* {& jFace tag: 38479 Face Type: 1 Face Name:
8 Q7 V$ k5 S( R& LFace tag: 38480 Face Type: 1 Face Name: 4 x7 g3 P, M! H- {
Face tag: 38481 Face Type: 2 Face Name: 4 f' y6 C# p$ b" B8 n& F5 N! @/ z
Face tag: 41207 Face Type: 1 Face Name: 6 l# _; ]3 q8 N' a; l
Face tag: 41203 Face Type: 1 Face Name: , W' ~+ N, L: }+ F
Face tag: 41158 Face Type: 2 Face Name:
7 ]; ]$ @6 v4 ?# g; Q, VFace tag: 40987 Face Type: 2 Face Name: 4 ~. w9 q8 x9 }6 u. ]2 X# [
Face tag: 41010 Face Type: 1 Face Name:
& \1 E3 y& v/ M' Q% c/ GFace tag: 41001 Face Type: 1 Face Name: 9 F7 [2 {, Y# v" |
Features count = 75 T) e! }! B( p
features tag : 41280 features Type: SPHERE features Name: Sphere(17)
9 _6 B' `0 V; G/ ?7 o( q& B9 L% Ofeatures tag : 41281 features Type: BLOCK features Name: Block(18)6 W( }. X8 T( Q: P; U% s
features tag : 41307 features Type: CYLINDER features Name: Cylinder(19)/ H" O; V# w5 ?
features tag : 41314 features Type: CYLINDER features Name: Cylinder(20)6 u: X2 B# h# O) r
features tag : 41322 features Type: CYLINDER features Name: Cylinder(21)
1 Z. p. L7 A6 v" afeatures tag : 41330 features Type: CYLINDER features Name: Cylinder(22)) \% A4 N0 H8 d: d& O
features tag : 41338 features Type: CYLINDER features Name: Cylinder(23)1 @+ O+ u& p# q; G0 U

7 f& x* w+ a8 X. p
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了