PLM之家PLMHome-工业软件与AI结合践行者

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

[复制链接]

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

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

admin 楼主

2013-11-4 16:53:51

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

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

x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息
8 v. R7 w) |& p4 p
: }: d4 e6 ^% ~% i$ w5 A
# n" I/ k: F" D) L  theSession->ListingWindow()->Open();
$ b( @0 J- B* Y, h1 F" {% w  theSession->ListingWindow()->WriteLine("Get information from all bodies\n");0 Y% b: y9 q" q' q% _2 F( A
     std::vector<Body *> bodies;
" U+ s* ^) a) E3 q9 t: S  BodyCollection *bodyColl = workPart->Bodies();" Z) B4 ^4 n% y  `* g; w: g! n
  for(it = bodyColl->begin();it!=bodyColl->end();++it)
* z8 {2 `4 ]. H3 r: ^  {9 X, N. g. ?: D+ g
   bodies.push_back(*it);
1 T1 b  q$ B2 O3 I! x# C0 w  }6 W) Y7 J5 N  U4 \" g% N5 Z
  ss <<"Bodies count = " << bodies.size()<< "\n";! V4 ]* p: t$ O& F8 a+ D
   std::vector <Edge *> edges;+ F; R# U: N) O4 @  w6 j8 l0 z0 U
   std::vector <Edge *> totalEdges;. e8 {- p2 W- v# |' n
   std::vector <Face *> faces;
6 I& b# w* c8 d3 ]   std::vector <Face *> totalfaces;' P1 d1 M9 b! m6 Z2 U6 S1 |1 A; [" I
   std::vector <Features::Feature *> Features;" V; f# t1 ?2 @0 N( U7 m: t
   std::vector <Features::Feature *> totalFeature;
. h  U8 D3 ]9 F0 A0 |$ E   Point3d vertex1,vertex2;
5 P' {- t5 l7 D' g" `( ^7 J" s   for (unsigned int i = 0; i< bodies.size();++i)) F$ m8 Y- {3 f- f  S
   {
3 [* f  _) t" D6 g( o+ O' i$ P# Z, i    edges = bodies->GetEdges();/ n8 ]% j' a  R7 M' M
    faces = bodies->GetFaces();
& ^( ~" F( @/ F) \+ S- d5 ?    Features = bodies->GetFeatures();7 f2 T0 B: q, ^% n. S& n
     for(unsigned int j =0;j < edges.size(); j++)$ G6 G2 D+ W/ S9 x9 Y2 m
     {
3 E' T7 A* N/ Q& U( `* W; ]" I     totalEdges.push_back(edges[j]);/ i, P, g+ k6 Z' Y
     }
) Q( ~; b/ F$ Q0 z     for(unsigned int j =0;j < faces.size(); j++)
. B5 u# X9 K  Y3 ]     {
  G( O; ^. O4 [0 w     totalfaces.push_back(faces[j]);
6 m5 X$ e) r8 G* {% ~  Q- ~     }% ]. z6 }$ U% R7 Y6 i, F( N. C
      for(unsigned int j =0;j < Features.size(); j++)% C9 d* o; l; K' x- X
     {/ e% y0 t, O9 ]" h% V
     totalFeature.push_back(Features[j]);
$ c6 k+ A8 o1 `/ ]9 c' {     }( b7 m! a' x% l' t
      ! K' h& V. P- k# D: J0 S& I4 ~6 n
   }$ L; F0 c- {' I9 z( @
    ss <<"edges count = " << totalEdges.size()<< "\n";7 ^+ t" r0 M" E/ |6 g
   for(unsigned int j =0;j < totalEdges.size(); j++)
' H; j; B: m+ o+ y7 ]9 ?     {   2 u" [' g  P. \* ^6 U, P' |
      totalEdges[j]->GetVertices(&vertex1,&vertex2);
* X& M# `/ z% k+ f/ E       ss <<"edges tag: " <<  totalEdges[j]->GetBody()->GetTag()<<"\t";
! Z5 `- h. m$ K; k8 ~       ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";
  K4 J  b" r3 N6 v       ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n";, V; j0 U0 u. ^
     }
0 |1 ?# E6 v# E; D. Y! o$ l+ O   ss <<"faces count = " << totalfaces.size()<< "\n";. ^9 A; w2 U, W( E) c
    for(unsigned int j =0;j < totalfaces.size(); j++)
# |- D, m' J) }* E    {  # M6 @% {6 a% s3 K
     ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t";/ e* U5 W' Q4 D, Z
     ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";
/ z  _+ w! o0 z7 u8 u1 N     ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";/ p" {% [; ^  R" n" I0 N% n
    }
0 C6 J( R0 y' J( {& ~( G$ _+ T   ss <<"Features count = " << totalFeature.size()<< "\n";
( u; Y2 e% U  U( K/ V9 w* s  i     for(unsigned int j =0;j < totalFeature.size(); j++)' ~- s* p- X" m0 Q4 `
    {  : \# ~: L" J1 S: t
     ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";
# c* [/ r4 p' c' f9 d     ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";. b, g5 i3 v$ f) f# d5 I5 Y
     ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";4 J* R+ S4 c' |9 ?9 X9 l1 t: [
    }6 u1 Q  b- g/ ~' B/ c9 U
  theSession->ListingWindow()->WriteLine(ss.str());' M7 P. O& `/ F4 T4 Q2 f: j

& _% W" R5 ?! ~7 \5 q! i! J# Y6 H$ @" T1 m& I' Y( r+ f, Q# E8 E3 o
查询结果如下:
& e4 U" R0 k4 p: M& i! N, x$ o% {0 z! @, s

/ t- s7 x4 k) F6 N$ P/ ]6 gGet information from all bodies
" v! ]: _6 Z$ p1 @3 Q& L  WCYLINDERBodies count = 7
* m# W" V* r! X9 w7 hedges count = 22- b: c: v. R3 i- z
edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100)9 }) B7 ?6 o2 G0 V
edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0)  a9 r) K$ I' t3 d3 S5 I0 H
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)0 S9 h9 U! h& h+ z. m5 m
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0)
$ f" V: }7 C. @: vedges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100)
6 O& A/ R% ]# B& Dedges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)2 {* @9 z" |1 c
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100)# z: j. T/ s1 j
edges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100)
. M2 |* P8 p; l$ Bedges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100)* ^& B3 Q5 b( ]4 w, ^, i* C
edges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100)% F( d- [  S8 k6 O8 Q5 w
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100)3 o" C7 x9 F% a+ Q: L$ m8 D
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0)" [. a% E2 ^* l* \
edges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100)& I# \# X& @1 [7 n0 A
edges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)4 V2 `/ F: U- a2 U# C# C) }
edges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)% Z- _- Q$ X0 M% y* {0 ^) w
edges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)! a7 \+ K) q! C9 c; {1 o, E. E# a% [
edges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)5 }. [! n/ l7 Z" S1 [8 X, @
edges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)4 P2 m7 Q. m* ]5 e7 a8 q0 U
edges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)
7 a8 I: y( }6 [; [edges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500)5 W# U# ?' X9 Q! A; T
edges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200)' r6 S/ K$ T, q) \% I
edges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)
, m# b! |2 y. w8 W  o* Yfaces count = 226 {, g+ g: b5 G
Face tag: 41407 Face Type: 4 Face Name:   A5 u9 h3 _) Q8 c
Face tag: 41398 Face Type: 1 Face Name: ' H; R7 Y  P# Y# z8 c: |
Face tag: 41376 Face Type: 1 Face Name: 9 Z- I4 [# p" j9 X- c/ o
Face tag: 41391 Face Type: 1 Face Name:
8 A/ F0 t# K3 P) SFace tag: 41380 Face Type: 1 Face Name:
2 F1 o; s9 J; sFace tag: 41396 Face Type: 1 Face Name: , V% p4 P. W6 G' h8 h) U; N  F
Face tag: 41397 Face Type: 1 Face Name:
/ o( ]7 g2 |9 h5 gFace tag: 40995 Face Type: 2 Face Name: + {; ~9 m. F" [
Face tag: 40965 Face Type: 1 Face Name:
! n  L  F# f  I* A8 y7 [" Q# hFace tag: 40997 Face Type: 1 Face Name:
+ m4 G( I0 `' s. ~5 F' g. x0 _Face tag: 41351 Face Type: 1 Face Name:
# m. X1 ~% r1 h4 ]$ [* m( P# eFace tag: 41352 Face Type: 1 Face Name: $ ^% F# [- b+ g9 A& G1 d
Face tag: 41353 Face Type: 2 Face Name:
6 ^1 t* `& K) s( [5 L9 @Face tag: 38479 Face Type: 1 Face Name:
: ~7 K9 Q3 r( O2 u9 _1 `' vFace tag: 38480 Face Type: 1 Face Name:
, e) U3 F  \1 U- H2 z0 k+ RFace tag: 38481 Face Type: 2 Face Name: ( T9 J* C/ C2 L; d& q
Face tag: 41207 Face Type: 1 Face Name: # ^& q( F& F' n' T) Y! [
Face tag: 41203 Face Type: 1 Face Name:
3 H& }5 n" g" S; {5 S+ z7 EFace tag: 41158 Face Type: 2 Face Name: 0 S2 b( Z) y1 j9 W( p; x6 B% S9 z8 v
Face tag: 40987 Face Type: 2 Face Name: 6 C% i/ ?/ R( T* z% a- w2 w& x
Face tag: 41010 Face Type: 1 Face Name:
3 f9 O) x7 P6 [4 h, f( H+ tFace tag: 41001 Face Type: 1 Face Name: ' |# ~7 f$ H% X; M
Features count = 7
; @: ]7 e3 y3 Zfeatures tag : 41280 features Type: SPHERE features Name: Sphere(17)
( I5 x% ]% i$ J0 b1 H  D- Mfeatures tag : 41281 features Type: BLOCK features Name: Block(18)
: }: c0 {3 m0 T/ {features tag : 41307 features Type: CYLINDER features Name: Cylinder(19): S" e' t- _2 z* X* _' E. X) b
features tag : 41314 features Type: CYLINDER features Name: Cylinder(20)5 N$ Z/ D% M" |- n. o7 v& G
features tag : 41322 features Type: CYLINDER features Name: Cylinder(21)
6 x0 Y5 `" ^9 v) Q( mfeatures tag : 41330 features Type: CYLINDER features Name: Cylinder(22). a. A/ a' e6 S5 Q5 w( X- R! |' j
features tag : 41338 features Type: CYLINDER features Name: Cylinder(23); A- c+ l* T8 P0 s! O; c$ ^: e
1 k) a# n9 b. V7 N# J3 p; m
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了