PLM之家PLMHome-国产软件践行者

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

[复制链接]

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

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

admin 楼主

2013-11-4 16:53:51

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

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

x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息: U# a& P# A8 N) z8 v! B: J" @

5 O+ X$ @5 ~, d" m. P( f3 }- _0 B* h
  theSession->ListingWindow()->Open();
8 l# q7 i7 y/ }9 P$ `, Z! S& @  theSession->ListingWindow()->WriteLine("Get information from all bodies\n");+ i4 T* w. S7 k$ A7 z9 c8 j4 D
     std::vector<Body *> bodies;
7 _$ l1 x4 u, q% e! b  BodyCollection *bodyColl = workPart->Bodies();: T9 C$ ^; Z7 r+ @: J# c) w2 S
  for(it = bodyColl->begin();it!=bodyColl->end();++it), j1 J; |1 y! ^8 N
  {8 _) P0 M8 E" [! q
   bodies.push_back(*it);2 M$ r# ]1 N' t' Q5 b- w3 \* ^6 p* R
  }/ n! u# o0 h% M: H. X0 Q) K
  ss <<"Bodies count = " << bodies.size()<< "\n";% x+ @. {  g/ L% B' x
   std::vector <Edge *> edges;
" }2 t4 F" A) J   std::vector <Edge *> totalEdges;$ T/ g  |4 p, P/ H5 D! O
   std::vector <Face *> faces;: g- }  z4 U  i" n1 L; X
   std::vector <Face *> totalfaces;
( ]1 ]7 x5 \" J8 `8 Z2 z   std::vector <Features::Feature *> Features;  M% w3 j' b6 X
   std::vector <Features::Feature *> totalFeature;" \1 r1 Z0 k( @' V. x
   Point3d vertex1,vertex2;
* A" }$ X* o+ m0 m, k; j# ^4 P   for (unsigned int i = 0; i< bodies.size();++i)
" S1 `& Q/ F$ a9 P   {; r) \" T! E' r9 ]( [8 m, E
    edges = bodies->GetEdges();* I: Y" z1 C2 s, Z; s) [
    faces = bodies->GetFaces();# {0 [9 ^$ u& P/ ?: S
    Features = bodies->GetFeatures();, B; ?6 d( R! M
     for(unsigned int j =0;j < edges.size(); j++)
8 W( ]0 O4 ]- Z% b; ?; R) d     {2 K( {: v, t/ V% k' a  ^7 Z1 f
     totalEdges.push_back(edges[j]);
; i: N: C0 S# ^8 F2 t3 m( O2 f+ x     }
  F% y- k/ o4 K) V4 h. K     for(unsigned int j =0;j < faces.size(); j++)
% l. M/ f& U# i8 e3 Z% [. I: l8 }     {
1 H0 t) R; m( N9 Z& V- g     totalfaces.push_back(faces[j]);0 ]3 _/ Z) J" Q) v) y6 F$ w* |
     }' X) h9 R: [1 {, X
      for(unsigned int j =0;j < Features.size(); j++)
4 J1 A' R. S# `! }7 l$ X( t     {$ Q# e, Z0 o7 k. E1 n
     totalFeature.push_back(Features[j]);6 x) M, P2 s+ d+ @
     }3 W8 }7 {, Q6 j7 m  F3 y
      
/ S3 o  k- ]6 |3 Y0 l5 c   }
7 g2 u, |5 \' I2 e    ss <<"edges count = " << totalEdges.size()<< "\n";# a* h  _7 y/ k! k% p/ ]& L) Z
   for(unsigned int j =0;j < totalEdges.size(); j++)' Z8 ?' b1 t% }- x" t
     {   ) k, {* r$ w* S# n
      totalEdges[j]->GetVertices(&vertex1,&vertex2);8 r  j! B8 o# g1 U2 V- A$ O
       ss <<"edges tag: " <<  totalEdges[j]->GetBody()->GetTag()<<"\t";
6 y+ L& A/ u1 X5 r       ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";
6 a, |* b/ |: J. P( i+ ~       ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n";' p3 b& N  v% W# V% S: |* Y
     }
; ~: h4 E$ e- Y$ a   ss <<"faces count = " << totalfaces.size()<< "\n";  m. @- x) _# e9 T8 T
    for(unsigned int j =0;j < totalfaces.size(); j++)/ @) O: D3 `) f  ], e" b
    {  
% |" }; P2 L$ L     ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t";7 n4 q! b' L3 h: @
     ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";
4 v, h' V9 l- a0 m' {     ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";& y; w  N2 r* z; c1 _2 |0 W
    }
$ X5 }( q& ~/ w3 ^1 P6 a' a; |. Y   ss <<"Features count = " << totalFeature.size()<< "\n";
" J1 X" P4 E9 f: K+ P- d# C     for(unsigned int j =0;j < totalFeature.size(); j++). x' F" l0 `8 n8 \* @. V
    {  
4 N1 D# n3 Y4 `! s& Y7 N     ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";0 K5 p6 d, R2 y, w
     ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";
/ W' ~; z( Q0 x& v2 v; H     ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";
& M! r/ @  Y6 `9 V& F  N    }* @1 j0 E7 X! m# w1 i
  theSession->ListingWindow()->WriteLine(ss.str());3 b, I$ m0 a; z5 M9 b% e8 `* u
2 t: P4 g/ Q/ d7 ^

8 Y- W, q( f- `! G9 N' _查询结果如下:
- `9 I  o/ }( d7 k, M' C! _1 |; y7 u" k1 O+ H
2 U" m3 @, L4 A
Get information from all bodies
, D0 D& ~  N5 X, X; bCYLINDERBodies count = 7
- z9 m4 n, W' b: O' f1 f) ~' Hedges count = 22
7 ~/ Z5 I- t- J0 s: ?edges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100)
. }5 [2 o" V- h' P) s3 P) E- redges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0)
) e# g- u/ x/ r6 oedges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)7 [$ Z5 i' X/ C+ s6 }
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0)
, ?' b: M  A5 ?' medges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100)
% w' k; E6 T1 C) i, i3 \edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)8 w" q! j2 z9 D8 l
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100)
( s4 \$ n( a: H' L* D& h! ledges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100)
$ j  w1 B& i! I) q- }$ o; fedges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100)
* t, W4 d% @) Y6 x' E* D* ledges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100)1 ], H- Y% _) L9 j; m
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100)7 @' G; n2 d. _0 W$ }$ L5 Q
edges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0)
  b5 Y3 q: z' I1 Xedges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100)9 Z5 B0 m. }6 Q& K
