PLM之家精品课程培训

PLM之家精品课程培训

联系电话:18301858168   |   QQ咨询:939801026
NX二次开发培训

NX二次开发培训

UFUN/NXOpen C++和实战案例

适合初级入门或想深入了解二次开发的工程师,本培训结合ufun,NXOpen C++,大量的实例及官方内部的开发技术。
公众号二维码

关注公众号

点击扫描二维码免费在线高清教程

课程详情
Catia二次开发培训

Catia二次开发培训

市场需求大,掌握核心技术前景广阔

Catia二次开发的市场需求大,人才稀缺。掌握开发技能潜力巨大,随着经验积累将在汽车、航空等领域有所作为。
B站二维码

在线原创B站视频

点击关注工业软件传道士主页

课程详情
Teamcenter培训

Teamcenter培训

全方位培训,从基础应用到高级开发全覆盖

涵盖用户应用基础培训、管理员基础培训、管理员高级培训及二次开发培训等全方位内容,由多年经验讲师打造。
QQ群二维码

加入同行交流

点击扫描二维码加入QQ群

课程详情
×

PLM之家plmhome公众号

课程涵盖: PLM之家所有原创视频

×

关注B站视频

所有高清视频一览无余,全部在线播放学习

×

加入PLM之家QQ群

同行交流,疑问解答,更多互助

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

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

[复制链接]

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

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

admin 楼主

2013-11-4 16:53:51

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

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

x
UG NX 二次开发源码分享:遍历所有的实体得到边面特征信息3 f( p% U& a9 l6 \) C/ O! Z

. y. S# D0 Y1 T/ z$ {5 |7 I2 v
6 h7 ]) X7 {( s( l2 E" S  w3 ~  theSession->ListingWindow()->Open();
& Y4 z1 `3 r# L7 n, ~  theSession->ListingWindow()->WriteLine("Get information from all bodies\n");) r" C/ I+ P& g3 R! a4 Z1 e" D4 t
     std::vector<Body *> bodies;
; e6 j9 g0 ?  \2 E  BodyCollection *bodyColl = workPart->Bodies();$ y  o% G/ Z9 x9 V9 b1 o/ q
  for(it = bodyColl->begin();it!=bodyColl->end();++it)
' D5 z4 O3 I. T  {; z  ?) [, W* w* V' L8 x
   bodies.push_back(*it);5 M# m0 f2 g. `- E7 ?8 t' }5 i# X' P
  }
: }$ [- x) m* ^, x  ss <<"Bodies count = " << bodies.size()<< "\n";6 ^- F/ v; h" p
   std::vector <Edge *> edges;
$ ?" o2 |8 |: _% {3 H0 d6 n- X   std::vector <Edge *> totalEdges;
) d4 h/ C( t! f+ l) X: ^   std::vector <Face *> faces;
1 Q- l) \4 [9 ?( _' {/ t   std::vector <Face *> totalfaces;! g: l, p1 k% K2 g' f* V
   std::vector <Features::Feature *> Features;% q. R% H$ R' S& C7 }$ k
   std::vector <Features::Feature *> totalFeature;' X" h2 N, T6 c- d! m) N
   Point3d vertex1,vertex2;1 ?# y4 t0 [% `( C4 z$ g
   for (unsigned int i = 0; i< bodies.size();++i)
8 v7 I# v3 I! ^9 B8 q% s6 I   {- _: f9 C5 z; x' R. H7 Q0 l
    edges = bodies->GetEdges();5 x! S0 G3 \+ [& h% V- J
    faces = bodies->GetFaces();! X+ ]" d3 G2 H: |$ X, Q
    Features = bodies->GetFeatures();
6 G% e. K& Y+ h     for(unsigned int j =0;j < edges.size(); j++)
7 ~+ O* s  r. z# t     {! c* q: A) V- [
     totalEdges.push_back(edges[j]);4 ]: N7 F- L1 \9 C! n* G
     }- J  n0 \! B; C& w6 m
     for(unsigned int j =0;j < faces.size(); j++)
6 B" {4 ^) S' _2 D  C     {
) ]4 M. t9 A7 r( V5 Q# g( q+ P     totalfaces.push_back(faces[j]);! g) ?0 F* A6 P; W' e- A5 V0 [7 V
     }
