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

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

[复制链接]

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

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

admin 楼主

2013-11-4 16:53:51

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

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

x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息  ]! m5 ?$ d5 s0 W8 q

+ z# n1 u" c; u; |8 a# n' I( l% j2 P# q9 C% ^/ c
  theSession->ListingWindow()->Open();! t+ ?$ g; ?3 l, F) l. b, K9 u
  theSession->ListingWindow()->WriteLine("Get information from all bodies\n");( ^' h* |2 p8 k0 X
     std::vector<Body *> bodies;
! t8 f6 n$ v4 M) F  C  @# S  BodyCollection *bodyColl = workPart->Bodies();- P$ s* _5 o' ?2 _& \' I& H8 D% M3 t& T
  for(it = bodyColl->begin();it!=bodyColl->end();++it)
! D; h" E: ~/ ^: k# ~  M9 e  {
0 w4 F4 d; l( k: S6 ]4 y( B   bodies.push_back(*it);( O/ `+ v) {! r- R' T$ n
  }- |1 a) n, t  i) z
  ss <<"Bodies count = " << bodies.size()<< "\n";1 x( z; m* O7 f$ X8 \
   std::vector <Edge *> edges;
6 y/ L8 O% D( F4 g   std::vector <Edge *> totalEdges;
! e) R7 c1 Z- T) F5 Q7 m0 e   std::vector <Face *> faces;  a+ |6 A4 a& C; s. |  z. C
   std::vector <Face *> totalfaces;! b$ O3 Z* }( ~2 }3 E$ ^1 N
   std::vector <Features::Feature *> Features;
! J4 r8 ^! M% T6 a" z6 o   std::vector <Features::Feature *> totalFeature;" i  H# [7 Z; d
   Point3d vertex1,vertex2;+ P9 W9 z1 x, ^! c7 K
   for (unsigned int i = 0; i< bodies.size();++i)
" h3 x6 ?1 Z! ~. g: m. N   {
8 r7 C* \" C& p; _6 y    edges = bodies->GetEdges();$ v6 Z( I+ z4 o( x8 `: X
    faces = bodies->GetFaces();( H4 T+ q2 _' m, Z) R  n
    Features = bodies->GetFeatures();
- Q- O0 w; Z9 N' B0 a     for(unsigned int j =0;j < edges.size(); j++)
. r) p) S' S, k3 F     {
( z& V( M8 p( T3 s6 D* i     totalEdges.push_back(edges[j]);
1 B: d2 k' _# a9 b  T, L" ^/ @     }$ H6 Y6 K6 k; N# w, ]$ O7 w9 c# g
     for(unsigned int j =0;j < faces.size(); j++)
$ v, ^; M3 a/ ]& Q* {     {
" e" }7 l% Q7 S' M1 m- F     totalfaces.push_back(faces[j]);
  Y0 t2 G) ?# _; o     }6 I3 {' A- g2 M3 b8 E
      for(unsigned int j =0;j < Features.size(); j++)8 m$ s7 Q% c' U4 P7 x# G
     {
# a2 i$ j  ^8 R3 {     totalFeature.push_back(Features[j]);7 ~3 g3 v) @& s0 I! G* m) b5 [% u
     }+ G9 h, X6 k. s2 E5 E! ]+ I
      + d7 Y7 x5 d) [2 s( o" O
   }
1 [6 i5 G: G, Q# P    ss <<"edges count = " << totalEdges.size()<< "\n";* F. G! N  s$ U9 [) U4 T% c
   for(unsigned int j =0;j < totalEdges.size(); j++)
+ K5 u: Y9 g3 O+ r/ U: N  q! H     {   ) A& X1 U' `- I: e7 A# ]
      totalEdges[j]->GetVertices(&vertex1,&vertex2);
2 W! \2 X3 O- z$ o1 D       ss <<"edges tag: " <<  totalEdges[j]->GetBody()->GetTag()<<"\t";5 `7 E1 @2 f& o9 F, Y, A
       ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";
. {  D) e, h8 k" P- S" V" L$ ~       ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n";) E+ v" E0 g8 o1 ?1 v
     }, x: a$ R4 ~/ K( G
   ss <<"faces count = " << totalfaces.size()<< "\n";
( ?2 @% M) ?& m6 o& {( k# V+ F" x    for(unsigned int j =0;j < totalfaces.size(); j++)% b$ g& a/ N: {  Q4 M( m
    {  4 |, ~2 k3 J/ A- Z5 c
     ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t";% ^( T% e* L" s# A/ h+ R) O& y
     ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";
! h& }9 W0 y* A6 D' p$ A     ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";  f4 n* M1 e3 Q  f& i# i1 n
    }" J6 L" L  D- [* ]7 g' ^0 e
   ss <<"Features count = " << totalFeature.size()<< "\n";
' M0 [' S6 u1 f. @* y     for(unsigned int j =0;j < totalFeature.size(); j++)8 N& ?0 _# z, F, ]7 x( _. _1 \  C/ g
    {  . W* n8 {7 ]  o+ t& \
     ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";# z+ m( V8 L/ n6 K* R
     ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";, D* p) h$ `0 a- n" l
     ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";/ I( ?& O  _5 E5 n( u
    }
" C+ r# k; d( d( e  theSession->ListingWindow()->WriteLine(ss.str());" Q& L8 {- v8 ]9 v7 P, |
. h  X9 `9 j' _7 Z% O0 m
9 Q" |' C; W2 C' ]) h$ ?
查询结果如下:+ Z' ^/ g' ]6 Y. q8 k, z  u
( C# P* @8 N5 P
$ V$ h+ r# n! H# a) R3 g
Get information from all bodies
- o$ K% e5 h6 ?3 w; q" SCYLINDERBodies count = 7$ `8 |- }' b! r* e3 J% M
edges count = 22
6 e5 \6 ]" P5 X0 r7 Xedges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100)
7 s6 F: ~/ M4 y+ m2 _8 oedges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0)
$ ?" [) A; ?3 g* Q* C. v. Wedges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)6 [) @+ T' S4 _! z/ x, c
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0)% U: o: C7 l" c4 g  T
edges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100)' ~' S6 [. }; j6 F5 j& Y1 F
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)6 Z5 X6 A: I& P3 W8 z% i+ M0 ]
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100)$ J, j1 J% U1 Y! L9 Y) a  e
edges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100)
- ^4 s' k4 S. S; J5 Y; R: x& Iedges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100)
, B3 a- O; u. f9 d  q/ Eedges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100)
: a0 C- E- w0 R: xedges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100)" T  M2 r2 V- u: T8 ^
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0)" e2 l1 h) c2 h' y/ o. M
edges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100). d, \& K# X2 r" ]
edges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200). I- \0 A5 ~1 K3 p2 u# d
edges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)5 k& V  x) W* H1 s
edges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
0 s+ s# a- q4 t+ T/ [7 }edges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
4 E1 B  Q  Z3 ?2 A! K3 l+ \edges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)' m0 {/ z2 h$ o: K5 B& I
edges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)4 `9 i) B3 ]. d8 u7 \4 v4 Q
edges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500)- L% p! n  P# S- `
edges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200)5 ^0 V, }4 N, k
edges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)
/ Q4 ?  @/ v( U7 \4 Y* C& s. hfaces count = 22
! v4 I8 w/ G# `6 ~0 [: sFace tag: 41407 Face Type: 4 Face Name: % }: m' z- @! K9 i$ n( x, i  n% h( a
Face tag: 41398 Face Type: 1 Face Name:
7 i4 o* B" G* O& y! i+ |) P  nFace tag: 41376 Face Type: 1 Face Name:
2 O5 k* `+ O8 i* y$ xFace tag: 41391 Face Type: 1 Face Name:
" p% D' b( R5 o/ CFace tag: 41380 Face Type: 1 Face Name:
0 c; W0 i: L1 S$ ^& S& pFace tag: 41396 Face Type: 1 Face Name: * u- B2 z; P6 ]7 E6 i  M6 l% c2 h
Face tag: 41397 Face Type: 1 Face Name: + h9 G2 k, g7 @1 v8 v9 ?0 m
Face tag: 40995 Face Type: 2 Face Name:
6 q! i8 H7 C5 ZFace tag: 40965 Face Type: 1 Face Name: : e, x! Z5 E' r: l9 K
Face tag: 40997 Face Type: 1 Face Name:
* V  Z% `5 m' s) @: z, rFace tag: 41351 Face Type: 1 Face Name: : J- x5 [" F, R; H. \: x3 R- E' z
Face tag: 41352 Face Type: 1 Face Name:
* x/ Z% z* a$ g2 ^6 R$ I+ }" UFace tag: 41353 Face Type: 2 Face Name:
# J. O# r+ ]6 o( O5 lFace tag: 38479 Face Type: 1 Face Name:
+ G" C% H; B1 W" kFace tag: 38480 Face Type: 1 Face Name:
2 A- m+ h: L- @7 @Face tag: 38481 Face Type: 2 Face Name:
) y- _  ~8 [( O+ W- y' f. I, tFace tag: 41207 Face Type: 1 Face Name:
! o  z9 @6 |, o/ X7 D! F3 m, t' iFace tag: 41203 Face Type: 1 Face Name:
( V7 @  u- q) E& m+ PFace tag: 41158 Face Type: 2 Face Name: ( e$ F' A- |7 W4 |
Face tag: 40987 Face Type: 2 Face Name:
: l" ]4 s, Q$ f# W/ O. YFace tag: 41010 Face Type: 1 Face Name:
# [/ c$ R3 a" T! q3 }; y( \+ |# eFace tag: 41001 Face Type: 1 Face Name:
7 a! Z4 j! u% q4 fFeatures count = 7! L4 X6 b. E8 A
features tag : 41280 features Type: SPHERE features Name: Sphere(17)  H1 L6 q+ d7 m) n2 i- g
features tag : 41281 features Type: BLOCK features Name: Block(18)
$ Q- f* v6 H* M! m+ H0 t) G# G  Ifeatures tag : 41307 features Type: CYLINDER features Name: Cylinder(19)9 s% ?0 Y5 f% d, L7 f
features tag : 41314 features Type: CYLINDER features Name: Cylinder(20)
& G3 F" D3 n9 o7 N+ sfeatures tag : 41322 features Type: CYLINDER features Name: Cylinder(21)+ P0 u) |. ?6 d" H6 p/ U
features tag : 41330 features Type: CYLINDER features Name: Cylinder(22)
4 t# J2 E  x( w& l3 z& Efeatures tag : 41338 features Type: CYLINDER features Name: Cylinder(23)
# U' k" T( F& ^3 l, H
8 F( f* R- r5 r/ Y
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了