edges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)( J0 r  _7 q' [  ^3 R8 D
edges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)
2 k; w1 u/ |! q, `, Sedges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)* w2 o7 [- w: W2 u5 F- A% L
edges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
% B! P) v/ \: k$ z" `2 Z5 cedges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)
. F# O' a7 D, u- Medges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)" f9 s# a' [3 A" b* k/ Y- W; o
edges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500)7 \7 Q( f8 W* T4 F$ m: g
edges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200)9 A1 S4 M6 C7 C6 @7 ]
edges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)
+ J. ?, y9 n! {: N5 l& ifaces count = 22; y4 ~) j. E+ G+ `4 @3 M5 Z
Face tag: 41407 Face Type: 4 Face Name:
% y2 B" k2 H2 c0 v9 Q; ]; {Face tag: 41398 Face Type: 1 Face Name:
. q$ c: t7 L$ |5 }+ E0 N, Y, U% {: GFace tag: 41376 Face Type: 1 Face Name:
! ?0 a* h4 j( G& b! YFace tag: 41391 Face Type: 1 Face Name: 7 _# ]) F5 q2 G8 a
Face tag: 41380 Face Type: 1 Face Name: / x9 J9 b0 y& K( Z5 I+ R
Face tag: 41396 Face Type: 1 Face Name: ! d. A4 S3 g1 b2 }+ v
Face tag: 41397 Face Type: 1 Face Name:
7 X1 A6 w0 W6 N4 h/ v' m# vFace tag: 40995 Face Type: 2 Face Name:
. w( X' V" |% D( ^% W& lFace tag: 40965 Face Type: 1 Face Name:
6 E0 P- M* j/ Z3 c  a3 m; _8 O, kFace tag: 40997 Face Type: 1 Face Name:
3 W, m: @; R  G3 {Face tag: 41351 Face Type: 1 Face Name: 7 ]% V+ y: Y5 ^* E& a
Face tag: 41352 Face Type: 1 Face Name: ; n' x8 q3 {+ i
Face tag: 41353 Face Type: 2 Face Name:
% p2 k- e) g5 X3 Z. f$ z9 iFace tag: 38479 Face Type: 1 Face Name: 3 T" m) B9 f7 R5 |( m+ p& s" e. R) E& C
Face tag: 38480 Face Type: 1 Face Name:
+ a" `- `* I8 x. c4 ~& S; x: c- cFace tag: 38481 Face Type: 2 Face Name: ' G: J; z" u2 O9 G
Face tag: 41207 Face Type: 1 Face Name:
% p6 ?3 d4 H( fFace tag: 41203 Face Type: 1 Face Name: ' X" T) w3 m; F, {4 V( m
Face tag: 41158 Face Type: 2 Face Name: + [# T$ p) D0 q$ q
Face tag: 40987 Face Type: 2 Face Name: 8 ]) W& k2 G. \9 U! z# Y
Face tag: 41010 Face Type: 1 Face Name: # n. i3 F# T( p: n  G7 [9 X
Face tag: 41001 Face Type: 1 Face Name: $ I% E- Q% U6 D/ j
Features count = 73 h1 v1 Z$ N! T' i. V& y* J
features tag : 41280 features Type: SPHERE features Name: Sphere(17)4 B% {: k# R, R
features tag : 41281 features Type: BLOCK features Name: Block(18)
' h1 N% j9 Y- I. A" Q: G: rfeatures tag : 41307 features Type: CYLINDER features Name: Cylinder(19)
: G1 m9 ?+ p, Gfeatures tag : 41314 features Type: CYLINDER features Name: Cylinder(20)( O6 `# G( o- Q1 C9 P+ w# _
features tag : 41322 features Type: CYLINDER features Name: Cylinder(21)
/ T7 Q8 y2 I; W/ T' ^( ?features tag : 41330 features Type: CYLINDER features Name: Cylinder(22)  v/ P/ m5 N2 G% o# L
features tag : 41338 features Type: CYLINDER features Name: Cylinder(23)) A) V8 }% S1 v
, A0 L. k4 b, B4 n
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了