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

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

[复制链接]

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

2470

主题

1275

回帖

8万

积分

管理员

PLM之家站长

积分
82162
QQ
发表于 2014-11-4 20:48:40 | 显示全部楼层 |阅读模式

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

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

x

% O$ B4 K( T1 L  I0 pNX二次开发源码分享:报告当前工作部件的所有属性/ x2 n7 o6 c( U. ^$ N  ]0 Z
主要是用过workPart->GetUserAttributes()获取属性信息;
& @/ J7 L; j1 `+ o- L( w$ n
  1. void MyClass::do_it()9 z. @; e! Y" E7 L) [/ j3 b
  2. {/ f! Z  w: c0 x  {/ d# ~
  3.     stringstream out;
      K! N' |4 O; r/ {
  4.     std::vector<NXOpen::NXObject::AttributeInformation> infos = workPart->GetUserAttributes();7 o8 s" n( z& S- z  L6 g" C
  5.     out.str(""); out.clear();
    7 w2 h" f4 k0 [8 R
  6.     out << "\nAttributes found: " << infos.size() << endl;' B( {/ a  {( G7 w% [# {0 p
  7.     print(out.str().c_str());. q$ Z' a' G/ k* M6 s
  8. ; b  y1 D8 q3 O) X" A1 w
  9.     for (unsigned int ii=0; ii<infos.size(); ii++)
    ' L2 A0 K. ]: B
  10.     {
    5 _  c- L! Q) Q3 @- _
  11.         out.str(""); out.clear();4 [1 E2 b/ s$ q) y
  12.         out << "\nAttribute: " << infos[ii].Title.GetText() << endl;* R' v  {; }# B: m) c
  13. / m- Z0 V' O) D' V4 K  e% H
  14.         out << " Array: " << infos[ii].Array << endl;
    7 v$ L: Z# [# t7 D
  15.         if( infos[ii].Category.GetText() )
    ; W( t+ G: J% T0 F% E; N8 ]2 y
  16.             out << " Category: " << infos[ii].Category.GetText() << endl;
    ' ?8 b( e3 c' N0 O
  17.         else
      n0 h, Y* j" c: y# H& X" F# `
  18.             out << " Category: NULL"  << endl;2 ~& {. |, P0 o1 |# w
  19.         out << " Inherited: " << infos[ii].Inherited << endl;' d* {7 U; r. i9 w; d
  20.         out << " Locked: " << infos[ii].Locked << endl;
    ! F0 r, B6 w& Y2 S/ I% r0 V
  21.         out << " OwnedBySystem: " << infos[ii].OwnedBySystem << endl;6 L5 P% I* K- ^8 G2 ?% L- e
  22.         out << " PdmBased: " << infos[ii].PdmBased << endl;# H% |( G3 f3 y: r  ]) M9 C" ^. J
  23.         out << " Required: " << infos[ii].Required << endl;7 C6 R+ Q0 W7 \$ H1 o' f
  24.         out << " Type: " << infos[ii].Type << endl;6 T) m! x' K1 u- Z2 s. Y% r: ?
  25.         out << " Unset: " << infos[ii].Unset << endl;9 h0 F$ M! [# v; b5 Q9 k$ I$ m8 }; k
  26. 6 y+ \$ m/ O3 ^1 M2 P
  27.         swiTCh ( infos[ii].Type )9 e0 |! Z! j8 A  P$ G6 W# n7 w. Z
  28.         {- m$ \6 g% O2 ]' t  {
  29.         case NXObject::AttributeTypeInvalid:
    5 i8 A& k3 ?) h" }. y6 W
  30.             out << " Type is invalid." << endl;4 U* N3 X1 N2 O: R
  31.             break;
    $ ~' |) t: ]- X( D2 K2 |9 e" R9 z
  32.         case NXObject::AttributeTypeBoolean:6 U% s3 h6 s' K5 l8 g1 }/ J9 ^8 A; [
  33.             out << " BooleanValue: " << infos[ii].BooleanValue << endl;- U% r) W! w8 @+ {2 t5 k0 X
  34.             break;( m9 U- U/ x% A
  35.         case NXObject::AttributeTypeInteger:
    % H, L# o6 I% X3 L% U
  36.             out << " IntegerValue: " << infos[ii].IntegerValue << endl;8 s% B- o5 ]  F" s- n7 q8 M
  37.             break;
    ; g2 x$ V: k/ B- z4 X
  38.         case NXObject::AttributeTypeReal:
    / Q% ]! r) H  X) k
  39.             out << "RealValue: " << infos[ii].RealValue << endl;. k( Y+ k2 V4 W  ~# U- C
  40.             break;
    3 |4 i$ u% @& D5 H5 E$ k
  41.         case NXObject::AttributeTypeString:
    , X7 n/ U1 G& j$ U6 h6 f
  42.             out << " StringValue: " << infos[ii].StringValue.GetText() << endl;7 L/ C2 |8 [* p/ t* c3 A( |
  43.             break;3 f0 R# a" P; t: e) {& ^6 G+ b5 ]* X
  44.         case NXObject::AttributeTypeTime:
    7 ~$ W6 c4 |' F" U% V. t. f3 o
  45.             out << " TimeValue: " << infos[ii].TimeValue.GetText() << endl;
      b) x3 f1 U" N" l+ _8 @& F" I1 B
  46.             break;0 Z, d: c/ W, r
  47.         }) |0 p/ y( ^) P

  48. " `# u. B5 N$ b+ Z- I( P
  49.         print(out.str().c_str());
    ' |6 a) `% u6 H( {* ]) B
  50.     }$ }/ O! f" ]% ]* w8 ]( p

  51. 2 {5 y. H# I0 l! C  ?
  52. }% f& _& z: O- B9 e1 D/ z0 f8 \5 U
复制代码
5 b: o, J- H  G) Z2 n
$ y& o8 o, O5 `1 w

: Y4 |; P( J$ N
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

全部回复1

0

主题

13

回帖

56

积分

注册会员

积分
56
发表于 2019-4-25 18:49:57 | 显示全部楼层
有用的,解决
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复 支持 反对

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了