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

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

admin 楼主

2013-11-4 16:53:51

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

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

x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息
4 Q  d+ H6 Z' m, Q4 K0 b; u$ k & d, H% R, g5 P- {% R
# ~8 ?# w/ z  {
  theSession->ListingWindow()->Open();
# H) J& d* r5 y4 [4 r) f0 |  theSession->ListingWindow()->WriteLine("Get information from all bodies\n");1 q5 Q! I3 i" h
     std::vector<Body *> bodies;
! C& D8 J7 m8 a  O  BodyCollection *bodyColl = workPart->Bodies();
/ H1 h% g: X( K2 s- J( h  for(it = bodyColl->begin();it!=bodyColl->end();++it)) s$ n! S  {1 A
  {3 {3 u' J  P( i1 z9 A
   bodies.push_back(*it);7 s% L& _0 S' s* j2 z; }
  }
8 L0 e2 F) U; ?6 F& [  ss <<"Bodies count = " << bodies.size()<< "\n";, ?+ K  a, V; X4 ]8 Z. T5 D
   std::vector <Edge *> edges;
" i# {# k: t4 [% p: U   std::vector <Edge *> totalEdges;% a$ w0 v: H& f( f5 V$ i
   std::vector <Face *> faces;$ @0 ]& [0 @3 \' F0 b
   std::vector <Face *> totalfaces;' E* J/ b/ E" a
   std::vector <Features::Feature *> Features;1 L5 C6 v6 C! l, m- L5 ]
   std::vector <Features::Feature *> totalFeature;
5 I; V: H* \6 p+ t, _   Point3d vertex1,vertex2;; ^1 g- G+ |% D$ a
   for (unsigned int i = 0; i< bodies.size();++i)) a8 o/ L- o* P) ?5 y
   {
# J! k, }) q$ U# I: E/ @" M    edges = bodies->GetEdges();5 X( |! A+ F1 g5 J9 P2 v
    faces = bodies->GetFaces();
) {# D1 w1 {; c7 C5 o1 d$ n    Features = bodies->GetFeatures();$ M+ Y& Q1 u1 V4 C5 r
     for(unsigned int j =0;j < edges.size(); j++)
. `: @  S( g  P     {: h  a" H; ?5 P
     totalEdges.push_back(edges[j]);
. n" R9 Y% N. j3 _     }
7 J$ ?9 \( {2 r8 [" t9 y     for(unsigned int j =0;j < faces.size(); j++)
* m1 r1 C) m" N     {" t* E7 M2 q- C: h5 I' b2 ^. I
     totalfaces.push_back(faces[j]);5 q4 _8 m$ `' p. t7 H2 a$ |
     }/ [+ w' A$ f8 g! W+ z
      for(unsigned int j =0;j < Features.size(); j++), Y, ^* n6 D: ~# l. \
     {
# W0 r  {! @! B, u( l6 l     totalFeature.push_back(Features[j]);; r. L- t! y7 z, x) t
     }1 ~7 L2 G* |7 B% L) A7 K
      
