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

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

[复制链接]

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

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

admin 楼主

2013-11-4 16:53:51

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

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

x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息
) I7 y6 I1 q# c5 x/ r2 P! E
" R  B0 v8 E. W6 w3 c
/ A. s( _; x- p$ F  theSession->ListingWindow()->Open();- f: M+ O/ A+ Z; \9 ?
  theSession->ListingWindow()->WriteLine("Get information from all bodies\n");5 n2 ~" [% C$ e+ y
     std::vector<Body *> bodies;
5 f9 l# ~( l$ J* k  BodyCollection *bodyColl = workPart->Bodies();
2 K" o0 y* H  ~( G5 h  for(it = bodyColl->begin();it!=bodyColl->end();++it)! x9 c! W! f+ Z4 x/ `0 E
  {
9 Y+ `. v  I: z$ T+ P4 L/ v   bodies.push_back(*it);8 C/ n( S, E  F$ L4 a. J8 g$ Q0 N
  }+ R7 Y& j9 d, i
  ss <<"Bodies count = " << bodies.size()<< "\n";" D; S3 a4 O( K+ L
   std::vector <Edge *> edges;3 t! t0 ]# u$ k6 D! a
   std::vector <Edge *> totalEdges;
* {& L  i. W0 A: |$ h   std::vector <Face *> faces;, Q% Y% {6 U4 S
   std::vector <Face *> totalfaces;( ?' A9 m* [; ~  h/ g6 x
   std::vector <Features::Feature *> Features;. _. g& K* e" ^: d# r
   std::vector <Features::Feature *> totalFeature;
+ C2 I0 F7 Q; d2 t   Point3d vertex1,vertex2;7 N% _  ?" f, ^2 E" P
   for (unsigned int i = 0; i< bodies.size();++i)
7 S* d* ?( c; P& c- p( C) J) ]   {
2 Z- X! I# U4 M! Q4 z; V  Z  p3 C    edges = bodies->GetEdges();
, u5 t* _) _( d$ w    faces = bodies->GetFaces();
1 l( I# Z6 e4 _    Features = bodies->GetFeatures();" O9 l  \4 v5 K8 s9 e+ N
     for(unsigned int j =0;j < edges.size(); j++)
! S7 S1 @0 m/ T2 H. k     {
- H; C& z9 d6 h. O# J5 f: z     totalEdges.push_back(edges[j]);# M: v5 B: S7 |4 P% b6 i- P
     }
- e( H; K2 |5 |$ |6 x/ Q9 S) K$ l     for(unsigned int j =0;j < faces.size(); j++)2 k9 W6 ?) w' O, Z
     {! q% I1 E) X: s: k2 h) v. l5 J' K" e
     totalfaces.push_back(faces[j]);
& q. a" t; B4 o6 M     }+ M8 q" V. b+ `' e
      for(unsigned int j =0;j < Features.size(); j++)! K# @- x$ s0 z' \( F+ z' R* g
     {
9 h* {' G- h( [& _2 f: k* |     totalFeature.push_back(Features[j]);  S6 Q9 E' w$ j$ D. [
     }
9 j) y3 R9 {( O" |      
. @' e: x1 B! T, Q" e% @   }
1 V' j' V# j. Q3 z* m! q. U9 W    ss <<"edges count = " << totalEdges.size()<< "\n";
: \0 g; q: F- Z   for(unsigned int j =0;j < totalEdges.size(); j++)
% P' f/ \' \# X7 b6 F9 x     {   7 n  d) [7 X/ _' ]% @8 l2 e# g$ P8 d$ o
      totalEdges[j]->GetVertices(&vertex1,&vertex2);' o& z: J4 o- |" g: J! w$ z
       ss <<"edges tag: " <<  totalEdges[j]->GetBody()->GetTag()<<"\t";: W: _$ {' B8 z3 y" u' [( w
       ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";
1 L" V- v. r# M# t  N9 ?% G       ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n";" r9 c$ ~/ Q3 H6 w
     }% x4 Y" m9 A9 r: f* c1 t
   ss <<"faces count = " << totalfaces.size()<< "\n";
5 P: X" }- K( z2 Z' W6 e( M8 O    for(unsigned int j =0;j < totalfaces.size(); j++)" x* J; i, u2 h; e& Y
    {  
% ]# r% ]5 c. z7 p8 L/ e5 q/ M     ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t";
" J' H/ L0 e5 u# ?5 J     ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";2 r) Q! `  W- D
     ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";- Z; P5 I$ D9 u, G+ q% ~
    }
$ _9 S* q" S( d, y2 J   ss <<"Features count = " << totalFeature.size()<< "\n";
6 G1 @, b4 G( y     for(unsigned int j =0;j < totalFeature.size(); j++)) K4 j  ]* ?6 V
    {  0 i3 Q, [2 ?8 m$ j* @
     ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";
8 z, H  S( E+ A8 M& M; `     ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";- \& J1 g: W0 j% [& y) F
     ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";5 c, u0 u; T& c+ o  v1 Y4 K8 n
    }
9 L0 }3 B; C. N' J3 |  theSession->ListingWindow()->WriteLine(ss.str());5 s7 m# y3 B! y# V& B
% D# V2 Z. c# q0 O- {. p1 q
2 I- N2 q* M9 e6 {( L" I; W
查询结果如下:
  S9 E8 y( x! I+ I* a1 }1 k
& w4 e+ ?) g$ M" T6 m6 I# l. G/ T& k0 q5 b& y  u1 v( l" d) e
Get information from all bodies: F  W4 A! f4 x: h# l: e9 o
CYLINDERBodies count = 7
! i* L9 h5 G" M& Aedges count = 22: |- h. _5 q. p3 w
edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100)
% f7 c7 Y. U9 J" Jedges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0)" e5 c5 _4 q7 M
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)/ N. _: w3 f3 F
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0)$ r" x; b2 f& E, ]) N" i$ x) j
edges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100)
3 c# p0 E6 k3 I4 G* Ledges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)
% j7 ]1 n# S- ~# Bedges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100). L( G9 }! K. i4 o* P
edges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100)
2 G  W4 C& U7 g6 {( W7 e; p2 dedges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100)
5 T: |4 Y( i$ x0 ~edges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100)
6 U# k( m, w- |edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100)' D9 E( F# l. i# h
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0)
' y% a7 r9 j0 \, Nedges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100)* V% L9 l+ g- ]. \' w/ t0 Q
edges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)
8 S; C; D2 X+ I  o3 iedges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)
4 m% Z5 l; S$ I: X8 G9 ~- }: gedges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300); Q5 A! l. U  m3 M5 r; w( n9 E
edges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
" a/ `* E  q- w' N! A/ T( Tedges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400). j1 E! Z/ J- ^; X/ [
edges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)) ?) C% z" S% U* i8 @5 {
edges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500)
! _. S. k7 v$ F0 ledges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200)$ X5 G6 H3 w* \3 U+ _
edges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)
- r0 W  ^6 U  ]; P; g$ j- j& ]+ bfaces count = 226 s; k% s/ n$ c6 {+ Q
Face tag: 41407 Face Type: 4 Face Name:   }9 f2 T+ I: T; _- @5 Y& p
Face tag: 41398 Face Type: 1 Face Name: ; g5 ^/ p5 E& ~# A" H
Face tag: 41376 Face Type: 1 Face Name:
9 X: h$ G4 S1 `" t; K. fFace tag: 41391 Face Type: 1 Face Name:
8 N8 l& d& I! b% f, f$ JFace tag: 41380 Face Type: 1 Face Name:
1 ]2 p7 J4 O9 BFace tag: 41396 Face Type: 1 Face Name:
+ N. N  N, p) f* s! z2 uFace tag: 41397 Face Type: 1 Face Name:
  `4 R% Q' i  wFace tag: 40995 Face Type: 2 Face Name: . t$ a( E4 t8 w  g( }
