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

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

[复制链接]

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

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

admin 楼主

2014-11-4 20:48:40

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

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

x

* I8 ~& ~$ Q  |7 d- DNX二次开发源码分享:报告当前工作部件的所有属性
& i# N( F  A& j# n主要是用过workPart->GetUserAttributes()获取属性信息;
4 O! W5 ^/ Y) c! E2 i
  1. void MyClass::do_it()- W, B1 A' d& f+ Q) i
  2. {5 _$ x- M6 h- @' c' A
  3.     stringstream out;6 M% p: f3 H( r3 ]) t8 a, I6 E
  4.     std::vector<NXOpen::NXObject::AttributeInformation> infos = workPart->GetUserAttributes();
    1 p% J& V  C+ u. V
  5.     out.str(""); out.clear();  t% u: u8 ~! `' M  J
  6.     out << "\nAttributes found: " << infos.size() << endl;3 {; k3 W# c, o. a
  7.     print(out.str().c_str());3 V$ k2 P( \/ U
  8. ( t8 t, g2 ]7 u/ ^; i% m9 H
  9.     for (unsigned int ii=0; ii<infos.size(); ii++)7 x7 @1 \) D" Y: j. |! U
  10.     {
    " r. W! S& ^4 N+ z, R( |+ u
  11.         out.str(""); out.clear();5 Y+ ?% f1 M# b/ M, |
  12.         out << "\nAttribute: " << infos[ii].Title.GetText() << endl;  i, L! A1 {8 c3 u+ S

  13. & ^- H) o, s; i
  14.         out << " Array: " << infos[ii].Array << endl;
    ; t7 O# l8 Y2 X
  15.         if( infos[ii].Category.GetText() )
    $ t5 k% N8 W: i3 D* q- T' x
  16.             out << " Category: " << infos[ii].Category.GetText() << endl;
    0 T2 @! \1 ~3 @0 ^% P
  17.         else
    ( d6 H' Z3 i! H  ?
  18.             out << " Category: NULL"  << endl;
      {  O) q2 e* ^9 W/ e4 r
  19.         out << " Inherited: " << infos[ii].Inherited << endl;
    ! p+ _6 S9 c9 n9 ~7 ^- x/ r. k
  20.         out << " Locked: " << infos[ii].Locked << endl;- ]# H' ?  {: q& ^
  21.         out << " OwnedBySystem: " << infos[ii].OwnedBySystem << endl;% `/ ]2 B; `+ [4 Q
  22.         out << " PdmBased: " << infos[ii].PdmBased << endl;2 p# u2 d4 a2 y
  23.         out << " Required: " << infos[ii].Required << endl;
    + p& V4 Y& Z" ], V; c( ?
  24.         out << " Type: " << infos[ii].Type << endl;. |3 ]. X$ v9 H) T- y
  25.         out << " Unset: " << infos[ii].Unset << endl;
    ; W, X/ m" c- v" q4 J

  26. & X: U; Z8 |4 o7 [1 G
  27.         swiTCh ( infos[ii].Type ); L7 p- q" k( p( b6 G
  28.         {
    6 ?1 u7 p, R, t- e" j
  29.         case NXObject::AttributeTypeInvalid:+ k  a  j2 Q* h4 W+ M& ~. F, T' F
  30.             out << " Type is invalid." << endl;- d2 _, Y. K6 y& F4 ?% v) L' P/ m4 D
  31.             break;, p8 J& l9 w5 L  Y  n+ ]7 n+ I
  32.         case NXObject::AttributeTypeBoolean:7 ]6 C* q) o+ d" i( u
  33.             out << " BooleanValue: " << infos[ii].BooleanValue << endl;
    8 t& f+ [/ Y0 e- f8 c# P- N
  34.             break;( D# k' P: y* o4 k
  35.         case NXObject::AttributeTypeInteger:, V0 ^0 h8 m5 X$ }) A+ Q
  36.             out << " IntegerValue: " << infos[ii].IntegerValue << endl;
    # f5 n9 p* \8 N1 ]8 `
  37.             break;
    ; e% w# I+ B; `7 r
  38.         case NXObject::AttributeTypeReal:
    ) `; A6 k& z' q. X: l% U; c3 b# I
  39.             out << "RealValue: " << infos[ii].RealValue << endl;
    ( Q8 f3 f. H% |
  40.             break;$ @0 x4 U- l9 ?8 {: n0 |: ~* `
  41.         case NXObject::AttributeTypeString:
    7 _$ h1 ]/ x' Q' E
  42.             out << " StringValue: " << infos[ii].StringValue.GetText() << endl;! `1 X1 T4 `- x9 J) p" ~* h
  43.             break;
    ' z" _9 \3 O# b
  44.         case NXObject::AttributeTypeTime:
      Z: b2 Z6 o, ^3 |6 c+ }; _# k
  45.             out << " TimeValue: " << infos[ii].TimeValue.GetText() << endl;
    5 w. I- D+ L! L& H8 U3 D( r
  46.             break;
    ! h9 o8 R: N3 d" o7 c
  47.         }7 T, k& y* v" q! Q7 m. x# ~

  48. 7 D) D: ]  O$ _  w' I
  49.         print(out.str().c_str());6 w8 X  t* _) k" K4 [
  50.     }
    ) A/ \5 A, ~( P) V8 Z% B7 e5 [: d

  51. ' g9 |# a, i) n# r: f
  52. }
    1 i" w' L) M, w3 _/ ^# u
复制代码
. v9 e! b4 j/ \" D' d! o6 h
/ Z3 g; _4 D6 y7 T
9 g4 b6 l% L4 ^$ o1 k( @
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了