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

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

[复制链接]

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

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

admin 楼主

2013-11-4 16:53:51

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

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

x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息6 e1 m- E! b, b1 s1 m

1 n8 c0 f" j( F# q3 m, o' H7 A9 C! d+ N6 X3 ?% C, C
  theSession->ListingWindow()->Open();
7 c. R) v+ n+ p' Q4 P  theSession->ListingWindow()->WriteLine("Get information from all bodies\n");
1 P) f, }, O2 G4 f: @- o: v     std::vector<Body *> bodies;# o: L/ r3 J. L+ U$ l
  BodyCollection *bodyColl = workPart->Bodies();
, L/ V3 F1 G4 z6 n. X1 A  for(it = bodyColl->begin();it!=bodyColl->end();++it)
# `$ i7 ~/ }. Y( `( L  {' Z$ y7 c8 g2 C* Q
   bodies.push_back(*it);
/ a: C; x% T* B5 s( a' f  }
& W2 ^& w1 n" n2 I) |  ss <<"Bodies count = " << bodies.size()<< "\n";
# S1 u4 y( l5 Y5 T   std::vector <Edge *> edges;0 o1 N- d3 \1 A9 ?. G; D' Q
   std::vector <Edge *> totalEdges;
$ r7 N3 I" w/ v- X# q* x   std::vector <Face *> faces;
/ f0 D) P2 F/ J+ N2 x   std::vector <Face *> totalfaces;' }2 r: z" s9 r
   std::vector <Features::Feature *> Features;
