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

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

admin 楼主

2013-11-4 16:53:51

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

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

x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息
! w- ]; F9 \( X- A
$ M3 y% t# x) A0 F- a' [7 b( w
, {9 C8 @# V+ b, D$ W6 \  theSession->ListingWindow()->Open();
: z. l% A7 N! `) f  theSession->ListingWindow()->WriteLine("Get information from all bodies\n");
4 H$ Q! P0 a& M! F     std::vector<Body *> bodies;
* f0 R- S3 g! n, a  BodyCollection *bodyColl = workPart->Bodies();
) a- k# J. x4 v  L0 a6 i  for(it = bodyColl->begin();it!=bodyColl->end();++it)+ D, T5 j' R2 e' [( V+ y  Q
  {& F7 V2 z) Z' Y- M: t* Y' c
   bodies.push_back(*it);
+ \' }( Z8 O( o% Q* ]9 n  }6 [4 `  A) q$ ~
  ss <<"Bodies count = " << bodies.size()<< "\n";8 t- |6 [' u7 _: M* |0 _! S
   std::vector <Edge *> edges;# B, g2 s( Z' C2 m6 v
   std::vector <Edge *> totalEdges;8 k. ~: n2 K; D& Q; w
   std::vector <Face *> faces;
9 V- }/ w. K* X  O4 I   std::vector <Face *> totalfaces;: P. J9 j& X) M
   std::vector <Features::Feature *> Features;& J3 O5 z3 }) X# o- f0 L
   std::vector <Features::Feature *> totalFeature;" |7 N/ j( P  |/ l! `' H7 S3 y0 g( e5 \* \
   Point3d vertex1,vertex2;
" e% c) a2 v3 ^4 P   for (unsigned int i = 0; i< bodies.size();++i)
1 Z8 r: p1 y! k, }7 Y   {
( `" x/ p+ [+ y( g7 s  Z    edges = bodies->GetEdges();
2 F& V, N- q+ r5 F7 m    faces = bodies->GetFaces();
" j+ {8 s& q+ |$ }: h6 S0 X: r0 T    Features = bodies->GetFeatures();
# j* U7 W) Z+ V' s& r     for(unsigned int j =0;j < edges.size(); j++)
' W& T3 i, R3 A( x1 V     {, O5 w2 d" Q! f6 l8 L0 h
     totalEdges.push_back(edges[j]);
2 _# t7 L9 A+ i7 w$ |     }2 I# w9 B* m+ a) @: g' }  b# t: B; l
     for(unsigned int j =0;j < faces.size(); j++)
( l/ m% F* h6 n0 S7 V/ }, }     {
# y. @8 b& q- I; X! h' j     totalfaces.push_back(faces[j]);( q+ e( [, }2 @$ T# _; h
     }
; P& W, w  C& p4 O. H( `: m      for(unsigned int j =0;j < Features.size(); j++)
. e1 S: D' G3 G2 s" P/ s     {: L3 ^# |3 i3 b3 J7 X; L0 p
     totalFeature.push_back(Features[j]);: ?$ g9 t) i; R" w
     }
3 ]( `5 Z9 c7 Q6 k      + x9 r9 {3 i) R" ]
   }+ t& c6 |3 J8 d7 T6 d
    ss <<"edges count = " << totalEdges.size()<< "\n";
, J) N8 |( _" I2 i7 x& d   for(unsigned int j =0;j < totalEdges.size(); j++)+ s) X2 S* q( N1 b
     {   * w# X! Q; m, l
      totalEdges[j]->GetVertices(&vertex1,&vertex2);
. y# C4 Z- z, {3 I8 L6 w       ss <<"edges tag: " <<  totalEdges[j]->GetBody()->GetTag()<<"\t";
  L& }' O/ J' F1 h8 d+ p       ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";5 Z' u- @+ n/ G5 c
       ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n";2 B+ O+ ?* Q6 \5 ~& D& o3 P" Z
     }
  m9 V* @* u7 d4 J- D; m& k   ss <<"faces count = " << totalfaces.size()<< "\n";) A, ^* b6 B4 r/ a
    for(unsigned int j =0;j < totalfaces.size(); j++)
& t! f8 L2 G9 \. a/ b' {    {  ; W. o/ C: a1 @
     ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t";1 Y+ H; S. i& b
     ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";
  F' b& U7 b$ X) p8 {% Z! r     ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";
7 r, I( `8 t0 y6 `6 X- f    }3 g" Y- R( a' [9 b1 F& n. X
   ss <<"Features count = " << totalFeature.size()<< "\n";, E' H; v' j) q. U0 o
     for(unsigned int j =0;j < totalFeature.size(); j++). y, I+ I+ j! ~" T$ z- `
    {  5 _8 |9 g9 M5 ~# H, v- h
     ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";
+ `" {" O& l3 c: u1 V     ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";
! `) I4 t" x4 M     ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";! Q0 j5 @+ Q7 l  G0 t$ A9 p$ X
    }- ]$ T0 r! R+ e. k! F
  theSession->ListingWindow()->WriteLine(ss.str());5 H& [2 D/ {+ x9 t
$ X% J) C8 \. @, a9 W" P

9 T9 o5 C9 i! d  C查询结果如下:% P+ n1 Z: X9 O: t/ ]

