PLM之家PLMHome-工业软件践行者

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

[复制链接]

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

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

admin 楼主

2014-11-4 20:48:40

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

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

x
0 i2 F: H. }5 O9 H
NX二次开发源码分享:报告当前工作部件的所有属性4 |: i5 T0 u5 S) q! Q
主要是用过workPart->GetUserAttributes()获取属性信息;
* c' q) U' y3 u) \/ h0 g6 Q  m
  1. void MyClass::do_it(). L1 {1 s& }6 O. U3 M
  2. {
    + W% {) q7 c( ~8 i# A7 k
  3.     stringstream out;4 {+ A9 D2 }; Z1 @
  4.     std::vector<NXOpen::NXObject::AttributeInformation> infos = workPart->GetUserAttributes();
    ( K( ^- g$ S7 K+ d& N
  5.     out.str(""); out.clear();
    ( ]1 j! {6 w; z4 E* Z
  6.     out << "\nAttributes found: " << infos.size() << endl;
    9 q4 s# ?5 e5 }, Y$ T% F# m
  7.     print(out.str().c_str());( k$ A4 V4 u3 }4 e. A
  8. 2 u8 a: _2 V! I+ w( C% N
  9.     for (unsigned int ii=0; ii<infos.size(); ii++)
    ; @" J2 t' W. \, D5 J# F
  10.     {
    " s8 x. Z& l$ R7 \
  11.         out.str(""); out.clear();2 R* v% i; a) B8 I/ f7 y) U, i
  12.         out << "\nAttribute: " << infos[ii].Title.GetText() << endl;
    9 z' {% P7 I  v0 d8 i

  13. 1 P$ Y/ M) r0 \8 v
  14.         out << " Array: " << infos[ii].Array << endl;% x$ G7 y, U7 n3 n, n& n
  15.         if( infos[ii].Category.GetText() )
    . \0 r# y3 \$ t3 c. L/ x
  16.             out << " Category: " << infos[ii].Category.GetText() << endl;; a) F& ~5 K$ G2 q7 a
  17.         else
    5 [2 p' ^" E& l$ N! k! V, s
  18.             out << " Category: NULL"  << endl;
    6 z! a3 }: j6 r
  19.         out << " Inherited: " << infos[ii].Inherited << endl;
    ) U$ T5 Q2 Z. D) t+ F3 d
  20.         out << " Locked: " << infos[ii].Locked << endl;
    5 T) h2 v7 h; V, u% O& z
  21.         out << " OwnedBySystem: " << infos[ii].OwnedBySystem << endl;
    / e8 v6 s, s7 h/ a
  22.         out << " PdmBased: " << infos[ii].PdmBased << endl;
    ( j( L$ K( q# V
  23.         out << " Required: " << infos[ii].Required << endl;
    , R" n4 V: p# t
  24.         out << " Type: " << infos[ii].Type << endl;
    0 Z+ t$ p. s% N+ ^5 J: P$ u% e
  25.         out << " Unset: " << infos[ii].Unset << endl;6 p" h0 \, w+ R' [2 b* e0 z
  26. ; s4 b" [& b3 e1 W' U+ D5 m1 A! w
  27.         swiTCh ( infos[ii].Type )
    * l* Z- g; v. _6 x/ F  v
  28.         {
    * H0 f. O" `, E
  29.         case NXObject::AttributeTypeInvalid:; C( K- w' B, R0 q/ o+ F/ o
  30.             out << " Type is invalid." << endl;
    . t  x, D: \) U' z, L9 n- I& I
  31.             break;
    8 b+ A3 ?# E! I4 p* J3 s: I
  32.         case NXObject::AttributeTypeBoolean:6 i. X. \! d" y& I; ~- X( G
  33.             out << " BooleanValue: " << infos[ii].BooleanValue << endl;
    ' _  p( z8 v+ T2 T3 f
  34.             break;
    5 l. F  d2 N% f
  35.         case NXObject::AttributeTypeInteger:  ?1 K: \! ?9 v; p! @; C4 C* I, E
  36.             out << " IntegerValue: " << infos[ii].IntegerValue << endl;
    ( Y9 k* Q7 D* H% x+ D  N) S
  37.             break;# k  u, L* M: F% Z; l; i/ ^
  38.         case NXObject::AttributeTypeReal:
    / _2 E: H- h# Y0 H/ T; ]0 h" S
  39.             out << "RealValue: " << infos[ii].RealValue << endl;! i. R0 f5 |6 @# O' d8 b) q
  40.             break;6 _6 G6 J* \# ~+ t
  41.         case NXObject::AttributeTypeString:' A& @4 a4 ?; H& S/ ]" V8 F& s$ O
  42.             out << " StringValue: " << infos[ii].StringValue.GetText() << endl;
    & y& c+ N/ d, B. D6 n1 _
  43.             break;
    2 m+ L+ S2 ~3 \: @* U
  44.         case NXObject::AttributeTypeTime:
    . r/ k/ R; ]" ?
  45.             out << " TimeValue: " << infos[ii].TimeValue.GetText() << endl;
    * [& A% Z7 \$ t6 @/ Z5 h2 ]
  46.             break;: f/ A: u# k0 \" R8 \- C+ W
  47.         }
    - Z3 A' F/ T2 \0 `

  48. ; T1 S1 u1 z- Z3 P7 |
  49.         print(out.str().c_str());
    - P& i$ c+ X+ ~9 v1 S" R
  50.     }
    8 k0 t# \! D- g& m( G$ Z

  51. # q" Q0 E# Y3 y0 s: J& B1 j# x
  52. }
    ' o7 ?: H5 Q) K& h+ K
复制代码
+ d) b0 r* L- U! s0 t: v2 s* Y

! K, z- N9 }8 {$ S6 D+ J; M9 f/ ~1 f. D& O2 K/ h
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了