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

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

[复制链接]

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

2470

主题

1275

回帖

8万

积分

管理员

PLM之家站长

积分
82162
QQ
发表于 2013-11-4 16:53:51 | 显示全部楼层 |阅读模式

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

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

x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息$ h* ~0 P- t9 r. K4 L
- _8 b& ~8 ]$ |2 Q/ W2 F! L
7 d: K. p! H) U! H0 o
  theSession->ListingWindow()->Open();
7 h  x. t  L% K  o+ s) e( e  theSession->ListingWindow()->WriteLine("Get information from all bodies\n");
$ @- Y$ A$ y: C     std::vector<Body *> bodies;) `, }" {: t4 i/ h5 K1 ~+ _; X/ Z
  BodyCollection *bodyColl = workPart->Bodies();
& i# G0 E7 a/ @' E# o  for(it = bodyColl->begin();it!=bodyColl->end();++it)' p% m3 {) z8 W+ p# ~
  {
) p/ T; V, C0 F$ S0 W8 q   bodies.push_back(*it);5 ^2 h5 y. F$ `0 V3 }! O9 L
  }
* ]- S' b# z9 A' G  ss <<"Bodies count = " << bodies.size()<< "\n";
" T% W7 Y3 I+ w6 h+ z8 R, }$ ^   std::vector <Edge *> edges;9 A& J- f# G  Z% N* t6 v
   std::vector <Edge *> totalEdges;4 y! e4 z/ u: P1 ^1 J( _
   std::vector <Face *> faces;
/ ?: O& L2 f# v, x( [& \   std::vector <Face *> totalfaces;
0 w2 w8 u3 ^/ G8 w   std::vector <Features::Feature *> Features;
% ~% U% y+ S6 Q1 P3 D   std::vector <Features::Feature *> totalFeature;
5 j* T' q7 x  q2 t$ r4 z+ t6 l( h  }   Point3d vertex1,vertex2;
; A: I) Z0 ~6 Q* [6 I8 y   for (unsigned int i = 0; i< bodies.size();++i)
" Z  X" l8 E4 s+ {1 ~   {! b3 Q9 Q# \8 ]9 `7 }& d
    edges = bodies->GetEdges();
9 Z0 z: O/ H- X8 k8 n' F    faces = bodies->GetFaces();% T" g" z' ~4 j6 r
    Features = bodies->GetFeatures();
9 d" c$ s  A* m7 e     for(unsigned int j =0;j < edges.size(); j++)" E5 @% e9 R# F. J3 N
     {
6 H' _4 \) V- n3 w6 {/ A9 |6 r     totalEdges.push_back(edges[j]);
; c4 z: I- O, R5 I" O% W% \6 X     }
, U0 Q) U! i1 F4 {" Z     for(unsigned int j =0;j < faces.size(); j++)
4 r4 _: l7 I$ H, H4 V9 g2 o! A: Q" `     {" `% O7 a( l% C
     totalfaces.push_back(faces[j]);
2 h% k2 H/ E1 ]! p' b     }# \' W, n! D: {# e, Q/ n: N# z
      for(unsigned int j =0;j < Features.size(); j++)1 c8 y. p1 b3 d5 N* u) U4 L
     {. l6 v, l# E2 Q  P9 C  a$ |5 p
     totalFeature.push_back(Features[j]);
: f5 t* y8 J: f5 i; o" V; j1 t     }( m* }1 h& V6 u1 }. J8 x
      6 c1 M! i* N3 Q9 G
   }5 }8 q: e$ ?5 \0 N0 S0 ^  x$ u
    ss <<"edges count = " << totalEdges.size()<< "\n";
& g0 }& I. T3 _1 ~7 L+ \/ R6 D* B   for(unsigned int j =0;j < totalEdges.size(); j++)& Z/ o, l3 s1 u0 C3 J- y
     {   
: q. [) J2 w! P* V  I      totalEdges[j]->GetVertices(&vertex1,&vertex2);; W* S3 h2 {% x2 c% h
       ss <<"edges tag: " <<  totalEdges[j]->GetBody()->GetTag()<<"\t";
6 ~( F  F( h: U( s       ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";, b! H; }4 L) n  D
       ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n";7 k1 o1 Y! p, v+ R
     }6 I; Y8 N6 t. ?0 a  o6 g
   ss <<"faces count = " << totalfaces.size()<< "\n";
( G* t0 G! H9 [' X3 V' b    for(unsigned int j =0;j < totalfaces.size(); j++)6 [; D3 m7 ^8 _1 k/ V" W9 h+ l
    {  , a0 Q* D0 e" z6 c0 ~3 ^
     ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t";5 e; H2 ]* g% D# k+ l
     ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";: {1 L' L( `! R
     ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";
3 N8 V4 }: Z% F8 q* Z) p8 r    }  d) a' c- X) O5 `1 q. D% m
   ss <<"Features count = " << totalFeature.size()<< "\n";, T! L0 y# [, x. p% x9 z6 |/ M
     for(unsigned int j =0;j < totalFeature.size(); j++)
