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

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

[复制链接]

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

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

admin 楼主

2014-11-4 20:48:40

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

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

x
$ P* n1 O9 B5 T0 S+ w- i
NX二次开发源码分享:报告当前工作部件的所有属性# i& T1 _( F( R
主要是用过workPart->GetUserAttributes()获取属性信息;5 {' S4 ~9 c  j7 q6 o2 C, x
  1. void MyClass::do_it()
    / ^+ }7 N' W& {+ y- S$ h
  2. {0 K- b7 @! S0 i7 }
  3.     stringstream out;, N5 D# W* w( H) N; Z3 ]4 g
  4.     std::vector<NXOpen::NXObject::AttributeInformation> infos = workPart->GetUserAttributes();
    7 Q: V8 {0 v3 H- h
  5.     out.str(""); out.clear();
    # {% t- b7 Q! i
  6.     out << "\nAttributes found: " << infos.size() << endl;  K$ H( t* ?. Z" }4 O* t
  7.     print(out.str().c_str());
    ! S3 r  C7 ^, H, Y# e! c/ V- a

  8. 3 M  H4 o! x, q8 S+ @% j5 l; V+ h
  9.     for (unsigned int ii=0; ii<infos.size(); ii++)
    1 n+ x- m# N' Y# b" `9 ?) h
  10.     {- K! ]( M3 E8 m6 V; y
  11.         out.str(""); out.clear();
    9 \0 [. X5 `* ~' e( }
  12.         out << "\nAttribute: " << infos[ii].Title.GetText() << endl;8 v+ W( e8 e9 x( `  N+ ?
  13. 6 |8 y: A' [0 c5 F- N
  14.         out << " Array: " << infos[ii].Array << endl;9 h3 z7 D  l: f+ C7 {7 A
  15.         if( infos[ii].Category.GetText() ). M2 r. m4 t0 T8 d( _
  16.             out << " Category: " << infos[ii].Category.GetText() << endl;" Q9 b# \$ z9 `
  17.         else
    : o8 ]' `& P" Z* P, v2 d
  18.             out << " Category: NULL"  << endl;" a" @( ]  J3 i& n' ~, A
  19.         out << " Inherited: " << infos[ii].Inherited << endl;
    & X% M/ |: F: |  B) a
  20.         out << " Locked: " << infos[ii].Locked << endl;
    1 {/ f( y7 Y# i  c" K. z, Q
  21.         out << " OwnedBySystem: " << infos[ii].OwnedBySystem << endl;8 w: E- d0 o+ a% Y3 W+ Q  \
  22.         out << " PdmBased: " << infos[ii].PdmBased << endl;8 d% O+ H; m2 r4 E4 c/ Y. p# H8 T, r
  23.         out << " Required: " << infos[ii].Required << endl;" S* z2 [0 u! y
  24.         out << " Type: " << infos[ii].Type << endl;
    ( }& r5 B0 v" P7 l) B* @
  25.         out << " Unset: " << infos[ii].Unset << endl;2 v( `. g2 T0 i8 \6 q' ~+ j
  26. $ |6 L; w- j, E- I* ~) P
  27.         swiTCh ( infos[ii].Type )
    ; z9 }2 D- \5 _! g7 i
  28.         {4 E2 z$ m# S( }+ i- G) }
  29.         case NXObject::AttributeTypeInvalid:& x2 Z) X5 p& p4 `( s! w0 D6 S
  30.             out << " Type is invalid." << endl;
    2 D3 t! F8 l- z6 r5 A8 B
  31.             break;+ s) o! [7 Q6 d* d. Q0 L0 ?
  32.         case NXObject::AttributeTypeBoolean:, u/ T4 j+ g, {$ \2 P# s6 h+ S
  33.             out << " BooleanValue: " << infos[ii].BooleanValue << endl;) ?5 v8 _( v. |2 z* ]' v
  34.             break;2 p0 f( ~+ \: @$ A9 \2 h6 G6 `9 S
  35.         case NXObject::AttributeTypeInteger:
    " g+ L% G" l+ n2 @5 {  V
  36.             out << " IntegerValue: " << infos[ii].IntegerValue << endl;& d7 j  |% M. E6 w
  37.             break;
    5 z2 \" z/ g/ J- [3 t
  38.         case NXObject::AttributeTypeReal:
    " r1 j. s5 G- y$ F
  39.             out << "RealValue: " << infos[ii].RealValue << endl;
    9 d  ]4 b- L+ V" k& ^3 g0 k
  40.             break;& [; W& ]/ Y. o2 ~: t
  41.         case NXObject::AttributeTypeString:* G+ s8 k; e, n* b
  42.             out << " StringValue: " << infos[ii].StringValue.GetText() << endl;* R; d5 x+ P1 h0 l1 b
  43.             break;
    5 N  v* X' S( Q2 H
  44.         case NXObject::AttributeTypeTime:
    & `9 u' C* F3 U4 ~4 S
  45.             out << " TimeValue: " << infos[ii].TimeValue.GetText() << endl;! c% @$ ^+ Z9 T3 o- F2 q
  46.             break;' f7 T1 `, }; N2 j5 p. _* V' S
  47.         }
    4 A! b) G7 ?, {

  48. / n# w+ ~; R0 G4 _) u
  49.         print(out.str().c_str());, P1 x3 T* J1 Y3 u" l' D5 _
  50.     }& ], F( g5 |: r8 `  _+ R( |: k; V

  51. 3 C) p9 Q$ C( k: i* e# X
  52. }" g; g) I  G3 i5 ], ?
复制代码
# @; l: F2 T4 P

! a) A% N) I5 G/ f) {/ t
, P9 a! u7 j. M  B
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了