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 5994 0

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

admin 楼主

2013-11-4 16:53:51

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

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

x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息
2 d) r% m3 p" |: H% ^5 X( R 9 m/ _4 [/ m0 b2 B3 c, Y0 L
  Y( `0 L( \, P
  theSession->ListingWindow()->Open();" X" \  p3 H4 a) c2 _
  theSession->ListingWindow()->WriteLine("Get information from all bodies\n");
6 x& D& t1 @/ C     std::vector<Body *> bodies;; b6 v7 P) A9 k  K0 u# T1 K
  BodyCollection *bodyColl = workPart->Bodies();! L6 t5 k* \! B( p: S6 m4 \) G0 ?: ]
  for(it = bodyColl->begin();it!=bodyColl->end();++it)
* S4 |" S9 O. [/ G4 a% w  {5 K9 g/ S- n0 c- E  y
   bodies.push_back(*it);8 |8 I3 a5 r9 M% z8 Q  v# Y* a
  }
& r" k" ?) g0 K+ L  w, q  ss <<"Bodies count = " << bodies.size()<< "\n";  }# }8 N5 ]# Z$ s
   std::vector <Edge *> edges;9 P  R+ C6 h. ~1 ]1 p
   std::vector <Edge *> totalEdges;
: ^- `' ?7 i- ?8 F& T   std::vector <Face *> faces;" }# {2 _" n  K( Z! Y* _$ L7 R
   std::vector <Face *> totalfaces;- a/ T0 M! L1 ~8 T, U5 F: Q
   std::vector <Features::Feature *> Features;
+ b) o0 R  r+ y" C# B: {   std::vector <Features::Feature *> totalFeature;
9 I; ?- Y1 }' ~& {. m6 ~  v   Point3d vertex1,vertex2;
& m% _$ u& b' Y5 P" b   for (unsigned int i = 0; i< bodies.size();++i)
1 g8 u& W5 B  H- }   {4 g2 X9 M6 w8 }9 N  L% u
    edges = bodies->GetEdges();
# B+ e) O4 a  {7 p4 Q1 m    faces = bodies->GetFaces();
6 x9 D8 m' O1 r7 H  o6 y% e4 A6 m    Features = bodies->GetFeatures();- p" _& r7 L/ m0 b
     for(unsigned int j =0;j < edges.size(); j++). d# w" \" S( W/ E6 f
     {
# O7 x# u% R; d% H( N' F8 }     totalEdges.push_back(edges[j]);
) m3 X# M7 X7 g6 x/ t& v; t     }
, I+ b6 S1 [( p8 g9 I6 p     for(unsigned int j =0;j < faces.size(); j++)2 ]) k: K$ p+ D( a0 J# K5 ?
     {
8 _$ z4 s4 r% T5 o- ^5 r% m+ t9 x! z     totalfaces.push_back(faces[j]);$ n+ ]" \, Q. K4 }4 K& ]
     }' t& _) v# k6 S/ U; K8 Y+ ~! i/ O
      for(unsigned int j =0;j < Features.size(); j++)- Y: O' o$ @, ?1 {# Y
     {
) ?+ a0 C. v3 W3 B7 V0 ]     totalFeature.push_back(Features[j]);, t4 U5 E" l( }) T+ E
     }% u6 U  h! q. D9 x
      
# q, ~* }  E+ T8 h8 C3 s   }
- R/ w1 w6 k9 w. r3 _    ss <<"edges count = " << totalEdges.size()<< "\n";
" Y4 S, t& _& E0 H- Z6 x   for(unsigned int j =0;j < totalEdges.size(); j++)
* \% k1 q$ G- ~) V* M3 T" \' i     {   
7 O$ _4 D% m8 V      totalEdges[j]->GetVertices(&vertex1,&vertex2);
$ V- U* H' N) o; i8 H. }4 J& @* H       ss <<"edges tag: " <<  totalEdges[j]->GetBody()->GetTag()<<"\t";; F, N8 G# x- K2 y7 |" v* o$ L
       ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";