7 A! ]: U9 Z" j      for(unsigned int j =0;j < Features.size(); j++)1 O) }7 Q& i% J; j$ [
     {2 V# W! m; I0 g" b! X0 W4 G4 s
     totalFeature.push_back(Features[j]);
9 M" c2 K/ N# j; D     }
8 r6 t7 v) t! f. S* _+ C8 s      
0 M: X$ m$ d! _0 E2 i   }, L9 C- f( e" q6 u1 Q
    ss <<"edges count = " << totalEdges.size()<< "\n";
! L; o% U. G0 i* T' ]   for(unsigned int j =0;j < totalEdges.size(); j++)# c7 e+ b4 w$ T0 Z
     {   
* ?" A6 w' \  r' N" F8 f      totalEdges[j]->GetVertices(&vertex1,&vertex2);' B5 W. ]5 d! l
       ss <<"edges tag: " <<  totalEdges[j]->GetBody()->GetTag()<<"\t";
+ Y  r5 t7 `& q) W6 H) X, Y; U$ y! c       ss <<"edges vertex 1: "<<"("<<vertex1.X<<","<<vertex1.Y<<","<<vertex1.Z<<")"<<"\t";" {) ?% l- r% G- y& N
       ss <<"edges vertex 2: "<<"("<<vertex2.X<<","<<vertex2.Y<<","<<vertex2.Z<<")"<<"\n";
. |6 L. L2 f4 Q4 c& {     }  t" y& Q. f8 h: v  Z! P; v
   ss <<"faces count = " << totalfaces.size()<< "\n";
9 M2 X6 P5 ?0 M) o. D    for(unsigned int j =0;j < totalfaces.size(); j++)+ }5 n$ Y/ n. E& P
    {  
/ h) {1 Z/ U/ A4 S     ss <<"Face tag: " << totalfaces[j]->Tag()<<"\t";
6 ~4 k$ \) A. b0 ?# M/ `( k     ss <<"Face Type: " << totalfaces[j]->SolidFaceType()<<"\t";
3 M, ]0 p5 R; K% g2 C2 [# b" }     ss <<"Face Name: " <<totalfaces[j]->Name().GetUTF8Text()<<"\n";: L% v- ~- Y9 e
    }
- v/ e" m8 }+ o5 ^9 i" P   ss <<"Features count = " << totalFeature.size()<< "\n";5 j) ^% t. N; q; x9 L% o
     for(unsigned int j =0;j < totalFeature.size(); j++)
4 h6 L. X7 @- k4 n1 B    {  % P  m" I* t7 p+ u' q' p
     ss <<"features tag : " << totalFeature[j]->Tag()<<"\t";
/ N1 Q; U6 D9 h     ss <<"features Type: " << totalFeature[j]->FeatureType().GetUTF8Text()<<"\t";' Y% b. u# N- z; z
     ss <<"features Name: " <<totalFeature[j]->GetFeatureName().GetUTF8Text()<<"\n";
0 i4 W  b$ A7 d2 l8 `: J$ @    }
4 Q0 }6 ^* g1 f' @  theSession->ListingWindow()->WriteLine(ss.str());' J6 _0 {5 _; r" W. \8 I; {
% w3 X9 J4 n! B% K/ s0 e, O' ~
" g7 k1 \. W3 i' c  j* n
查询结果如下:
/ R# o" z9 ?) t0 R9 H$ I. b) ?6 a5 @( g+ r$ F

3 J1 `; C) ?: J' i4 X0 OGet information from all bodies( T+ z+ ~# ]/ ~& w. ]
CYLINDERBodies count = 7
' t! [+ E; G# B9 dedges count = 22
/ x. c( C' W1 Z4 f& q' Xedges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,0,100)
1 m, Z- ~) B( e- L# S" Medges tag: 41404 edges vertex 1: (100,0,0) edges vertex 2: (100,100,0)
6 x! T  u5 X' x' q  T0 ~$ iedges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,100,100)+ F" ]" N9 t; f/ k& Y
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (0,100,0): X) w8 @, R3 D$ a- E7 F
edges tag: 41404 edges vertex 1: (100,0,100) edges vertex 2: (0,0,100)2 @5 d$ G& I8 }2 E& l/ `
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (100,0,0)+ R- X# K1 Z/ V# n$ R- i( j$ ]8 Q
edges tag: 41404 edges vertex 1: (100,100,0) edges vertex 2: (100,100,100)
: Q+ i/ x: p' Q; cedges tag: 41404 edges vertex 1: (0,100,100) edges vertex 2: (100,100,100)% w5 Z- U# H! B# Z  r+ g
edges tag: 41404 edges vertex 1: (0,0,100) edges vertex 2: (0,100,100)
& H  v0 f4 N1 B3 V/ f3 A  iedges tag: 41404 edges vertex 1: (100,100,100) edges vertex 2: (100,0,100), Q! E) R7 J6 s$ S3 z+ {& A
edges tag: 41404 edges vertex 1: (0,0,0) edges vertex 2: (0,0,100)
3 A$ b: f8 O1 }$ d# T+ h1 Bedges tag: 41404 edges vertex 1: (0,100,0) edges vertex 2: (0,0,0)
7 C, p8 c! g: D" |* nedges tag: 40966 edges vertex 1: (50,0,100) edges vertex 2: (50,0,100)
! B( ^; h- \* D+ Tedges tag: 40966 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)% E4 e+ I) i* f) R
edges tag: 40977 edges vertex 1: (50,0,200) edges vertex 2: (50,0,200)& X3 Q; V$ B! t+ R3 N6 p! |6 M
edges tag: 40977 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)8 r+ W9 y3 v5 a1 L9 {& \9 {
edges tag: 37824 edges vertex 1: (50,0,300) edges vertex 2: (50,0,300)
0 _; M" k; {7 g  ^edges tag: 37824 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)
. }3 L7 [* F1 @' r# Y/ Wedges tag: 41200 edges vertex 1: (50,0,400) edges vertex 2: (50,0,400)0 Y* v  u4 e& v' a. e  X( a
edges tag: 41200 edges vertex 1: (50,0,500) edges vertex 2: (50,0,500)0 d( }. K& H( [) N& V5 r
edges tag: 41357 edges vertex 1: (150,100,200) edges vertex 2: (150,100,200)
9 W! M( B& Y* |; Bedges tag: 41357 edges vertex 1: (150,100,100) edges vertex 2: (150,100,100)/ v% p% l2 C* p, p6 g
faces count = 22$ f5 p+ t& O1 Q$ ]4 Q6 k
Face tag: 41407 Face Type: 4 Face Name: 3 G% B8 F0 M. Y9 b
Face tag: 41398 Face Type: 1 Face Name:
/ e" N# F$ Y( p. R, XFace tag: 41376 Face Type: 1 Face Name: / M! h5 }# f3 c+ P  t
Face tag: 41391 Face Type: 1 Face Name:
$ H6 q: q) I" I9 cFace tag: 41380 Face Type: 1 Face Name: 1 b# Z$ p% U! @$ ^$ T) @: F2 X  G
Face tag: 41396 Face Type: 1 Face Name:
8 x+ _) a9 D/ k( OFace tag: 41397 Face Type: 1 Face Name: 3 y1 q& [9 S# w0 h6 U% T
Face tag: 40995 Face Type: 2 Face Name: 9 j6 D" _& o; ?% ~. H. q7 L
Face tag: 40965 Face Type: 1 Face Name: & @* y7 v  t, R5 T; a. y" D% y
Face tag: 40997 Face Type: 1 Face Name: 8 }. X8 @' j0 Z! p; ?5 \1 m3 }; Y
Face tag: 41351 Face Type: 1 Face Name: 5 Q' {; g6 ^7 N
Face tag: 41352 Face Type: 1 Face Name:
6 V0 `  ?. }/ M) h! N. wFace tag: 41353 Face Type: 2 Face Name:
0 J0 H. Z8 z7 }' J! qFace tag: 38479 Face Type: 1 Face Name: * y: ^& o5 l3 M  g4 r: _
Face tag: 38480 Face Type: 1 Face Name: 5 ?+ f. v1 h" v
Face tag: 38481 Face Type: 2 Face Name: " I# K% c' z. h
Face tag: 41207 Face Type: 1 Face Name:
4 t5 F  s/ O1 e8 J! T0 C2 f7 XFace tag: 41203 Face Type: 1 Face Name:
8 j, c! Z/ K/ i( w& f& NFace tag: 41158 Face Type: 2 Face Name: 3 y; n; M5 N( W$ Q4 K$ ]' c; p9 m
Face tag: 40987 Face Type: 2 Face Name: 1 H; o4 ]/ w. l$ e# ]7 g$ K. T2 s
Face tag: 41010 Face Type: 1 Face Name: ! f) Q% |  _* u4 `- B/ ?
Face tag: 41001 Face Type: 1 Face Name:   O# `3 I+ Y& _( j9 Q
Features count = 7
( b7 C! g, j$ \) k3 F5 hfeatures tag : 41280 features Type: SPHERE features Name: Sphere(17)
- c: I4 C9 U( C* w- Ffeatures tag : 41281 features Type: BLOCK features Name: Block(18)2 j+ u8 ]5 S, w/ T3 W4 Z3 o; ^) ?
features tag : 41307 features Type: CYLINDER features Name: Cylinder(19)8 ?) q; S: A5 r3 }5 Z/ p
features tag : 41314 features Type: CYLINDER features Name: Cylinder(20)
9 V$ m" I2 y( hfeatures tag : 41322 features Type: CYLINDER features Name: Cylinder(21)5 {& ?  l" U2 P0 h. Q9 Z
features tag : 41330 features Type: CYLINDER features Name: Cylinder(22)4 s0 z! Y4 e8 H( G# t
features tag : 41338 features Type: CYLINDER features Name: Cylinder(23)
3 I- O+ `4 h/ [- J
: \8 [4 r/ ?5 W; Y+ ~, X
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了