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

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

[复制链接]

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

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

admin 楼主

2013-11-4 16:53:51

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

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

x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息
0 Y1 V: m5 s/ a6 K: c' A2 o+ @6 x8 q
9 B* g3 T) Q  n- c( ]% j5 m! o8 w6 Y: j0 ~+ S( t( a
  theSession->ListingWindow()->Open();$ S/ g4 A  q0 z, y
  theSession->ListingWindow()->WriteLine("Get information from all bodies\n");* U% }" H3 K$ O' h3 _& K
     std::vector<Body *> bodies;
3 `. R) e9 d" e4 u/ V  BodyCollection *bodyColl = workPart->Bodies();
6 n7 ^% P- a! ~, ?+ L  for(it = bodyColl->begin();it!=bodyColl->end();++it)  e4 a- M+ b6 P! L* {
  {5 |9 p+ [/ T4 W. [9 }6 [
   bodies.push_back(*it);) \1 M' ]; S1 R# R1 s& o+ y
  }" [5 H* P- E' h
  ss <<"Bodies count = " << bodies.size()<< "\n";$ z1 B) _: _' e9 G  e
   std::vector <Edge *> edges;- l8 R& T" J% O, F' s
   std::vector <Edge *> totalEdges;
9 r4 e+ p2 ]' g' n  }7 E$ x   std::vector <Face *> faces;
4 q* J5 `& S6 Y; m   std::vector <Face *> totalfaces;
, [$ l# F6 W, l! ~2 C' m   std::vector <Features::Feature *> Features;
; A! _: V( M7 h/ i# T   std::vector <Features::Feature *> totalFeature;
$ q- p- o, D5 N: ^% J" t   Point3d vertex1,vertex2;
1 v" a6 @! H" M8 S   for (unsigned int i = 0; i< bodies.size();++i)
6 h6 l' M/ U7 \* Q" t   {
8 h, T) X8 D) Z1 }. s    edges = bodies->GetEdges();
- n& H  E) N, U, h: C: _+ u    faces = bodies->GetFaces();  r% O# C& v- f9 I
    Features = bodies->GetFeatures();