" Y8 x$ I% o2 C( j- M! S   }; U: x! e2 Z0 f0 G0 |: H
    ss <<"edges count = " << totalEdges.size()<< "\n";% S1 G: I5 K% g. M6 H6 L+ j. Q1 M
   for(unsigned int j =0;j < totalEdges.size(); j++). s8 E: T* \: f
     {   , p6 O: t' e8 U! t$ m* O
      totalEdges[j]->GetVertices(&vertex1,&vertex2);4 z, Y7 Z& \. p* F1 I
       ss <<"edges tag: " <<  totalEdges[j]->GetBody()->GetTag()<<"\t";
# M/ w- t9 {( D; N- A4 R+ x% y       ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";
2 r# b# K# n5 l; ^       ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n";
4 L$ C+ c, U5 m# t+ Q! J* T     }1 ?3 m$ S3 n0 ?3 C$ x5 D
   ss <<"faces count = " << totalfaces.size()<< "\n";) r& i7 K* ^+ L1 \+ }3 z
    for(unsigned int j =0;j < totalfaces.size(); j++)) s* f1 n9 o  i# Q* c& O2 }( F
    {  ; P7 U, f: B! R6 N1 b7 y/ V% b
     ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t";
: z  B% u6 h, V5 m/ [- n     ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";4 Q+ `8 R# {! t2 G: h
     ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";2 K& p% _  s+ g3 l: K8 z9 h
    }0 C- t  R# a; S4 G9 ~9 C3 L* d$ f
   ss <<"Features count = " << totalFeature.size()<< "\n";
: z5 o7 Y. w" u3 Y0 y     for(unsigned int j =0;j < totalFeature.size(); j++)
, N" g# ^. u, ^" [( S( X2 t0 w4 ^    {  2 H4 t# M, {/ p7 F& ?6 V$ p# g- q
     ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";! J; ?  `( }( D& A0 W# i6 k
     ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";$ T( I' `" H& S* V# P
     ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";( \; M7 p% N$ p. b$ m
    }
. O  x4 J9 q6 K( P  theSession->ListingWindow()->WriteLine(ss.str());
# _1 W! o3 \' l8 B
( L5 O. B, T' q/ ^  }# j8 R/ n& W3 L$ [# y& r* |9 f
查询结果如下:
# r4 ]/ T  O9 R6 D) k3 ?$ A2 W7 I( L& v. a" b6 A

5 @- T" D* k5 b' r( Z, N% h) C* n! @Get information from all bodies
8 \3 A% E& i' n8 B% S  g3 uCYLINDERBodies count = 7
, M7 l4 F6 l4 redges count = 22" m, Y1 @/ L1 l$ j9 _9 @9 \1 |
edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100)
8 B3 [# X3 d+ q8 V" Qedges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0)3 ]' q7 e3 S- Z1 J" L5 {) e3 p
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)
0 X* l  H4 w6 K/ e# Y$ M( H8 ^edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0)6 [+ V1 c7 u" t
edges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100)& j% s3 k; G. m$ w1 |
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)
9 f3 R+ ]6 T1 N, R/ G- Gedges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100)# i3 d  ]; @4 K, n9 K- `
edges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100)
4 V9 m7 L& I4 uedges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100)
/ Y1 S2 R, e% g  ^  medges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100)% i+ x) R! n6 @; I7 h
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100)3 ]- Q2 a8 i0 p
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0): [* M  X$ I" e5 `
edges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100)
% \' g2 U; M/ U) c& ^edges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)$ _0 O5 i1 `9 S( J  e
edges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)" {, c* M! I; k- w6 o: c, {+ ~
edges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)0 g- [! ?5 i( y3 q! T  ^$ o9 o  H
edges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)8 |4 Y" i6 e9 G+ i
edges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)
& h. ?) L& `: e, w6 \. @edges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)3 O& H2 ~6 I6 \. u! w) W, i( I
edges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500)" l% Y# B- _. Q
edges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200)# L$ Y) t* ]) q8 ^4 d
edges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)9 Y' }# J6 W4 F" Y* j- k' l
faces count = 22% _) M2 m3 ^- H. p( i( x4 m! x- i
Face tag: 41407 Face Type: 4 Face Name:
' M5 S3 `+ ]% V# f8 KFace tag: 41398 Face Type: 1 Face Name: $ D- K$ P6 t( ?
Face tag: 41376 Face Type: 1 Face Name: ) G4 w. V+ n+ @. N1 U. _) @$ p& D
Face tag: 41391 Face Type: 1 Face Name:
$ E# Y! M! f. J3 PFace tag: 41380 Face Type: 1 Face Name:
5 h  x* Z, S2 Q6 Y! L( Q7 JFace tag: 41396 Face Type: 1 Face Name:
( a" ^, O3 Q( z$ V# F7 |4 SFace tag: 41397 Face Type: 1 Face Name:
7 d- @0 a$ h& o: x# [Face tag: 40995 Face Type: 2 Face Name: 4 V1 O8 ^$ d4 Q, [; r/ h
Face tag: 40965 Face Type: 1 Face Name: 6 o7 Z+ N6 H& A5 j) S1 y$ {
Face tag: 40997 Face Type: 1 Face Name: : w7 T$ S% M! J, l8 O
Face tag: 41351 Face Type: 1 Face Name:
$ W7 @3 ?. C, w7 x, ]Face tag: 41352 Face Type: 1 Face Name:
' c; c& B/ C' E& H: d# oFace tag: 41353 Face Type: 2 Face Name:
2 n9 d  X/ m+ T6 v. ~Face tag: 38479 Face Type: 1 Face Name:
7 X7 p' w6 J' l# ~0 |2 \Face tag: 38480 Face Type: 1 Face Name: 1 p, J( U3 w1 k5 U* N! Z/ Y' \% M
Face tag: 38481 Face Type: 2 Face Name: 8 V" t: P! X% }# |/ _
Face tag: 41207 Face Type: 1 Face Name:
) R6 i6 C' m& e1 x1 d( bFace tag: 41203 Face Type: 1 Face Name: * s: b- k3 ]- p9 x; Z( ]. ?4 h
Face tag: 41158 Face Type: 2 Face Name:
1 J4 N$ R# o% B5 w0 V( l+ m& L3 UFace tag: 40987 Face Type: 2 Face Name:
( U. ^: P( [1 X. K5 B8 h6 w- [Face tag: 41010 Face Type: 1 Face Name:
9 s0 i' @2 Q6 q0 ^$ C7 U4 IFace tag: 41001 Face Type: 1 Face Name:
8 ^6 R/ `, F7 ZFeatures count = 7
3 ?" ]6 q+ O9 W2 T  l4 Kfeatures tag : 41280 features Type: SPHERE features Name: Sphere(17), Y- n- `6 u8 A" h* c0 f
features tag : 41281 features Type: BLOCK features Name: Block(18)8 P. Y8 h. o- {5 ^3 B1 k/ a( v6 T. ~3 B
features tag : 41307 features Type: CYLINDER features Name: Cylinder(19)
7 J. N  i; B$ Y5 S3 c# L- kfeatures tag : 41314 features Type: CYLINDER features Name: Cylinder(20)& G' m/ E" |4 }( R2 D: c
features tag : 41322 features Type: CYLINDER features Name: Cylinder(21)
6 i( |& Q, ~- {- pfeatures tag : 41330 features Type: CYLINDER features Name: Cylinder(22)
# l0 C: n& i# ifeatures tag : 41338 features Type: CYLINDER features Name: Cylinder(23)
' K9 {6 @7 ^2 q: {, X4 L
% ^. k3 q8 d0 L! q# |
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了