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

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

[复制链接]

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

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

admin 楼主

2013-11-4 16:53:51

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

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

x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息' h! U; ?# v6 x2 I* R

2 }  o  `' j" Y; s2 Y0 ^6 F" {* e, l* F4 h8 V5 F/ H# O4 H+ ^) }
  theSession->ListingWindow()->Open();
( z7 y7 {; T% X, ~6 O& f" X  theSession->ListingWindow()->WriteLine("Get information from all bodies\n");
0 @- d5 `( \& C+ X# ]3 E- i     std::vector<Body *> bodies;
9 g4 n7 P1 k9 {! Q( R' s  BodyCollection *bodyColl = workPart->Bodies();: s4 U/ o7 \5 Y$ t  u
  for(it = bodyColl->begin();it!=bodyColl->end();++it)
, F" ^5 q6 z/ Q  {# V; x! d" d0 F
   bodies.push_back(*it);2 [6 v2 v) _: b' `: V
  }
- ^- k& N' E4 ~' e' ?7 j8 i  ss <<"Bodies count = " << bodies.size()<< "\n";; o5 p: x/ Z6 t% q6 n
   std::vector <Edge *> edges;# b# P3 H2 S, g" e: |$ e) \( }; f6 f
   std::vector <Edge *> totalEdges;) `7 ^; |- ~- d2 U! s
   std::vector <Face *> faces;
# e; H  r( E5 L/ F" G6 z: x& }   std::vector <Face *> totalfaces;
7 h6 w+ m/ N! p1 V   std::vector <Features::Feature *> Features;
& o: f! z  _2 y. {4 _   std::vector <Features::Feature *> totalFeature;% ^  A' _% Z: \1 y5 F
   Point3d vertex1,vertex2;
) x+ g! R- F9 B8 H" I   for (unsigned int i = 0; i< bodies.size();++i)# i' n: `3 }0 A9 p5 m: B2 R
   {5 H7 Q- D# B% o/ i$ k
    edges = bodies->GetEdges();
. J5 \, a5 u9 q8 v    faces = bodies->GetFaces();
, z) l! Z( a! t' b1 U5 e    Features = bodies->GetFeatures();2 T$ _$ m1 `. ~2 U1 l$ R
     for(unsigned int j =0;j < edges.size(); j++)( ~/ Z; x% }1 c  C. n* M0 d
     {
& O" V% h. a! @     totalEdges.push_back(edges[j]);3 }: d" i9 T; e* U1 Q
     }
9 B& p9 H/ u, O     for(unsigned int j =0;j < faces.size(); j++)! P; g+ u( ]$ s# Q- n9 _
     {
# \9 c6 g; b+ d( ?     totalfaces.push_back(faces[j]);
3 J. ]  Z* f, F# d; U! }     }( x( M$ G) [' X
      for(unsigned int j =0;j < Features.size(); j++)$ n. x- y, K/ i! U/ k& Y+ d
     {: I) |) V, V1 u* x. W
     totalFeature.push_back(Features[j]);2 v- ?1 y0 z9 L& w- @
     }
" h8 c7 b1 N: P+ f      
/ x% O8 s; e/ U. a# W6 S   }/ k$ o" g; q4 ^9 Q
    ss <<"edges count = " << totalEdges.size()<< "\n";' U2 T  S- y! Y1 f7 S. C! J5 U4 a
   for(unsigned int j =0;j < totalEdges.size(); j++)
& h: D- D* z( E& S4 Y# h8 t     {   & }  v! K1 j, y) f
      totalEdges[j]->GetVertices(&vertex1,&vertex2);
7 e' l1 H% Y, ^  n! P       ss <<"edges tag: " <<  totalEdges[j]->GetBody()->GetTag()<<"\t";/ q) p/ {/ R, j3 c5 X! m' A
       ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";! v+ ]$ X3 m- p6 k+ J
       ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n";" l) ]: \& E( O# A) E
     }
5 [0 U; o+ Q# W6 Y" H, A9 W1 v  w   ss <<"faces count = " << totalfaces.size()<< "\n";
) \' ~0 T: S- \7 R% a    for(unsigned int j =0;j < totalfaces.size(); j++), D/ ]  g) z0 Y) ^2 r, b( o1 v% |
    {  " i" Y5 Q: g5 g# o3 R6 E; h; Z' v
     ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t";
/ @& A! Y5 h: A7 L) b1 I$ j8 g     ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";) B+ S5 ^: U& Q6 I' P
     ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";9 i# h, v, f% X
    }- p, `3 u# c- k: `* B5 m' O8 C
   ss <<"Features count = " << totalFeature.size()<< "\n";