# I& y8 M) H& R" E* N. S   std::vector <Features::Feature *> totalFeature;8 M( H3 S: i: |, m# r3 L, W, ^3 u
   Point3d vertex1,vertex2;4 K) Z! @; Q2 V
   for (unsigned int i = 0; i< bodies.size();++i), y4 t" i: {. h4 D  w! Z
   {9 ?* J" s! {* L6 Q2 x
    edges = bodies->GetEdges();8 s, I- N5 _& l$ C9 Y6 J
    faces = bodies->GetFaces();. j7 @- o2 i/ U  v( _1 v. P
    Features = bodies->GetFeatures();
" B0 Y5 S% W! L7 e+ C1 o0 N" t0 [3 x     for(unsigned int j =0;j < edges.size(); j++)
7 s* V. {4 @/ e! q+ h& O: C     {
+ x7 h7 e  v) \" Y     totalEdges.push_back(edges[j]);6 b2 V7 @& n6 U9 E. G; M" J
     }2 [" {, z# c" w9 q- P
     for(unsigned int j =0;j < faces.size(); j++)# K1 }* {  G- m! U# W( P+ Y
     {
" S: \* f7 O" m3 W     totalfaces.push_back(faces[j]);2 ]) E0 k3 p  O% c5 Q9 _
     }
% ?" K4 G5 k: N& C) V) H# r      for(unsigned int j =0;j < Features.size(); j++)4 r, L( L% Y9 b- n* M
     {: R2 A7 a0 R0 ~; B' [  v' w, l
     totalFeature.push_back(Features[j]);0 B; Y6 \. K2 I2 o
     }# }) X3 U& M/ [- Q" B* ]
      
* G: Q( Z; z8 J2 h5 r! w   }& L5 ~' }' ]& {
    ss <<"edges count = " << totalEdges.size()<< "\n";
1 ^+ z( u$ C7 U' u- s5 }   for(unsigned int j =0;j < totalEdges.size(); j++)
. q* K: E( e: N% e9 c- ^     {   ' o) M" ~! f6 J6 Y# r0 g6 y
      totalEdges[j]->GetVertices(&vertex1,&vertex2);" z- f) ]# N4 H, n
       ss <<"edges tag: " <<  totalEdges[j]->GetBody()->GetTag()<<"\t";, L1 W- b( L! Y1 k7 y( J+ U% m
       ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";
4 H& B- t/ a9 L. o1 ~, {4 G       ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n";7 \' p; x) H, d8 z0 |
     }
& t( l) ?5 b- D2 T0 |7 l+ i% O   ss <<"faces count = " << totalfaces.size()<< "\n";2 T! @) l5 Y' P+ r% e! }! Y
    for(unsigned int j =0;j < totalfaces.size(); j++)
) b2 J2 [1 Y) [/ t& B: J. _* G    {  1 V: ^& W4 w4 `  u. O3 m
     ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t";0 i" M- c; u$ m0 Q0 V* o& [
     ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";" v  ?& Y* A# d# |2 {
     ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";# i0 D9 E- x! t2 E0 I" C
    }
# B' `1 d, r  ^( |% A* r   ss <<"Features count = " << totalFeature.size()<< "\n";+ j: j. l5 Z+ X0 g
     for(unsigned int j =0;j < totalFeature.size(); j++)
6 k9 t0 d$ Y0 {% T# b    {  : ~$ _$ }0 `7 c) k% h& e: Q( n3 Y  i
     ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";7 h2 O" h8 s1 `; x1 D) g
     ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";
  K$ i- n- Z2 V% C* c- k; s5 t( G) w     ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";
7 I$ m& B$ s0 H  N7 x    }
, f3 e8 k0 U9 L; Q3 x  theSession->ListingWindow()->WriteLine(ss.str());
% y" G! F1 F% ~0 _9 \
$ t  @2 I# Q7 \: A
) e9 h4 I( _4 }( A8 _3 H6 w; r查询结果如下:* J5 O/ K& I7 {  ?! K) U

" I* |6 p6 A* Z% \* `# s- ?
( q. s9 f# q' D' k7 sGet information from all bodies
: |0 y5 u* q) c* mCYLINDERBodies count = 76 a$ c9 O0 J$ l# M7 w0 w
edges count = 22: c! R* n" {6 V, n6 l8 `# y
edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100)
/ ?* D9 E# q, R7 n- Sedges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0): O; ^5 X  I7 }7 a: m  z/ d8 {. l2 c7 m
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)
8 s& e8 b% C. |$ X/ x  |0 M3 p6 [edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0)
7 o& r6 a! [1 R- M7 B6 @0 }+ k) Xedges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100)- O* D9 ?& t" v( ]7 g# Y# \( b' s
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)
7 M4 h4 \1 ^. n; O% D1 Kedges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100)  `, w# S1 N/ X
edges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100)
" b# F0 |! J' ^- kedges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100)  \: h& G+ {& W8 H; ]
edges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100)5 ~- W1 U0 c& i( y" Y- s7 j( x9 Y
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100)/ ?( ~! J2 {$ |( X1 ]6 f0 j/ C5 w2 }2 W
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0)0 a' v8 C" r' Y$ J( g7 X. }
edges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100)
& {+ ?3 \: S8 C% ?# N7 y' D  I9 Redges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)
5 ~6 ^4 q; g' J5 P  E7 |9 dedges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)3 J- X8 z, A/ C2 ?
edges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
# t# K3 V% K% C. Y3 c- Oedges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
1 t% F8 P3 J3 ~7 eedges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)
" a3 o% E- M$ g! E" Medges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)/ o2 N1 u, B7 X* l7 k0 b. A' T) P
edges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500)
3 Y# w3 R9 h' S4 y8 L! Vedges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200)
) V# Q" d' p5 o' i; {edges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)2 m' u8 F) U* o. o* `9 F- A
faces count = 221 {" s7 ~5 S* I4 f' o. q; g$ o
Face tag: 41407 Face Type: 4 Face Name: " U- ^8 \: O& T1 [7 y
Face tag: 41398 Face Type: 1 Face Name:
- O6 z- i3 Z" l% H+ |, GFace tag: 41376 Face Type: 1 Face Name: ( x. Y% p( M" t+ A! j( H8 `' V1 [' }- Z
Face tag: 41391 Face Type: 1 Face Name:
1 C0 P# x/ I) J% U! OFace tag: 41380 Face Type: 1 Face Name: ; h0 q' r' k! g9 u% T' u
Face tag: 41396 Face Type: 1 Face Name: " n- i+ j- w( o. i& R, ]
Face tag: 41397 Face Type: 1 Face Name: + L+ n( p$ N* `& l+ N* W
Face tag: 40995 Face Type: 2 Face Name: 3 c7 p& l. r* ?1 r5 W
Face tag: 40965 Face Type: 1 Face Name:
% x4 f/ ~  C' e" `Face tag: 40997 Face Type: 1 Face Name:
  O7 P1 Y! G% T2 L  k$ b- N! aFace tag: 41351 Face Type: 1 Face Name:
% A# V8 g2 Y, f& {Face tag: 41352 Face Type: 1 Face Name: ) F! D( O' E! h; s
Face tag: 41353 Face Type: 2 Face Name: 0 H7 A$ ?6 c; P
Face tag: 38479 Face Type: 1 Face Name: 9 i" Q2 i3 n. r; |
Face tag: 38480 Face Type: 1 Face Name: : z- `1 R/ M- f* J* {$ R; ]1 |1 y
Face tag: 38481 Face Type: 2 Face Name: 3 Z/ t" W0 Z3 d9 b4 b, _3 q
Face tag: 41207 Face Type: 1 Face Name:
7 J  |9 X* ~% [4 ?Face tag: 41203 Face Type: 1 Face Name:
! o- l* O1 _( d$ K. bFace tag: 41158 Face Type: 2 Face Name: : Y; B2 G8 f: N2 l
Face tag: 40987 Face Type: 2 Face Name: 1 L* l+ O- r' C6 g+ G* r# F
Face tag: 41010 Face Type: 1 Face Name:
2 n" N, ^7 Q9 t/ m6 kFace tag: 41001 Face Type: 1 Face Name: 4 t  X9 A* W& `
Features count = 72 P: k. d7 G* d) N2 {% Y% `
features tag : 41280 features Type: SPHERE features Name: Sphere(17)
: [1 y: b' O7 ~* ^features tag : 41281 features Type: BLOCK features Name: Block(18)
; w0 I; i! `6 H, M* h6 i: Wfeatures tag : 41307 features Type: CYLINDER features Name: Cylinder(19)
/ n: |8 g# |: M/ n; H' ?features tag : 41314 features Type: CYLINDER features Name: Cylinder(20)
0 L  F) b6 |7 N7 |( a3 e" V8 N/ jfeatures tag : 41322 features Type: CYLINDER features Name: Cylinder(21)
& k$ P4 U  ^: {' I- t8 F" jfeatures tag : 41330 features Type: CYLINDER features Name: Cylinder(22)
+ i: a4 c7 P, J1 N$ efeatures tag : 41338 features Type: CYLINDER features Name: Cylinder(23)- f9 V/ K* B3 E' \0 B. M5 u! O( b# \
4 b: @$ U' @( a! I! w
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了