Face tag: 40965 Face Type: 1 Face Name: " C$ u, A' p) h. w! E
Face tag: 40997 Face Type: 1 Face Name: - g- x* g5 Z* d
Face tag: 41351 Face Type: 1 Face Name: : t+ J' V4 a2 \' D6 E5 U: W; e5 f& o
Face tag: 41352 Face Type: 1 Face Name:
) U1 j9 ^- k) M4 X0 IFace tag: 41353 Face Type: 2 Face Name: 6 W# H% n$ }! D, L* |2 ]
Face tag: 38479 Face Type: 1 Face Name: 1 R' C$ y1 [- a2 O
Face tag: 38480 Face Type: 1 Face Name:
2 o' L' k: F# Y: K0 G3 xFace tag: 38481 Face Type: 2 Face Name:
( d, E8 Y1 Y. A/ k5 x& p: u0 MFace tag: 41207 Face Type: 1 Face Name:
" h' ?- C% l  O& `* u) @' DFace tag: 41203 Face Type: 1 Face Name: & S# y9 t; o2 N8 e) B% B% ~. j
Face tag: 41158 Face Type: 2 Face Name: 0 ~5 t, n- d0 o4 b  A9 ^* I2 o, ]
Face tag: 40987 Face Type: 2 Face Name: ( u( g$ m0 i0 E% ]9 s. X! |5 _# [0 T
Face tag: 41010 Face Type: 1 Face Name: ; [% s& U9 Z1 w! y1 F
Face tag: 41001 Face Type: 1 Face Name: $ S! H0 c( c& T+ M' d# h
Features count = 7) G3 M% t7 u/ h  D+ A
features tag : 41280 features Type: SPHERE features Name: Sphere(17)$ ^5 e6 V) Q9 X
features tag : 41281 features Type: BLOCK features Name: Block(18)/ N& D" ^: r" |! p
features tag : 41307 features Type: CYLINDER features Name: Cylinder(19)+ g' F6 q4 s' K6 Q* y3 i5 V, v; A/ Q
features tag : 41314 features Type: CYLINDER features Name: Cylinder(20)6 Y" I/ m4 D8 \6 m$ I6 x. ^. T/ ]
features tag : 41322 features Type: CYLINDER features Name: Cylinder(21)
3 g, g% N6 ?% A' [" O+ [- R" lfeatures tag : 41330 features Type: CYLINDER features Name: Cylinder(22)4 N8 ?* f8 U& H; T
features tag : 41338 features Type: CYLINDER features Name: Cylinder(23)
  S5 \& {% D+ ?- ]* z, @  R$ t7 Y; n$ {( l& e9 [
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了