. |) L$ [; ]4 w  _     for(unsigned int j =0;j < totalFeature.size(); j++)
% ?: }1 r3 o1 R3 {* ~7 S    {  
5 L- \1 F2 n; \% H     ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";) e8 K4 x6 A* M9 h9 N; m
     ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";
# }/ g5 U: _1 U) g2 U) O! b' k     ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";' ?2 h, {' C, G. x
    }4 [% Y0 u- s4 J
  theSession->ListingWindow()->WriteLine(ss.str());
, e* Z7 x% R6 e7 r) G( B8 y1 @  D- a( Y0 f2 c
7 {. |7 D* h# ]& O. o1 k
查询结果如下:
  e3 `  Q' I5 K# C) ]
& i8 x. c' V8 O8 y6 S" e, n- z  A6 ^# ~. }: V7 \
Get information from all bodies2 n# G6 n) R' \  i8 ^6 T
CYLINDERBodies count = 7# S- F7 ]8 C+ x! i
edges count = 22% I* R  M3 p. N" {1 ]8 Q
edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100)
. ]; {! c  U' o- l, h) ^8 n4 C2 ledges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0)
+ i/ L& w7 {& @1 Q/ Z4 j1 c0 tedges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)+ K4 I4 H5 [1 S/ U- k( X) q& _
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0), o* J( j: ]* w9 e! [$ S
edges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100)
' g0 X- X) G# Tedges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)
* T7 z/ ]" F+ _4 Q& bedges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100). n! a9 o! s- }
edges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100)
4 L6 g; N' B. c7 }. Q1 Hedges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100)6 f" }9 n, S, T! p, h
edges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100)1 Z; w, H% _" h
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100)% T$ l( {1 n2 f( ]
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0)
5 j6 ?- s9 C- `: R) v2 `edges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100)7 Q5 G( x0 N0 y/ H! p' X! i. B
edges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)
2 n) c9 _$ c( r) T  Redges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)0 ~; l: L/ n6 r/ M
edges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
: p3 O3 ?# g; G+ J2 Cedges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
1 b/ j8 `+ T" q5 Iedges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)
4 A0 ~2 a/ V6 A1 k2 eedges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)
/ I+ R$ b5 @8 Cedges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500)+ X5 {( E; z, N  B, ?6 Z# J8 X
edges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200)
2 x( M1 r, v1 B* I' P- e) [7 m9 Iedges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)) i7 y  {# x8 _& k
faces count = 22' R/ I2 R; g! z* {+ C# d
Face tag: 41407 Face Type: 4 Face Name:
) v/ q% a) t, sFace tag: 41398 Face Type: 1 Face Name: ' v$ p: h* h/ H$ G" G
Face tag: 41376 Face Type: 1 Face Name:
4 Y7 i; s5 r* T' tFace tag: 41391 Face Type: 1 Face Name:
! F# G; _7 J: T5 a; lFace tag: 41380 Face Type: 1 Face Name:
5 A# J, N) D, H5 Z6 NFace tag: 41396 Face Type: 1 Face Name: " l# E6 c/ p8 p+ K+ }0 M7 `
Face tag: 41397 Face Type: 1 Face Name:
3 O4 y% c) W) p) sFace tag: 40995 Face Type: 2 Face Name: ' B5 Q; P' q* H3 K
Face tag: 40965 Face Type: 1 Face Name:
1 G# z# ~8 U: q: tFace tag: 40997 Face Type: 1 Face Name:
; x  `! q/ p$ q9 e: ~/ AFace tag: 41351 Face Type: 1 Face Name: 7 B! F* n+ A$ @  d- }8 N( a* E7 A/ v+ n
Face tag: 41352 Face Type: 1 Face Name: ) o: y- C& J3 l5 [( X' x
Face tag: 41353 Face Type: 2 Face Name:
0 B4 N5 \8 L( c4 W2 u( p; DFace tag: 38479 Face Type: 1 Face Name: 5 ]0 L5 ?4 i6 @9 K
Face tag: 38480 Face Type: 1 Face Name:
! }9 U; B+ s: [! Q' uFace tag: 38481 Face Type: 2 Face Name: 9 P/ z( g( w1 N2 q1 m7 Q; C
Face tag: 41207 Face Type: 1 Face Name:
( x) v. @! D/ EFace tag: 41203 Face Type: 1 Face Name: # }2 ~) ^- c& E$ V5 p- ~
Face tag: 41158 Face Type: 2 Face Name: 7 \+ B  q0 `& x& r- U
Face tag: 40987 Face Type: 2 Face Name:   a7 G1 E2 \! c, [4 ^/ b- {5 s/ y
Face tag: 41010 Face Type: 1 Face Name: ( L1 ^4 H: R* ~! [% w: M8 w; _
Face tag: 41001 Face Type: 1 Face Name: ' a6 |7 z$ d2 Y
Features count = 7
6 ?- [; `8 {% `" ?( w1 M- ?features tag : 41280 features Type: SPHERE features Name: Sphere(17)
, J6 L+ `  ^1 D# {features tag : 41281 features Type: BLOCK features Name: Block(18)
( T7 m) s6 a3 L* W% Gfeatures tag : 41307 features Type: CYLINDER features Name: Cylinder(19)& p6 W6 m) I7 [0 U
features tag : 41314 features Type: CYLINDER features Name: Cylinder(20)
; u% h+ s$ C+ x6 Mfeatures tag : 41322 features Type: CYLINDER features Name: Cylinder(21)
, `/ r; t/ g2 P0 g2 mfeatures tag : 41330 features Type: CYLINDER features Name: Cylinder(22)
( s) [" ^8 r% _features tag : 41338 features Type: CYLINDER features Name: Cylinder(23): z" n  e/ v0 a! M) s1 F* }

! N! X) y/ ]  v6 f
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了