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

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

[复制链接]

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

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

admin 楼主

2014-11-4 20:48:40

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

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

x
" M5 W6 E" ^0 s0 h9 \
NX二次开发源码分享:报告当前工作部件的所有属性3 b5 l* {2 y' f# }, ]/ m$ B% ]
主要是用过workPart->GetUserAttributes()获取属性信息;
- ?& }* |1 y8 i
  1. void MyClass::do_it()
    & p; I# r# F8 U; A0 T# w, u
  2. {
    ) w, @' C& r2 s% i
  3.     stringstream out;: m; ?9 @+ ]7 Y7 v& Q
  4.     std::vector<NXOpen::NXObject::AttributeInformation> infos = workPart->GetUserAttributes();
    * |5 \. G' v2 S, }1 h& G7 r* n
  5.     out.str(""); out.clear();
    ! T% t2 h' W  a7 C* L
  6.     out << "\nAttributes found: " << infos.size() << endl;6 S3 B* J/ o) F3 {- m" |
  7.     print(out.str().c_str());
    4 M& E8 p& t- H4 i% O5 D

  8. & i1 _; N' v7 ]4 M8 D
  9.     for (unsigned int ii=0; ii<infos.size(); ii++)4 m8 q3 g1 j: ~# K( k
  10.     {; f: B! c+ y$ @5 h0 M, i
  11.         out.str(""); out.clear();
    3 K6 c9 x1 j# e) k6 x; |" i2 E
  12.         out << "\nAttribute: " << infos[ii].Title.GetText() << endl;
    ! a  K3 @: ?8 m  D. y

  13. 7 g  @2 \$ @8 E" o" o6 e% i1 W
  14.         out << " Array: " << infos[ii].Array << endl;0 N5 M& n% `1 B. Z( U: w
  15.         if( infos[ii].Category.GetText() )# G0 {4 ^# P8 Y; F& f2 ]1 t1 M
  16.             out << " Category: " << infos[ii].Category.GetText() << endl;* d& Q& i- R) @1 h1 \  Z
  17.         else4 a* n/ y. t: ^5 L+ Q3 E
  18.             out << " Category: NULL"  << endl;
    5 l1 o9 J( g$ d) D2 c" ^9 s
  19.         out << " Inherited: " << infos[ii].Inherited << endl;
    $ b" p4 B. T0 O4 g; b1 y4 {
  20.         out << " Locked: " << infos[ii].Locked << endl;
    . `- K9 U" @. f- p
  21.         out << " OwnedBySystem: " << infos[ii].OwnedBySystem << endl;3 u# _. V/ K4 y0 h: e8 [
  22.         out << " PdmBased: " << infos[ii].PdmBased << endl;( i2 P7 f1 u8 P) m3 T
  23.         out << " Required: " << infos[ii].Required << endl;$ w, s8 C4 t* O5 N
  24.         out << " Type: " << infos[ii].Type << endl;6 p$ }. @6 |" u* U0 u* j6 P
  25.         out << " Unset: " << infos[ii].Unset << endl;
    5 N! W6 c0 Q8 \

  26. , o' T7 o2 ^# Q/ f% N9 Q
  27.         swiTCh ( infos[ii].Type )
    : R+ ?' d7 i3 n' e" I; n9 s0 L
  28.         {
    ) }( f) H1 v1 T! K1 ^
  29.         case NXObject::AttributeTypeInvalid:4 ~" U+ p3 R0 m5 W$ ]
  30.             out << " Type is invalid." << endl;8 A5 H% g) l+ h2 a1 l
  31.             break;2 Q' U+ G( m4 F2 c. C
  32.         case NXObject::AttributeTypeBoolean:  Q3 f/ p0 O# Y1 X2 O; ~& O4 G' V4 f
  33.             out << " BooleanValue: " << infos[ii].BooleanValue << endl;  `' @' i  F1 l& |6 `6 l% F7 @
  34.             break;
    1 ^# C8 ~- G/ Y0 A9 t/ l1 G% v) ^
  35.         case NXObject::AttributeTypeInteger:
    # h! X- h6 k! g" |$ C7 P
  36.             out << " IntegerValue: " << infos[ii].IntegerValue << endl;# R# Z5 [3 }' C. a& R
  37.             break;
    1 N2 H  _  |3 Q9 A
  38.         case NXObject::AttributeTypeReal:" H! [# o) s% t6 [: F. h
  39.             out << "RealValue: " << infos[ii].RealValue << endl;5 b% `( c' ?5 v1 m6 H
  40.             break;
    7 Z7 I0 g* \2 [) E0 h; m
  41.         case NXObject::AttributeTypeString:
    , L2 c6 u% l( n, l$ B# t( k
  42.             out << " StringValue: " << infos[ii].StringValue.GetText() << endl;
    2 Q5 E% F! L+ f" i& G9 O
  43.             break;
    ( g, g7 a4 P! {5 M2 x9 }. n9 U! R
  44.         case NXObject::AttributeTypeTime:
    6 O) T2 ^" J& ?
  45.             out << " TimeValue: " << infos[ii].TimeValue.GetText() << endl;2 D' Y4 Z  T( H- j" j7 i3 ]8 a, p, I
  46.             break;, L+ i4 _; y/ u! K2 M
  47.         }
    - S( b# }6 F+ r5 Y# q5 n
  48. 5 M6 e0 r- T6 V1 S
  49.         print(out.str().c_str());9 F& V. e7 }+ X+ K
  50.     }$ r! C7 Q3 Q2 H  p
  51. / k& ]+ ^/ `& {
  52. }% V; p  n4 B0 w0 }( u/ t% U
复制代码
. G: o! D8 f- x3 f+ i! k

8 {' N3 R! ~: W: k/ ?5 e* b7 h
  f* o$ m! L% I, k: F6 M
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了