PLM之家精品课程培训,联系电话:18301858168 QQ: 939801026

  • NX二次开培训

    NX二次开培训

    适合初级入门或想深入了解二次开发的工程师,本培训结合ufun,NXOpen C++,大量的实例及官方内部的开发技术对于老鸟也值得借鉴!.

    NX CAM二次开发培训报名 NX二次开发基础培训报名
  • PLM之家Catia CAA二次开发培训

    Catia二次开发培训

    Catia二次开发的市场大,这方面开发人才少,难度大。所以只要你掌握了开发,那么潜力巨大,随着时间的积累,你必将有所用武之地!

  • PLM之Teamcenter最佳学习方案

    Teamcenter培训

    用户应用基础培训,管理员基础培训,管理员高级培训,二次开发培训应有尽有,只要你感兴趣肯学习,专业多年经验大师级打造!

  • PLM之Tecnomatix制造领域培训

    Tecnomatix培训

    想了解制造领域数字化吗?想了解工厂,生产线设计吗?数字化双胞胎,工业4.0吗?我们的课程虚位以待!

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

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

[复制链接]

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

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

admin 楼主

2013-11-4 16:53:51

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

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

x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息
  {% b3 K0 C* n, e$ E
! C% E- F' S7 O" a8 Z8 J) U8 w. \3 s# i0 r! @
  theSession->ListingWindow()->Open();; Q( W3 W# u9 p6 g
  theSession->ListingWindow()->WriteLine("Get information from all bodies\n");
2 ?: o: r7 d" |4 j7 a* \  p( e6 w     std::vector<Body *> bodies;
- e) O$ |9 c4 V8 l6 {9 z/ L  w  BodyCollection *bodyColl = workPart->Bodies();- K# z- b! e# \  {
  for(it = bodyColl->begin();it!=bodyColl->end();++it)
3 o1 x* n4 f) g# t, R4 G+ \  {
; M7 [8 |: T5 m   bodies.push_back(*it);# G- T2 I4 c2 _7 l1 ^+ ^
  }' S* T3 A: y: P7 p0 s/ V, m# A
  ss <<"Bodies count = " << bodies.size()<< "\n";
0 I: P7 J6 a5 s7 k0 G- f& P( G   std::vector <Edge *> edges;% l+ Q3 f. r& ^; ~
   std::vector <Edge *> totalEdges;
6 C. K! ^$ A0 {9 I   std::vector <Face *> faces;$ B2 Y. s8 o7 b3 G
   std::vector <Face *> totalfaces;
! d- h3 ^8 e2 L8 e. o) g   std::vector <Features::Feature *> Features;
4 e8 \& D9 J) f1 D   std::vector <Features::Feature *> totalFeature;: C3 ~. A  E7 Z, J4 N4 p! P" @( G7 v
   Point3d vertex1,vertex2;
: ^  y# P  h  n& m1 E( f   for (unsigned int i = 0; i< bodies.size();++i)
: ~6 f$ b- J* R/ Z   {
- U; H: H9 Y. I- l/ ]/ a% `    edges = bodies->GetEdges();
% \. Z" N- v' y4 Y, ^  a- g/ p    faces = bodies->GetFaces();
& g7 E) o* C$ y" M! s3 k    Features = bodies->GetFeatures();
3 Z/ D5 M# l5 f" O0 _* ^  v, \     for(unsigned int j =0;j < edges.size(); j++)  |6 H7 b1 g  o/ J  m( G
     {7 ?( Q) X, k$ H- h+ b- Z5 [
     totalEdges.push_back(edges[j]);
  T: C8 u& r8 D4 ^* G4 |     }
2 y: D3 t/ [( t     for(unsigned int j =0;j < faces.size(); j++)2 E# [: ~, g) O8 N+ W
     {. F- J& \) j9 l$ u
     totalfaces.push_back(faces[j]);* M- {' M9 q. R, Y& M) k; U' h( u& v0 |2 b
     }
- }- K8 N7 c  {; h      for(unsigned int j =0;j < Features.size(); j++)
% ^% C( v0 r% Q5 p     {# y0 {; Q3 j! u
     totalFeature.push_back(Features[j]);
9 I2 C  a( H5 Y     }7 H" h7 L: \- Q& ^6 ^4 L( \9 Q7 e
      
! G( c  H) v) g! I1 R   }
3 G  y% L& X% [+ k* {, n' Y( n    ss <<"edges count = " << totalEdges.size()<< "\n";0 i" D& }- i2 K  D3 {* Y% Y
   for(unsigned int j =0;j < totalEdges.size(); j++)' y$ M" q$ [  ^0 s, \! h
     {   
* E! p/ {  Y5 X9 U  }( G      totalEdges[j]->GetVertices(&vertex1,&vertex2);
# t7 m) I, K) J+ v% D4 g0 Q/ X0 k       ss <<"edges tag: " <<  totalEdges[j]->GetBody()->GetTag()<<"\t";
/ |6 r1 ^% ]8 C$ [' t5 L       ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";
1 r! w: c9 S) e  Z       ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n";  N, J$ f) j* N$ j* O
     }1 i' C% [7 o1 @! T! b
   ss <<"faces count = " << totalfaces.size()<< "\n";, v7 i& v4 J- w/ a
    for(unsigned int j =0;j < totalfaces.size(); j++)# M0 a  W. K& s) P) w+ r+ X
    {  ( Z4 v5 [& q; t+ Z4 m. K9 g0 B/ M
     ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t";
9 E# M! e- s& F  F2 U# {     ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";
& H( U4 C* ~1 O( e; I/ x     ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";
7 ?1 k2 a5 X3 y: s0 q/ Z    }
, ~& \6 g- B$ O; v   ss <<"Features count = " << totalFeature.size()<< "\n";  M' y+ N, h8 W, Y
     for(unsigned int j =0;j < totalFeature.size(); j++)
8 l2 Q9 a' M% Y5 c( w9 ^    {  
2 N7 v3 E7 R1 o9 K) b1 h0 q1 H     ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";8 a/ [' v, R# v* h# k
     ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";
* r. l- S7 b( q5 g     ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";
( o' y6 W% a( C2 Q4 ]4 h7 z$ S+ m, t    }
( `; h3 F" q% A4 k$ p  theSession->ListingWindow()->WriteLine(ss.str());) T6 t" P) H1 X2 ^" o
& Q% u2 ~3 T6 \  U$ C% Z
) Q: m4 j5 g$ \
查询结果如下:
- w% ?9 z) C' v5 l& @# z9 N2 f
3 W% K2 f2 y$ a( P8 k
& b  x2 l5 E$ e6 j6 TGet information from all bodies
9 M1 [* P/ r$ t3 a* ^. R! S4 ACYLINDERBodies count = 7: B$ g1 B6 Z7 e) p, |2 K  a4 {
edges count = 22
: v6 D1 p8 `7 E) |2 H/ kedges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100)
+ }  ^% m1 w! W, c, |" y0 T( h: nedges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0)
8 H2 T& Y: P6 h2 zedges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)
  b0 }# f* s( m$ z, eedges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0)! S) R4 o7 }% P( R) s% I
edges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100)0 J' B1 i, |- H2 C5 I
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)
5 W; @6 q1 K  H! _0 jedges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100)3 o! V) l" J  T4 [
edges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100)9 b# k% Y- d$ |, X
edges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100)
' w& R# f, }# W$ Pedges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100)
  J3 @# f4 J% d) Oedges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100)
6 s+ N4 _4 u( ]& T2 zedges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0)
5 P- B* F. O& H) a- @: Yedges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100)- }! @7 j* j4 ]: i, K: o% p$ \# m
edges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)
; M  x7 I# y- W3 c2 H) h8 v# {edges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)
$ ?( M5 P' L5 ]* t0 }! J0 Medges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
! [2 C8 A/ @1 f6 g% W% _edges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
5 p0 |$ D) V) k5 a; l. X6 K& q; I+ Aedges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)9 Y" {6 u) i4 m5 {5 {
edges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)
' G9 z) m0 D' Cedges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500)
( l# ]8 T( i& T+ n# \3 B+ n1 E! w: \edges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200)
$ D6 t! y/ s2 Z4 b; ~& xedges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)2 r$ E5 ^; v1 T4 f! e* V! z$ U+ k1 }
faces count = 228 s* |. j  `' D, h  M
Face tag: 41407 Face Type: 4 Face Name: 6 v" L6 |2 c" u4 p
Face tag: 41398 Face Type: 1 Face Name: 9 y1 D% p+ x1 ]+ _1 r
Face tag: 41376 Face Type: 1 Face Name:
! D8 `0 f/ r' Z4 |/ t7 M% P9 XFace tag: 41391 Face Type: 1 Face Name: ) X* [3 B/ y1 d5 A
Face tag: 41380 Face Type: 1 Face Name:
9 o! x$ g+ X  O3 ^* ]6 E7 hFace tag: 41396 Face Type: 1 Face Name:
6 Q' E4 p5 {6 j) c* M1 dFace tag: 41397 Face Type: 1 Face Name:
: R6 I( R  _2 @  @7 p* vFace tag: 40995 Face Type: 2 Face Name:
! \" Y( ?# i# e. N# w" LFace tag: 40965 Face Type: 1 Face Name: 2 G# C& d2 l& c# \
Face tag: 40997 Face Type: 1 Face Name: * U1 Z6 p5 R4 w% c7 L) Y
Face tag: 41351 Face Type: 1 Face Name: 4 m8 C+ k3 c2 U; V, G$ ^
Face tag: 41352 Face Type: 1 Face Name:
- j2 m; n5 `! [/ yFace tag: 41353 Face Type: 2 Face Name:
+ ^) p# X. e# X- {: t$ Y% TFace tag: 38479 Face Type: 1 Face Name: ( ?' U  _4 u7 a* j5 V4 l
Face tag: 38480 Face Type: 1 Face Name: ; l  }4 R' }% e: s0 f0 a; \
Face tag: 38481 Face Type: 2 Face Name: : n( D* G$ y  A! H5 k3 y; z- F
Face tag: 41207 Face Type: 1 Face Name:
! i% |$ k+ n. Y$ D, N/ \Face tag: 41203 Face Type: 1 Face Name: 7 C4 }5 G* p8 t9 A  J+ P
Face tag: 41158 Face Type: 2 Face Name:
2 T: h" z) n' R/ W3 DFace tag: 40987 Face Type: 2 Face Name:
! E& u+ D% b! }Face tag: 41010 Face Type: 1 Face Name: / o0 d! L' J: `. x8 \$ [: h3 F+ t( D
Face tag: 41001 Face Type: 1 Face Name:
4 O; Y* E2 |8 m8 h$ M6 L) VFeatures count = 7
$ j* W5 m7 c8 n( Y- o5 xfeatures tag : 41280 features Type: SPHERE features Name: Sphere(17)
- t* q$ G+ i, zfeatures tag : 41281 features Type: BLOCK features Name: Block(18)4 |2 f% i8 k8 v& X3 A6 B
features tag : 41307 features Type: CYLINDER features Name: Cylinder(19)9 c0 u4 G# \" e. h  d' I" P! C, b  c3 b
features tag : 41314 features Type: CYLINDER features Name: Cylinder(20)
6 d6 l) l& t+ |- B9 ?( Nfeatures tag : 41322 features Type: CYLINDER features Name: Cylinder(21)
9 p0 n8 ~6 |% P% i: M" B( r4 E4 a9 Mfeatures tag : 41330 features Type: CYLINDER features Name: Cylinder(22)5 E8 H$ U7 y8 D
features tag : 41338 features Type: CYLINDER features Name: Cylinder(23)
( |- H1 l% `) f3 t* u" n5 W# M( e6 D4 r7 G, K
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了