4 v5 V1 y7 O8 H! ~3 o. U6 {* |    {  - T* y2 H" [7 h- l( c) t
     ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";
% |3 l) E+ J' g" _0 l- @: X- u     ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";
. A+ e4 H' u6 A1 {6 W* c% _, {4 ~     ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";
6 H$ V( L9 M1 `; u. F5 j3 F1 I* K    }: [+ \0 P% ?9 C& i, ]7 q
  theSession->ListingWindow()->WriteLine(ss.str());
7 V  ~% R% {7 P3 [# H+ J7 e# w: T; w1 o3 \! o/ g) i& M
! B% l( D8 y. ^: P
查询结果如下:
- P3 @, T. Z7 ~( J; W. ^1 I% E1 Q
* a5 U  F+ Z7 e2 @$ `9 H# _6 D& l1 b2 R' p2 p
Get information from all bodies
; {6 j  K+ X# d7 dCYLINDERBodies count = 7& G! t2 G) R. b
edges count = 22+ \- ^* x9 J5 D! c2 l
edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100)
, w6 s) V/ \# L( D" @edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0)% t6 O% K- A1 R2 F6 U5 [/ P
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)
  A# }# A* W' ]3 |edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0)3 d8 P' B" l2 l3 _
edges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100)
( \  @; r3 w0 E% d: ?0 F! ledges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)
7 d. n5 s: w5 c- |edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100)
' |* h$ }( c# w9 d6 J! eedges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100)
3 A% U! u* ~& p4 p+ y7 u) w9 `edges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100)
0 r. b( c  g  c2 v. k" r2 L( jedges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100)% \" p$ R  t$ \& S# E3 G" s+ l
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100)
8 k, M+ |" g# z" N4 z) jedges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0)4 q& P" E7 E& h2 J! J% U) p
edges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100)
' D, W  K( _: H& A! Oedges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)/ F2 T  D# L0 S' m( P
edges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)
# t$ a; F$ `( ~6 Zedges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
0 j! e& V! o3 _+ Dedges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
6 A& H% B: H$ C- b7 i+ ]. C. D4 Cedges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)
1 y( I1 N8 R# l, F# Q9 bedges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)
! Y  u0 V+ H. E' {( p8 m- ^edges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500); Y7 _7 ?/ Z9 q+ c# z6 |( u
edges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200)
' d# z& L+ Z/ V/ F2 a1 O( K* N  \edges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)
& Y: W: C3 A' M5 Bfaces count = 22* n, g5 I+ J1 E* r8 \! A
Face tag: 41407 Face Type: 4 Face Name: - }* @1 q1 R( n) C8 _: c
Face tag: 41398 Face Type: 1 Face Name:
1 A1 M( z  |* ^. N/ T8 OFace tag: 41376 Face Type: 1 Face Name: 1 x3 B  O! B, U# V' c
Face tag: 41391 Face Type: 1 Face Name: 4 _8 u6 B% r2 \9 d
Face tag: 41380 Face Type: 1 Face Name: 9 m! A, I6 ]9 y5 U7 z) p- j
Face tag: 41396 Face Type: 1 Face Name: / m2 L1 x! L8 ~4 j" t9 m5 U% b4 K* Q
Face tag: 41397 Face Type: 1 Face Name: ( i0 R3 M7 X; u6 V' U1 t' j7 z6 U3 x1 W+ e
Face tag: 40995 Face Type: 2 Face Name: , v6 {: d  o' S4 r* c/ y
Face tag: 40965 Face Type: 1 Face Name:
5 |$ i% u: N/ k! V4 [  h; j# R! C" f6 zFace tag: 40997 Face Type: 1 Face Name:
, ^( C$ r5 p% s4 c/ ZFace tag: 41351 Face Type: 1 Face Name:
( N& ~# Y0 T: \( _Face tag: 41352 Face Type: 1 Face Name:
+ T8 E3 }1 W3 L& g! @: |: b4 CFace tag: 41353 Face Type: 2 Face Name:
; c( Z: ^# g- A' {% o: NFace tag: 38479 Face Type: 1 Face Name:
8 f7 ?! e" x  b2 I2 e8 z" Y3 o! l/ nFace tag: 38480 Face Type: 1 Face Name:
" D. _3 u$ [! W+ c& v; LFace tag: 38481 Face Type: 2 Face Name:
( {4 S) e7 S+ x$ y* W" L3 _Face tag: 41207 Face Type: 1 Face Name:
- T6 D# W# p6 v6 P) \, x5 F/ qFace tag: 41203 Face Type: 1 Face Name:
4 r2 A$ ?+ G& E* S- `' J  p4 ZFace tag: 41158 Face Type: 2 Face Name: + F, C& e9 C% I. T4 B3 q' f
Face tag: 40987 Face Type: 2 Face Name:
- }4 n: L  F" e* @2 ZFace tag: 41010 Face Type: 1 Face Name:
+ v' q( O, f1 R- p, o: TFace tag: 41001 Face Type: 1 Face Name: 4 Q9 S$ \; O- G  g: G; q! j7 Q
Features count = 7- ~. ?2 l- p$ n0 M  k( L
features tag : 41280 features Type: SPHERE features Name: Sphere(17)$ p  f5 O/ n$ Z; f. u# s/ G
features tag : 41281 features Type: BLOCK features Name: Block(18)" p7 W0 e- Z; e  l6 |$ D. G' ~: d
features tag : 41307 features Type: CYLINDER features Name: Cylinder(19)
: j* n3 N6 d! X) T7 L1 s0 K. H# wfeatures tag : 41314 features Type: CYLINDER features Name: Cylinder(20)
, J; s5 q0 s5 Vfeatures tag : 41322 features Type: CYLINDER features Name: Cylinder(21)
4 @. y6 W6 t4 R, P" h- _. kfeatures tag : 41330 features Type: CYLINDER features Name: Cylinder(22)- O0 W5 N' {) L1 P
features tag : 41338 features Type: CYLINDER features Name: Cylinder(23)
9 k# c$ m! K8 p! D" F- n0 X( `9 n6 r: n% w" b8 V  N
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了