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

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

[复制链接]

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

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

admin 楼主

2013-11-4 16:53:51

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

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

x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息) p/ t" ^( z) U: l- B
. R  c7 P# p; S* w$ S

" s+ U3 A. @7 ^' w) [: S" R; c. \  theSession->ListingWindow()->Open();
; M4 X9 b. n* L: f$ K" O( `; j9 ]/ X  theSession->ListingWindow()->WriteLine("Get information from all bodies\n");
! w- H+ W  z4 i6 G) n; n* S     std::vector<Body *> bodies;
1 {" x; B0 ~+ X" ~0 U. B  BodyCollection *bodyColl = workPart->Bodies();
* c6 y, Z# `8 L+ A' ^5 J7 ]! t  for(it = bodyColl->begin();it!=bodyColl->end();++it)
7 I9 S- Z0 _' H$ [, U  {. E( [) T  N3 ^( j2 z' G% ~
   bodies.push_back(*it);
6 Y; E  K+ A3 ]  }
; v4 h0 D% R( B' k  ss <<"Bodies count = " << bodies.size()<< "\n";
3 Z% b4 F  C  }$ K8 s2 p% Y: v7 s   std::vector <Edge *> edges;
# e+ F0 k' ~8 X) T- V   std::vector <Edge *> totalEdges;
4 Q, W7 Y7 \" r' y, b0 w   std::vector <Face *> faces;6 R/ o9 L1 f( V0 ^$ a4 a' Q) z
   std::vector <Face *> totalfaces;
+ v" Q- {4 n2 N$ j5 S   std::vector <Features::Feature *> Features;
7 l; T- A% D6 Y/ s   std::vector <Features::Feature *> totalFeature;
8 F: J) H) l1 b. l' ?8 b   Point3d vertex1,vertex2;
& F3 n9 S3 K$ w. C+ J   for (unsigned int i = 0; i< bodies.size();++i)
$ R2 q, Y" u; a( [   {0 e$ ?- n( W7 h* |3 ]$ N
    edges = bodies->GetEdges();
