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

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

[复制链接]

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

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

admin 楼主

2014-11-4 20:48:40

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

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

x

. ]2 T$ K" Z9 W' g4 ^NX二次开发源码分享:报告当前工作部件的所有属性7 G* i5 H  r% A1 a7 ?, m
主要是用过workPart->GetUserAttributes()获取属性信息;
% {9 c! a0 L5 s
  1. void MyClass::do_it()
    3 F" |0 F7 d: v: X3 c% y
  2. {8 }% s. t5 ^( m, F3 R
  3.     stringstream out;. Z% y! z( @) v3 m' Z2 X
  4.     std::vector<NXOpen::NXObject::AttributeInformation> infos = workPart->GetUserAttributes();
    : Z# ~- O6 t+ j6 J+ d
  5.     out.str(""); out.clear();
    " k7 v9 M( p. _
  6.     out << "\nAttributes found: " << infos.size() << endl;( X5 ^5 h4 w" I  u# K* m. y, {! z
  7.     print(out.str().c_str());
    ) n3 V/ F' R6 [0 ?

  8. ' F; D3 x& W* {2 t! _+ O
  9.     for (unsigned int ii=0; ii<infos.size(); ii++)
      Q4 {+ [& o7 _$ ^8 k7 `
  10.     {
    7 z6 o9 ^, M# q9 Y, \0 Z
  11.         out.str(""); out.clear();8 i/ v: s; |( K5 ~1 \" F+ Q5 v: ~6 I
  12.         out << "\nAttribute: " << infos[ii].Title.GetText() << endl;
    7 R" F, X3 O! O: l7 o  C. t

  13. ( r$ m; T/ ^2 c
  14.         out << " Array: " << infos[ii].Array << endl;5 O2 P# n% p7 g8 ^2 E$ O7 g) r
  15.         if( infos[ii].Category.GetText() )
    6 j) Q; m/ a# K+ p" ]2 [
  16.             out << " Category: " << infos[ii].Category.GetText() << endl;
    & Y. G* U( X$ P7 a
  17.         else
    ' Z' K% I4 ^8 Y$ A! H7 ]) j5 R
  18.             out << " Category: NULL"  << endl;
    & k3 ~2 p( e& A
  19.         out << " Inherited: " << infos[ii].Inherited << endl;4 f  i3 B& U7 E+ ?6 ?0 z
  20.         out << " Locked: " << infos[ii].Locked << endl;
    : i% P$ Z$ W6 F) ^. H! N
  21.         out << " OwnedBySystem: " << infos[ii].OwnedBySystem << endl;8 c! ?  S1 S9 ]" g! \
  22.         out << " PdmBased: " << infos[ii].PdmBased << endl;! w7 T- C0 v5 u+ [1 b6 d( v
  23.         out << " Required: " << infos[ii].Required << endl;
    8 q8 [% P+ p- U, |* G5 _
  24.         out << " Type: " << infos[ii].Type << endl;
    1 s; [' c- G$ ~! i# f
  25.         out << " Unset: " << infos[ii].Unset << endl;
    " x( J9 _  ^- e
  26. " K; U" @7 D2 j2 @- Y4 V
  27.         swiTCh ( infos[ii].Type )
    9 U: l9 t2 E5 d( b/ D# O6 S; F2 ]9 a
  28.         {
    # Z9 h5 u9 M# t
  29.         case NXObject::AttributeTypeInvalid:
    & P! S( F, P/ J' x! I
  30.             out << " Type is invalid." << endl;1 W: n+ V4 c% U- p$ }3 e
  31.             break;8 P8 d0 `) d( _, J; `" B
  32.         case NXObject::AttributeTypeBoolean:
    " |% O, ^' B& r3 U3 {% g; H& \
  33.             out << " BooleanValue: " << infos[ii].BooleanValue << endl;
    5 @; w4 B) p8 F8 A2 d% V0 Y
  34.             break;* f$ c" n0 E' z
  35.         case NXObject::AttributeTypeInteger:
    0 w( W* Q6 s. c" D$ P! p! J
  36.             out << " IntegerValue: " << infos[ii].IntegerValue << endl;1 I! e) V/ w8 {4 e. l$ g" f
  37.             break;
    # }& {( @2 n6 D$ w* Y% h: j( J7 h
  38.         case NXObject::AttributeTypeReal:( M8 |! X  f! K0 a% C
  39.             out << "RealValue: " << infos[ii].RealValue << endl;
    - w$ v2 m# ]; R
  40.             break;
    9 q9 a4 A. Y8 O+ S9 b$ k7 m3 b, Q  e
  41.         case NXObject::AttributeTypeString:
    ( b7 O% ]6 m4 I/ Q) w  F+ a: h8 g
  42.             out << " StringValue: " << infos[ii].StringValue.GetText() << endl;! B3 h. L5 \$ _' K
  43.             break;
    ' h+ t+ P) d9 U' H& [" M
  44.         case NXObject::AttributeTypeTime:3 F/ q) k$ u& i, c
  45.             out << " TimeValue: " << infos[ii].TimeValue.GetText() << endl;
    2 |& {2 A' B* S$ |  a  m& s$ P
  46.             break;
    0 I$ W# q8 Q4 D
  47.         }
    / t! o3 |& V0 L9 @: T

  48. ; Y3 \0 m! S9 K& x% F4 J7 f2 }3 H5 M
  49.         print(out.str().c_str());
    , r$ E8 g/ }+ x4 J; o; _: i% i. _
  50.     }9 J0 ]+ o4 R% A6 T6 j9 X

  51. 0 |. `- N4 P( @0 j. p7 y
  52. }
    0 w. a) n' u' B2 u
复制代码
) r6 o, _, O5 A3 F8 O

* k* w% M+ }) ?3 v* I8 j: C
; h2 _6 k# M9 [& w
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了