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

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

[复制链接]

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

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

admin 楼主

2014-11-4 20:48:40

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

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

x
1 w/ c4 A6 ~$ [
NX二次开发源码分享:报告当前工作部件的所有属性; k7 x. m4 {+ M! k0 i9 Q
主要是用过workPart->GetUserAttributes()获取属性信息;
8 B- }% J4 v+ E, s) |9 y
  1. void MyClass::do_it()0 L! {2 O" U& e% a1 X6 e
  2. {
    ) @5 N- R4 E/ d( L2 {% s( ]/ g
  3.     stringstream out;
    ( _9 f3 s- G$ D, X7 Y: A  N" g
  4.     std::vector<NXOpen::NXObject::AttributeInformation> infos = workPart->GetUserAttributes();
    & a; z* P" T: F* M
  5.     out.str(""); out.clear();
    ) i' I1 d6 O1 k
  6.     out << "\nAttributes found: " << infos.size() << endl;* @: ^' e. W4 A4 @! W
  7.     print(out.str().c_str());/ P1 ]* ]2 T. Z: w) P- a8 Q
  8. ( T" W6 ~. m* F) p, }( c3 j
  9.     for (unsigned int ii=0; ii<infos.size(); ii++)9 H' y# A" X# g. M; }) E, ~, i
  10.     {
    ) r9 V0 {& a" O5 M7 w6 A
  11.         out.str(""); out.clear();, B: J7 i. i0 F) ~  g1 F
  12.         out << "\nAttribute: " << infos[ii].Title.GetText() << endl;
    7 a2 D# A6 J8 U1 R4 G
  13. ( f, l, ]  i# b7 e6 ~% Z, r( |
  14.         out << " Array: " << infos[ii].Array << endl;
    * p& t9 l/ a. {, z" ]' e
  15.         if( infos[ii].Category.GetText() )
    6 A$ M% ?  r- F, }/ h) E$ h; ^
  16.             out << " Category: " << infos[ii].Category.GetText() << endl;; o4 S! e% ~1 K% \6 @
  17.         else2 H- n$ B$ ?% N2 k7 r8 k# W
  18.             out << " Category: NULL"  << endl;
    3 n5 D- h8 ?4 K% Y$ F& H
  19.         out << " Inherited: " << infos[ii].Inherited << endl;
    0 \- K/ j% f7 h, D
  20.         out << " Locked: " << infos[ii].Locked << endl;
    2 j( k& a2 x. @- p) o$ N, a) g
  21.         out << " OwnedBySystem: " << infos[ii].OwnedBySystem << endl;4 z: q0 |0 \  h+ s
  22.         out << " PdmBased: " << infos[ii].PdmBased << endl;8 L0 G6 b/ r0 A: }; H
  23.         out << " Required: " << infos[ii].Required << endl;% S8 u5 y5 T( f  \$ q/ g! }3 f
  24.         out << " Type: " << infos[ii].Type << endl;
    # j, \0 X+ j/ g
  25.         out << " Unset: " << infos[ii].Unset << endl;# h, F. |2 q3 L9 E$ j/ g

  26. " C) k7 u; N: G: R
  27.         swiTCh ( infos[ii].Type )
    2 l9 X6 M' G3 w: n# O: W
  28.         {
    1 W0 D& {. `4 H+ Z. ]' n
  29.         case NXObject::AttributeTypeInvalid:: @( ^7 _7 L; t; A
  30.             out << " Type is invalid." << endl;3 i& M# ?1 t; z) F
  31.             break;' [4 e% C( A) v& P) @% d
  32.         case NXObject::AttributeTypeBoolean:8 V5 H# d  `9 @6 \1 G$ l- h
  33.             out << " BooleanValue: " << infos[ii].BooleanValue << endl;
    + ^: f: T9 d* q
  34.             break;
    4 s$ ?* k# l- e. J' ~
  35.         case NXObject::AttributeTypeInteger:
    . t: j+ r' v4 f4 n( ~$ G
  36.             out << " IntegerValue: " << infos[ii].IntegerValue << endl;, t7 G. |0 L+ j8 k
  37.             break;7 @6 C' q# _9 E
  38.         case NXObject::AttributeTypeReal:
    ) e: F" J8 U8 ^: p. G8 Z
  39.             out << "RealValue: " << infos[ii].RealValue << endl;
    % }# x* z, h! m  v
  40.             break;
    ! P( T# s( ?- A# v: s
  41.         case NXObject::AttributeTypeString:
    $ a8 |; D- Y5 [) t5 |. _
  42.             out << " StringValue: " << infos[ii].StringValue.GetText() << endl;( {' I) I+ Y% c' l4 g- j
  43.             break;  j0 I+ }$ W$ g
  44.         case NXObject::AttributeTypeTime:
    / w' a& |/ j+ j: G: X
  45.             out << " TimeValue: " << infos[ii].TimeValue.GetText() << endl;
    + a# T: ~0 H! \/ m
  46.             break;. ]* n: f* V# P4 q; Z
  47.         }
    6 a4 H' y1 }7 O( M( a& m' C
  48. 5 X4 |$ A1 t: k2 H
  49.         print(out.str().c_str());; L$ Q( h1 e. f% E3 \3 P( ]
  50.     }
    7 N5 i9 j+ F* ?3 {2 C# t

  51. . o7 d- A2 _' y  y
  52. }7 V/ E: f" C9 F* o6 j2 c
复制代码

- ^2 q* u( C1 ?" G, A2 s; s+ ]/ r6 j, _7 ]3 f
& W4 H8 s  }- L. \
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ 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二次开发专题模块培训报名开始啦

    我知道了