2 I5 t; T: h8 u% j9 j       ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n";
* P: ^' \2 O2 |: P% T* ?     }
; j0 @) |) q) @' q8 F& D   ss <<"faces count = " << totalfaces.size()<< "\n";
7 H6 p( {$ E# J8 a8 r% t; W    for(unsigned int j =0;j < totalfaces.size(); j++)
# [0 l4 g& q  [# ?! t3 t' m    {  
" [8 i# }8 ?9 J' {9 L# q8 e' j" S     ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t";
( A4 ~# {7 x- u! L     ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";
0 Z# s! ^. A# u: M  g7 B8 h& L     ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";
5 U1 I* U8 ~& Q' [8 k& X* r: l    }
- w- Q6 \( L% |/ }" h   ss <<"Features count = " << totalFeature.size()<< "\n";9 W; c' I5 Z+ f; u  D$ A# l
     for(unsigned int j =0;j < totalFeature.size(); j++)4 ?8 q" D' I- W1 {7 W9 r- J) f6 g* s4 V
    {  # E4 P, w9 {! m$ o, r
     ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";
3 L, b4 \( K* Z6 H     ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";+ M  w* T( G0 W. U
     ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";- G" [" Q8 _* `9 A
    }
; }. @. }9 y5 ^/ F  theSession->ListingWindow()->WriteLine(ss.str());
; h1 H1 p4 d+ @# |- S& g& u8 O7 h
: ^* ^/ i, F1 R% @& m: z
查询结果如下:' q8 R" P8 ~8 g  k
1 o& J" `& t& J

' Z; e9 K' T3 M& G0 n, ^Get information from all bodies- T$ h% M% j5 a$ A+ g( o/ F/ @
CYLINDERBodies count = 7
! N9 a) |' l# J5 v8 {4 b7 wedges count = 22
. ^& [" }" T, B% [edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100)* t; z4 X* ]8 z
edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0). M; e* W, j" r4 q% i+ s, ?
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)- _4 P% c: Y- |
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0)
: `8 |  [' ?4 n" K. C. x. \edges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100)* V- [( w! W1 q2 [
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)) ~. }( [. T. G( j
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100)4 m- x( f, O$ x" X4 [
edges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100)
8 ]. x+ Q/ D. L. r+ `9 `+ wedges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100)
+ z, w" m" U# M% s- x& \. B- uedges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100)6 `# Q: W$ p5 l2 G& Z  ]
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100)
4 H2 X3 K0 ~! W" yedges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0)4 H7 W+ v$ D) {
edges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100)0 ?. Z" q$ o3 O" n
edges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)/ s( `. o0 n: q6 ?" t
edges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)
; t1 ~8 K5 U/ E' Vedges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300); o$ Z; U$ Q7 p8 m
edges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)5 C( v" n+ I& H0 s
edges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)/ t; h4 c) |$ s7 r! M7 X
edges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)( u  \' _2 }! u# d8 s
edges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500)
4 {* L2 O! i: N. m0 m; j- Jedges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200)
) ^5 j3 E3 k# C4 redges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)4 Y! B% H  i0 W* w& t/ c  D
faces count = 22  @& y8 p4 g/ Z2 q& [0 E+ j/ `9 B6 f: U
Face tag: 41407 Face Type: 4 Face Name: . M" w+ z+ l$ G# O: H) e2 O: D" m
Face tag: 41398 Face Type: 1 Face Name:
$ d5 [9 Z1 L/ I) U9 o, u; E  dFace tag: 41376 Face Type: 1 Face Name: 6 s+ U- R0 s* }. x* ]- g5 i* U- J+ O
Face tag: 41391 Face Type: 1 Face Name: + {& g! l2 @+ g
Face tag: 41380 Face Type: 1 Face Name: 5 J4 ]2 @5 U2 o# C; m
Face tag: 41396 Face Type: 1 Face Name: / p" q" D; W' [2 N, y
Face tag: 41397 Face Type: 1 Face Name:
2 h9 K8 U2 X3 r( W  g+ [Face tag: 40995 Face Type: 2 Face Name: 0 U  `; v  F! h/ Z
Face tag: 40965 Face Type: 1 Face Name:
; H2 ^! }8 A. Q1 T0 D% RFace tag: 40997 Face Type: 1 Face Name:
* B/ ^2 |( L. J( H7 E. h9 tFace tag: 41351 Face Type: 1 Face Name:
4 G9 n# y; |9 j* r% @" AFace tag: 41352 Face Type: 1 Face Name: # Y$ e3 _3 a8 U' K* F& R$ ^
Face tag: 41353 Face Type: 2 Face Name:
9 F' M. ^$ [4 I0 @; U# jFace tag: 38479 Face Type: 1 Face Name:
3 g) Q1 Y% \) O5 R( M  a4 \Face tag: 38480 Face Type: 1 Face Name: - J% }9 X& _8 E$ ~1 j0 h# H
Face tag: 38481 Face Type: 2 Face Name:
0 e/ N) q3 s- r  o* D& ~% mFace tag: 41207 Face Type: 1 Face Name:
: x7 F. G; c( e# n, QFace tag: 41203 Face Type: 1 Face Name: $ ^% d9 W1 ^0 a: t; u) {" u
Face tag: 41158 Face Type: 2 Face Name: ; F+ Q. K# Z; x% N" P: E7 o
Face tag: 40987 Face Type: 2 Face Name: , O3 Z4 T5 b8 S6 j4 j$ \
Face tag: 41010 Face Type: 1 Face Name:
4 a: @2 K5 S3 @Face tag: 41001 Face Type: 1 Face Name:
7 U* [# k1 m# q# b* E& q9 CFeatures count = 7, h# a* ?7 h: F* v0 G7 F
features tag : 41280 features Type: SPHERE features Name: Sphere(17)
7 {' r6 S* ^, J) _+ [' Rfeatures tag : 41281 features Type: BLOCK features Name: Block(18); ~; p- t% \1 {7 Z7 c3 T7 B
features tag : 41307 features Type: CYLINDER features Name: Cylinder(19)0 l; f! j) Q' G* e$ @" w* R  X
features tag : 41314 features Type: CYLINDER features Name: Cylinder(20)
, B  H. U1 {8 Z" \6 o1 zfeatures tag : 41322 features Type: CYLINDER features Name: Cylinder(21)
" B' n- M# m* w7 W8 \' Cfeatures tag : 41330 features Type: CYLINDER features Name: Cylinder(22)
6 U1 O: H$ R) _features tag : 41338 features Type: CYLINDER features Name: Cylinder(23)  N2 [9 E( |" _) A9 E& o5 U- }
* D; ]* v2 g, J4 H; _. F. F
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了