. P3 H% W# a1 S" P4 o* R$ ^( z" l  X
Get information from all bodies7 ]3 z6 ~2 q1 k3 f, M( H/ Y
CYLINDERBodies count = 7
7 k- k$ t. L" Z  ?' E. zedges count = 22
' y8 ]- V2 X$ a: E0 w/ C& jedges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100)
1 l1 A* H  G% t! d" `1 qedges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0)2 |* |) Q) P. q
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)+ M. e2 U  P/ a5 x
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0)7 p  ]3 V8 S8 K
edges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100)
# ?: V, U8 N0 P7 r* X  L4 O) eedges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)3 W: U, Z' Y" Y  d
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100)* `9 a& F$ Z0 `  ~0 A
edges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100)
0 F: X! J% j2 A$ H" x5 V: ]) hedges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100)
5 R, E3 W9 |' i: ]5 I( B. R7 K' N3 F7 uedges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100)3 ]6 x; ^: C3 v+ _; y8 g# Z
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100)
* D2 D; ~1 }3 T' w0 @/ x) Y3 pedges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0)
+ [# S) a) Z4 d, E. dedges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100)
" J1 Q1 ~! C; uedges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200): N, W$ Z# d6 |% ?; `7 Q
edges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)  S6 Y. G2 W6 W1 [4 i7 n
edges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
/ l' S( P: r& r+ i- ^8 cedges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
# H7 L  q9 B) x2 A) t' A% ?0 e; ^edges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)
- u9 E5 F5 h0 w; Z$ Bedges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)5 a& k! v0 d+ Z6 w4 y, Q
edges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500)# O- X. b2 q: c' h) i7 h
edges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200)/ ~0 W7 W( ^# h8 V1 Z. M
edges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)
3 M4 E# S" e- A9 }faces count = 22
* V# J0 |8 Y; wFace tag: 41407 Face Type: 4 Face Name: 8 m# D/ K1 ]+ B
Face tag: 41398 Face Type: 1 Face Name: + c& B3 Y/ F, ]" J( [6 t
Face tag: 41376 Face Type: 1 Face Name:
. {% Z8 R9 n8 eFace tag: 41391 Face Type: 1 Face Name: " M/ d7 x! t( _( B
Face tag: 41380 Face Type: 1 Face Name: 3 ^' _: p0 O3 M8 ?( p
Face tag: 41396 Face Type: 1 Face Name:
* S8 m. R- T5 [, X7 o/ k2 J+ AFace tag: 41397 Face Type: 1 Face Name: 4 r" G5 `4 V6 A5 j+ S- O; i
Face tag: 40995 Face Type: 2 Face Name:
) E8 r( [3 u+ ^% }Face tag: 40965 Face Type: 1 Face Name:
) u8 n( b. T) S1 |0 f4 p1 }Face tag: 40997 Face Type: 1 Face Name:
5 N" h: J* g  D4 \. wFace tag: 41351 Face Type: 1 Face Name:
) z" \/ V  P6 ~4 U2 p5 c3 h# RFace tag: 41352 Face Type: 1 Face Name: # [6 V6 q) J- j- o! J0 z+ ?2 z
Face tag: 41353 Face Type: 2 Face Name:
3 t5 x2 f8 y! L2 Q* C) K1 vFace tag: 38479 Face Type: 1 Face Name:
3 {: s, E& E" [; @$ b" z& \Face tag: 38480 Face Type: 1 Face Name:
  t* j; K8 j( zFace tag: 38481 Face Type: 2 Face Name: - a" |% h8 P4 \& F4 [
Face tag: 41207 Face Type: 1 Face Name:
+ d$ b! b" `1 ^- q. w- WFace tag: 41203 Face Type: 1 Face Name: ; t# A4 W+ }6 c, b
Face tag: 41158 Face Type: 2 Face Name: ) J- q+ Q7 }5 i. ~
Face tag: 40987 Face Type: 2 Face Name: / r1 A5 f! q  I: \5 y; E4 E
Face tag: 41010 Face Type: 1 Face Name: - Z; z9 }" U2 u6 F$ Q
Face tag: 41001 Face Type: 1 Face Name:
+ z& |) L0 [4 o% z$ G6 Y3 ~( k# j) IFeatures count = 7* {* U; I; g  ?' y
features tag : 41280 features Type: SPHERE features Name: Sphere(17)
( t- d, @, ]% h9 [& s0 m! B; Zfeatures tag : 41281 features Type: BLOCK features Name: Block(18)
9 A& Y# I3 g( ?features tag : 41307 features Type: CYLINDER features Name: Cylinder(19)
& d; c" x. ~6 |* b" P% e2 \0 afeatures tag : 41314 features Type: CYLINDER features Name: Cylinder(20)
( H2 R3 x- y' h# M4 T: y5 |features tag : 41322 features Type: CYLINDER features Name: Cylinder(21)! U. R4 e! I+ g( a% Y
features tag : 41330 features Type: CYLINDER features Name: Cylinder(22)8 x8 ^+ O, |. S% @$ A
features tag : 41338 features Type: CYLINDER features Name: Cylinder(23)
$ c( P3 C8 k% f* L+ D' w
+ [1 P  S; @# e! I0 A
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了