( B4 |( e" U- e& P6 t    faces = bodies->GetFaces();+ a8 Y) H2 t! j* ?& J( E& q2 _
    Features = bodies->GetFeatures();
9 l7 G! H$ C  E3 H& j6 u$ s/ O+ _     for(unsigned int j =0;j < edges.size(); j++)2 l3 |$ T8 o) l5 P9 o: b
     {( L9 s1 o" @3 y& i
     totalEdges.push_back(edges[j]);
% b, m2 q( j* d/ r4 W) i& F     }
$ k$ m: f! @" b# n! w     for(unsigned int j =0;j < faces.size(); j++)
+ K- `1 z  j; f- Z! g% K     {
/ _; ?+ {6 r: g# v3 d2 i     totalfaces.push_back(faces[j]);
. v. _; D) |3 D) g+ e) e# G: r     }0 n; {# a: @+ o& g$ N
      for(unsigned int j =0;j < Features.size(); j++)
+ G% G# q6 ?% M! N5 G/ m* w     {
. S8 b7 @( X$ n3 L8 ]     totalFeature.push_back(Features[j]);6 q  I: ?4 U4 O
     }2 \/ i+ b  X- g2 e' ~- j
      
  f8 t4 ?* v4 L) Z) u. r) U   }& Q' i$ ]$ t: I8 Z
    ss <<"edges count = " << totalEdges.size()<< "\n";
9 {7 [% b9 _. I7 }) q   for(unsigned int j =0;j < totalEdges.size(); j++)3 n/ I4 N. _  w/ k4 i
     {   0 N' `( s/ `0 |: d
      totalEdges[j]->GetVertices(&vertex1,&vertex2);
* T/ S  ^) z  {& {+ b1 {5 F3 C       ss <<"edges tag: " <<  totalEdges[j]->GetBody()->GetTag()<<"\t";/ q" h' A: c& {. A% d
       ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";
, {, Z; X) ~: E- U+ L6 ~: ?1 S       ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n";
. P% W: ~9 o7 z4 A7 [% x  T     }/ Q# E2 s7 O! q$ w# B
   ss <<"faces count = " << totalfaces.size()<< "\n";, Q' E8 S' }/ V5 r
    for(unsigned int j =0;j < totalfaces.size(); j++)
7 o" ?- V" Y+ O% n8 ?- j    {  5 s. R, V7 x# h6 ~& H) |1 h9 B
     ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t";) v7 q- _; S" K
     ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";7 P. m! G. F. ~
     ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";7 X% o* @* d8 U4 o( c
    }0 S# D. C9 n' k, k* x
   ss <<"Features count = " << totalFeature.size()<< "\n";4 G) U2 r9 _7 C
     for(unsigned int j =0;j < totalFeature.size(); j++)
5 W0 |! K) q7 f3 V2 z3 g" C4 n0 y    {  2 q5 r' f, B* _  c7 M; \! P+ J6 P
     ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";
  a! q8 Q% N- u# m0 e     ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";
' |0 H. N, m7 i8 d     ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";
5 V# X0 R1 P( N' i8 w6 B    }
& r" U$ J5 u- C7 F) J+ ]  theSession->ListingWindow()->WriteLine(ss.str());
" {$ T# i* N1 Q) B5 t
8 v) m" H$ g6 @$ k
% h9 F" B; [6 T% L  z! I# T& G8 Q查询结果如下:
/ F4 K$ F5 L, o4 w- F3 v% h5 }( d* w' q  e

/ T1 W, J" }9 b% NGet information from all bodies
/ N# E; U; K! \4 S- P5 L; n) CCYLINDERBodies count = 7
+ i; G7 k: f. ledges count = 22
' M! S* K( B$ X7 Q6 uedges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100)  u+ Y" x$ ~; C9 C; m$ f: C1 i; g
edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0)3 X3 W& H( I9 e# m6 Q
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)( u7 H+ M. _4 R* C6 }
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0)
0 r/ [2 R7 g4 j5 C6 i( M  N  uedges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100)
, a$ p* s) Z% l$ A3 Kedges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)! K/ ]: Y9 r$ Q' A/ |
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100)
0 E/ F  l1 v) X) `" q9 J, P8 Vedges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100)
) l" {  N: E- }! y! f# c0 k: Xedges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100)
" y2 l0 B0 ^# ^0 B4 J' Z  W7 |edges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100)
  Y% x9 q5 P2 Cedges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100), M1 v1 V8 I; H, S' e- |
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0)
4 |$ t6 U+ c# J" M4 yedges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100)
6 h1 V! z( B' ?$ M8 k4 T: _( wedges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)8 E; N  j* ]0 P" e% k* s2 g6 r
edges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)
8 V  r- o* r4 ?1 U: A: E; F& xedges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)$ z5 _- r( u$ S6 d2 Q) h
edges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)8 Y1 Y% j9 n! ]# t; C
edges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)+ O' R1 a1 `# C" ?
edges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)3 v# P1 r% o! ^6 n
edges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500)
. r5 o, p9 @4 @- W. r4 d6 Y5 w6 Oedges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200)
9 f7 b7 K" z* w' dedges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)% N; Z% C/ ?6 X- `: v
faces count = 22$ ?% |3 w- u1 x  {+ K$ {
Face tag: 41407 Face Type: 4 Face Name: % g; T2 j6 q& r( `- J
Face tag: 41398 Face Type: 1 Face Name: 8 b& g# V' A0 J3 a  Q' h
Face tag: 41376 Face Type: 1 Face Name: 9 x8 J6 i- D+ L1 p" X
Face tag: 41391 Face Type: 1 Face Name: : H6 v  ~8 y  g2 Q2 j( g, o
Face tag: 41380 Face Type: 1 Face Name: ' K0 y$ S7 f1 @% c- P
Face tag: 41396 Face Type: 1 Face Name: 0 L! m+ H( X) h3 D# ^( }
Face tag: 41397 Face Type: 1 Face Name:
1 B* K8 D; \% T/ e$ D9 xFace tag: 40995 Face Type: 2 Face Name: 9 {! N* x8 e* b) R6 C: o
Face tag: 40965 Face Type: 1 Face Name: & ?' M% P) ?4 z. @
Face tag: 40997 Face Type: 1 Face Name:
; H3 A$ Q# N# c: f% ]Face tag: 41351 Face Type: 1 Face Name:
  y/ S6 r; M, l+ J- BFace tag: 41352 Face Type: 1 Face Name:
" Q' _8 v) k! A" H8 k- uFace tag: 41353 Face Type: 2 Face Name:
: o: `, B+ W7 l- [" P4 r9 s- bFace tag: 38479 Face Type: 1 Face Name: 8 l4 E7 u8 `- b5 `5 n$ @1 V
Face tag: 38480 Face Type: 1 Face Name:
8 [, @, T! R; u5 a) @) G* P" UFace tag: 38481 Face Type: 2 Face Name:   S" i, @) H. w9 u) ^
Face tag: 41207 Face Type: 1 Face Name: ! s5 D$ N* d& y# z1 a, a- c
Face tag: 41203 Face Type: 1 Face Name: 4 p# v! y8 g2 L8 X; Q( I. e& `7 F
Face tag: 41158 Face Type: 2 Face Name: 3 ~7 p, a8 O" C% w
Face tag: 40987 Face Type: 2 Face Name:
8 o) R; h( ]  c& WFace tag: 41010 Face Type: 1 Face Name: ' K1 A5 V* V) g6 V( U7 S; U! z
Face tag: 41001 Face Type: 1 Face Name:
+ z" G- K  [) L8 O9 l1 NFeatures count = 7* B+ {' P2 W. M; k% g6 k, Z- U
features tag : 41280 features Type: SPHERE features Name: Sphere(17)
- r) Q  G- {2 i. h' Wfeatures tag : 41281 features Type: BLOCK features Name: Block(18)6 ?, O  x+ |5 p' p" G* D0 N
features tag : 41307 features Type: CYLINDER features Name: Cylinder(19); j  n6 Y9 {, d
features tag : 41314 features Type: CYLINDER features Name: Cylinder(20)1 v; S( O9 I7 r, f3 y: p: C
features tag : 41322 features Type: CYLINDER features Name: Cylinder(21)
8 F% {1 n" \6 f. c) m- Y7 O" Yfeatures tag : 41330 features Type: CYLINDER features Name: Cylinder(22)# H- I3 f4 @$ u- q
features tag : 41338 features Type: CYLINDER features Name: Cylinder(23)3 h' m/ \& s4 O; o2 Q
! N9 r9 q; i0 x
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了