" y8 Y- R% r: h* a$ b* t5 t4 N     for(unsigned int j =0;j < edges.size(); j++)
6 n- {, U( j+ G     {
2 n6 \+ a5 @5 `" h     totalEdges.push_back(edges[j]);1 z  N4 C; u: `3 p
     }# d/ W- K4 E4 |' D0 q
     for(unsigned int j =0;j < faces.size(); j++)
6 @9 j3 l2 _* e, G     {: t; [9 a$ O0 Y+ C0 r( W
     totalfaces.push_back(faces[j]);' P/ ]' W4 m& ^, k- F- }; q
     }
1 T5 ]; u0 b+ Z* {6 s* ]6 e      for(unsigned int j =0;j < Features.size(); j++)
9 I& |4 U' f3 ^6 {. e( o9 s7 \     {; }& j+ O  l0 d+ Y  F
     totalFeature.push_back(Features[j]);
' f+ ~- W+ u! t) r  }- O& }4 ?     }
$ }9 p8 p" A" ~7 v. S3 ~      , R0 I6 s: \9 Q7 P5 k  Q) Z
   }1 p2 R* P: G( g
    ss <<"edges count = " << totalEdges.size()<< "\n";4 ~' e3 v0 U& X. P
   for(unsigned int j =0;j < totalEdges.size(); j++)  |- A7 @/ g4 r4 p
     {   
7 H; K, Q" i' D! b1 }2 m9 h      totalEdges[j]->GetVertices(&vertex1,&vertex2);
/ c8 [# N5 }/ K. q( m       ss <<"edges tag: " <<  totalEdges[j]->GetBody()->GetTag()<<"\t";7 X$ a; p% r+ d7 y: S' U, O: @* k
       ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";
' [+ P- [. k" k5 J; `8 P" F' O       ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n";* M( N$ ~- w; G' ~' P2 X( ]
     }
+ r. A! X; D2 [( f   ss <<"faces count = " << totalfaces.size()<< "\n";
/ G1 V/ q: l$ [" T1 i1 E* t8 Z    for(unsigned int j =0;j < totalfaces.size(); j++)' n. R$ b4 U( t" }3 J- q" c
    {  ! T8 W, t5 x* }  w$ h
     ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t";  E% k" B4 X# a+ X1 P: |- A' O
     ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";
0 ~7 M7 m2 l9 r3 [: ?     ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";
+ _" ~% h' k5 X3 q5 H    }: I- G8 d# k; @9 [3 f" i: [1 J! P' P; M
   ss <<"Features count = " << totalFeature.size()<< "\n";8 V* Q' G9 `+ H
     for(unsigned int j =0;j < totalFeature.size(); j++)
1 X) b' k1 E! U7 }5 \, `    {  
" h9 ?* r. n' E) F     ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";) Z, W7 ~$ p0 Q1 f+ z& p
     ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";
3 R7 X9 G( k9 b2 ^$ o, z1 N     ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";3 E* {7 P- u  A" O( e& ^
    }
1 O5 E6 Q  E" z  ~  theSession->ListingWindow()->WriteLine(ss.str());
+ q+ D# ^8 ]$ T4 O9 D$ j& W) l# n" ]

, \% }2 V( p3 {  C% }+ Z7 @查询结果如下:
3 D9 H$ x) f2 `/ Y( w3 @: e5 o+ Z0 \$ `2 |; D5 C  `& E. H
9 h3 H( H) W4 R3 g
Get information from all bodies
' E# j8 {" q1 R) F  i7 L, `9 {% y/ X$ W6 VCYLINDERBodies count = 7
, D3 p7 b9 {5 F* h/ |! X" Uedges count = 22
3 l( f  B( G/ C& c6 d0 ^edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100)
" W6 M$ q- ?2 o5 P1 nedges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0)4 P% m3 j; ~) B% J$ c4 l+ _5 z
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)
6 X( b2 s( g' _' B9 |edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0)
& t! }! w6 N. Q) `: E3 Qedges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100)5 p- c( A4 T5 a6 X! `' K
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)
) m5 v8 v; l: s+ W4 {edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100)' P# a4 s) h; y- m, y
edges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100)
7 p4 h" I/ t$ d% f* {+ Tedges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100)' G$ {% q% D1 G' c6 W  C5 d- g
edges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100)" F: s2 C/ D/ y
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100)5 b- j3 L3 V0 L1 J/ r
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0)
* J( A* _$ z( jedges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100); ]/ Q0 H6 r0 S' O8 Y  F4 @
edges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)
7 Z* A! i6 k# }/ E: ledges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)
5 E# Y$ d% P. K9 ?/ n+ H  i% s3 o" Jedges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
. w/ Y- j# e/ m  r3 Eedges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)% [* Z' F4 @4 G# m& \
edges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)4 X7 t( `3 i8 v% I% {, [$ J
edges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)
$ a% E6 R( ~1 p6 Hedges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500)4 ?4 u9 V/ B: R) S
edges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200). j' |0 ~& p& m& B$ k; g% v; G$ l
edges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)
# ]  x0 e8 Z( _/ w2 F9 Hfaces count = 226 {" |) n. x% F1 d0 ]- I1 X: z
Face tag: 41407 Face Type: 4 Face Name: ! [4 p% G8 M/ @  U1 f3 V
Face tag: 41398 Face Type: 1 Face Name: 1 B7 a( A- l" u& v3 @
Face tag: 41376 Face Type: 1 Face Name:
) J: R1 Z; J' C- [2 R/ r3 `7 Z- \5 U8 `Face tag: 41391 Face Type: 1 Face Name:
$ h) ], |. [( k$ q2 M: c2 @Face tag: 41380 Face Type: 1 Face Name: 8 T8 A* D) N, {6 g0 w
Face tag: 41396 Face Type: 1 Face Name: 3 ~( m" y4 A# S- h0 ^
Face tag: 41397 Face Type: 1 Face Name: ) I) C5 Q' D  X$ U$ v3 O6 Q
Face tag: 40995 Face Type: 2 Face Name: 8 a; T+ B  g: W2 _8 ]
Face tag: 40965 Face Type: 1 Face Name: 4 U; N1 Y( J# @7 Z, ?8 P
Face tag: 40997 Face Type: 1 Face Name:
5 j% `  B0 t2 h) j8 R1 T$ Y; @Face tag: 41351 Face Type: 1 Face Name:
% `; G; T' l% XFace tag: 41352 Face Type: 1 Face Name:
. \, a% {) Z1 Y* Q8 x8 V4 `4 }* T$ SFace tag: 41353 Face Type: 2 Face Name:
6 Y# Y) l5 N! Z% K& x5 Q) }+ ?6 _& ~Face tag: 38479 Face Type: 1 Face Name: 8 ]. P: c0 o" D0 Q2 O9 u0 v
Face tag: 38480 Face Type: 1 Face Name:
5 ]  d5 f6 w; N, N, r4 p& n& NFace tag: 38481 Face Type: 2 Face Name: ( R1 S7 t- Y. C5 ^, `4 V: ^
Face tag: 41207 Face Type: 1 Face Name:
; d% t" R5 e5 `Face tag: 41203 Face Type: 1 Face Name: 0 u! P* x: g" e8 I! R2 |7 W
Face tag: 41158 Face Type: 2 Face Name: ! J3 H7 p, ?" j8 A, j
Face tag: 40987 Face Type: 2 Face Name: & ~* N4 Z. u5 f; S6 H7 Q! O
Face tag: 41010 Face Type: 1 Face Name:
7 F8 g+ s6 g3 F% _2 z' \9 p& |1 [Face tag: 41001 Face Type: 1 Face Name:
; m4 c, m5 k9 ZFeatures count = 7
- D) l  N: k1 W9 K) O; U5 yfeatures tag : 41280 features Type: SPHERE features Name: Sphere(17)$ C" K; F# w- q2 _3 L( T
features tag : 41281 features Type: BLOCK features Name: Block(18)
0 B1 b) {6 v2 n7 _! l. h: b5 Mfeatures tag : 41307 features Type: CYLINDER features Name: Cylinder(19), ^" M: I4 }! I" a/ h( \1 P
features tag : 41314 features Type: CYLINDER features Name: Cylinder(20)- k6 p& |: G- W# n
features tag : 41322 features Type: CYLINDER features Name: Cylinder(21)/ B) {5 y! C! a; E5 q
features tag : 41330 features Type: CYLINDER features Name: Cylinder(22)" v0 C6 C  C8 |3 t
features tag : 41338 features Type: CYLINDER features Name: Cylinder(23)
: Q  l3 v& V; e) c/ \3 v2 F( c7 d1 B2 B: s$ w9 x" y
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了