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

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

[复制链接]

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

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

admin 楼主

2014-11-4 20:48:40

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

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

x

( q" _! k2 d) r0 M$ c$ ZNX二次开发源码分享:报告当前工作部件的所有属性
# Q5 x& F7 ]1 f7 s, `9 Q) ^) u主要是用过workPart->GetUserAttributes()获取属性信息;
+ O, P; j1 e8 ^, G* O! X# I
  1. void MyClass::do_it(), q* a( u0 m2 E+ [6 E4 j- y
  2. {$ E! M8 C" a! O) n+ [
  3.     stringstream out;9 l& [( K- {0 n( A
  4.     std::vector<NXOpen::NXObject::AttributeInformation> infos = workPart->GetUserAttributes();2 k( o, A+ I5 j# ]9 ~. x, J
  5.     out.str(""); out.clear();: J& m& y" R3 x, i+ }
  6.     out << "\nAttributes found: " << infos.size() << endl;4 @/ L* l" F: Z: y1 E! c
  7.     print(out.str().c_str());
    " q: F' O# I( J9 [) i& V2 [
  8. 4 i& {0 L  q' p8 V1 g# `0 Z6 I7 U
  9.     for (unsigned int ii=0; ii<infos.size(); ii++)
    7 p: u" P! `1 e, _- P
  10.     {. r# L* U( @  F. A: Q2 e' u
  11.         out.str(""); out.clear();
    . n- |, ?; T& L6 T) Q3 r
  12.         out << "\nAttribute: " << infos[ii].Title.GetText() << endl;- u  k9 ?; i- w: W- M: y

  13. " }9 H9 {' B4 q, o4 N; {
  14.         out << " Array: " << infos[ii].Array << endl;# Z1 D% a& q) ]9 W- r0 ], X
  15.         if( infos[ii].Category.GetText() )+ f: e0 E' R' Y) c6 ~1 [
  16.             out << " Category: " << infos[ii].Category.GetText() << endl;" k& f  R7 _  T6 |, q2 K. ]
  17.         else
    & t' e! O4 x& V9 M8 x, g
  18.             out << " Category: NULL"  << endl;- k& _+ ^/ J4 l5 T' a$ O
  19.         out << " Inherited: " << infos[ii].Inherited << endl;( m$ v) M0 g  `8 y' W* J0 }
  20.         out << " Locked: " << infos[ii].Locked << endl;0 G9 {0 ]# z+ J( S2 N( u3 w- [( o
  21.         out << " OwnedBySystem: " << infos[ii].OwnedBySystem << endl;
    # m, g) f2 x& c  B) A
  22.         out << " PdmBased: " << infos[ii].PdmBased << endl;
    4 i' Y7 f2 Y6 j/ y3 F1 p
  23.         out << " Required: " << infos[ii].Required << endl;# q+ v; N- }2 |
  24.         out << " Type: " << infos[ii].Type << endl;: f9 K3 Z) n/ [
  25.         out << " Unset: " << infos[ii].Unset << endl;
    6 C" s6 p5 F0 X  V

  26. : Y) K: M. p  p% K0 h
  27.         swiTCh ( infos[ii].Type )
    & {! Q) m9 g1 U+ w# q/ k% z
  28.         {: C' m8 U6 \) p0 P2 ]% _
  29.         case NXObject::AttributeTypeInvalid:
    - s+ m, j: r; z: m3 K) ?3 k
  30.             out << " Type is invalid." << endl;7 H9 J2 S/ @$ E- m  \$ a
  31.             break;" H: A/ j) W% n0 P2 H( W' j
  32.         case NXObject::AttributeTypeBoolean:
    ' @# q4 m; ?" ~7 N: Z* d1 s6 W
  33.             out << " BooleanValue: " << infos[ii].BooleanValue << endl;
    . ~2 U6 G, P+ e: _
  34.             break;
    0 D) D5 t- R9 }
  35.         case NXObject::AttributeTypeInteger:
    5 G9 [" e# H/ a# f
  36.             out << " IntegerValue: " << infos[ii].IntegerValue << endl;8 N+ W  ?. I+ c4 P% K- ?4 n
  37.             break;/ s3 E" h& x$ H' d  A; o
  38.         case NXObject::AttributeTypeReal:5 i% q3 j9 Z. i" o9 o% d
  39.             out << "RealValue: " << infos[ii].RealValue << endl;
    " ]4 a, W' f6 f$ Y2 c- v* c* x
  40.             break;
    9 l$ Z- S% m! g$ Z3 x. y
  41.         case NXObject::AttributeTypeString:9 Q$ m0 o4 C$ d1 f
  42.             out << " StringValue: " << infos[ii].StringValue.GetText() << endl;- n, a' V( q5 n( w6 U; O$ F
  43.             break;  o  k( ^) ^! P- s- K7 h2 G& _
  44.         case NXObject::AttributeTypeTime:( C0 c5 X! D" D
  45.             out << " TimeValue: " << infos[ii].TimeValue.GetText() << endl;1 ~7 T7 ?) Y* n8 u, P$ g
  46.             break;5 `4 l8 }) C! w% i+ y
  47.         }
    7 w7 y% Z# l$ {% Z
  48. # G; c* }5 P7 @  N5 x/ L
  49.         print(out.str().c_str());: l6 U- S" l+ l5 ]
  50.     }
    ( T0 R. o% K; r3 a2 \' \1 G

  51. . ~9 G  ]1 M+ Z; P' x
  52. }
    6 H/ O$ w! t! I* l
复制代码

! G" ~7 Q! g. I, B" x/ `) T2 ?  V6 K& Y
$ n+ E' @8 Z, b' g* N, e& H# D& V
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了