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

[二次开发源码] NX二次开发源码分享:报告当前工作部件的所有属性

[复制链接]

2019-4-25 18:49:57 3848 1

admin 发表于 2014-11-4 20:48:40 |阅读模式

admin 楼主

2014-11-4 20:48:40

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

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

x
8 C4 \! Y- r2 m1 h/ P
NX二次开发源码分享:报告当前工作部件的所有属性
% @" }8 T0 x: D% f( H& @, Z主要是用过workPart->GetUserAttributes()获取属性信息;
4 Y. g6 ]0 \, J* q; x* q( u
  1. void MyClass::do_it()& \; S  @8 c5 o
  2. {
    # l$ |: E3 z$ ]8 x5 O
  3.     stringstream out;( O; D* i- R( m6 e
  4.     std::vector<NXOpen::NXObject::AttributeInformation> infos = workPart->GetUserAttributes();2 u9 e9 R! ]& }# Z. u: I
  5.     out.str(""); out.clear();
    " x" O! [8 T: p" T3 r8 h7 U
  6.     out << "\nAttributes found: " << infos.size() << endl;
    - P3 X4 G% G; H$ e$ q  M
  7.     print(out.str().c_str());% v1 ^1 I9 G2 j! `/ V

  8. ) I$ Z9 G/ s0 C  J  P) H
  9.     for (unsigned int ii=0; ii<infos.size(); ii++)
    " R4 p+ o0 S* _3 I6 M1 z5 ~3 I
  10.     {
    0 z' t2 g6 ~" s) n9 R+ s1 Z
  11.         out.str(""); out.clear();! m1 I+ n0 c8 r: i
  12.         out << "\nAttribute: " << infos[ii].Title.GetText() << endl;
    ' b4 w: p7 ?& b5 v
  13. ; `. I( [$ u" E( ?7 E7 i4 j
  14.         out << " Array: " << infos[ii].Array << endl;( c! T+ E8 E& g6 p4 W
  15.         if( infos[ii].Category.GetText() )8 f* x' u. ]' o% J" ?8 {+ L+ \; h: F* b
  16.             out << " Category: " << infos[ii].Category.GetText() << endl;  f( p! P4 r6 b" n
  17.         else3 d- \2 B/ ?7 L, J* |0 L' f9 m& Z! ~
  18.             out << " Category: NULL"  << endl;
    * I+ z1 K3 Y* T7 Q# J  d3 [
  19.         out << " Inherited: " << infos[ii].Inherited << endl;
    . a4 `9 F( G/ q) ]4 a9 P" Q4 u
  20.         out << " Locked: " << infos[ii].Locked << endl;
    0 I  t: c* X: c' [3 t3 ?& j5 ]
  21.         out << " OwnedBySystem: " << infos[ii].OwnedBySystem << endl;3 l; _* `# A$ R- [
  22.         out << " PdmBased: " << infos[ii].PdmBased << endl;# Y  h/ q6 b6 P" r
  23.         out << " Required: " << infos[ii].Required << endl;
    & k) F& t( G* h7 {$ \2 k4 w0 C9 v
  24.         out << " Type: " << infos[ii].Type << endl;3 S: C8 m. ~6 `5 S% x9 O
  25.         out << " Unset: " << infos[ii].Unset << endl;/ D0 N8 W" j2 Y4 A/ x( p3 k

  26. ! E& a2 `4 D0 l% z' `3 U& R5 G
  27.         swiTCh ( infos[ii].Type )7 r' w! y9 R% _- W* A
  28.         {
    % P. s! I2 N* z! e: t
  29.         case NXObject::AttributeTypeInvalid:2 A- l1 x$ Q( _3 p3 T9 I7 f
  30.             out << " Type is invalid." << endl;
    $ j) l8 O$ B, B7 f' y: m& K! }
  31.             break;! R( f) C8 t9 D& V' z! m
  32.         case NXObject::AttributeTypeBoolean:* S8 u+ }8 r4 }8 t
  33.             out << " BooleanValue: " << infos[ii].BooleanValue << endl;
    2 z/ d4 P# g. C$ S
  34.             break;
    7 _$ M2 v5 s* X" j
  35.         case NXObject::AttributeTypeInteger:( w" C9 M& P; ]2 a8 F" W$ p0 _) |
  36.             out << " IntegerValue: " << infos[ii].IntegerValue << endl;  J2 d% Y1 [9 e+ ~
  37.             break;
    0 I, G6 ^4 W2 ]$ U3 y7 R* a
  38.         case NXObject::AttributeTypeReal:4 ?) ?: A; q8 `2 n
  39.             out << "RealValue: " << infos[ii].RealValue << endl;
    - M8 {- t" z4 W/ i1 `# E
  40.             break;
    - w; M' A/ X4 W3 V, I* v. w
  41.         case NXObject::AttributeTypeString:/ }3 @( D& s; V( j
  42.             out << " StringValue: " << infos[ii].StringValue.GetText() << endl;
    ; `) G, q4 o/ p
  43.             break;9 f( }# j" m, |" S
  44.         case NXObject::AttributeTypeTime:$ h- I" j2 z! b$ \/ u9 A& }3 l
  45.             out << " TimeValue: " << infos[ii].TimeValue.GetText() << endl;
    # {& e+ b& Z/ S% V; k1 M
  46.             break;
    * }* B- n* ]: X- T1 {
  47.         }% q) [9 z2 ~1 b0 C0 }- x' A$ I

  48. ! Z" a) I  u- C! I0 Q+ p
  49.         print(out.str().c_str());* H) o$ H+ }' C/ Z8 J0 {
  50.     }
    / G% \) J, M/ o0 B
  51. 6 `; E, \9 z$ x' D3 @0 L
  52. }
    + j+ b8 @. S( R* N
复制代码
0 e- c( p1 E6 N0 V
( e# m! c; L. h

, b/ n. A. y6 g2 m# B0 T
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

全部回复1

593232280 发表于 2019-4-25 18:49:57

593232280 沙发

2019-4-25 18:49:57

有用的,解决
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了