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

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

[复制链接]

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

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

admin 楼主

2014-11-4 20:48:40

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

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

x
: F- K" w) N, j9 m# n
NX二次开发源码分享:报告当前工作部件的所有属性' c- N' I0 T. k7 t) H
主要是用过workPart->GetUserAttributes()获取属性信息;
# _' p$ d# C3 u+ `
  1. void MyClass::do_it()
    ( ?8 [9 }# j5 t- R7 S: N! e
  2. {
    , r4 f- J  p! ^
  3.     stringstream out;
    " ?! x5 I* C0 m# c
  4.     std::vector<NXOpen::NXObject::AttributeInformation> infos = workPart->GetUserAttributes();" ~- E# j; `4 i4 ~  c$ S2 B
  5.     out.str(""); out.clear();# g/ ?- G: W$ J" F8 e$ E
  6.     out << "\nAttributes found: " << infos.size() << endl;
    + n$ p& H5 h1 v
  7.     print(out.str().c_str());& Z( j2 r2 ]. H. S) C% C0 F" D  ]

  8.   L& a" k% _' ~& W0 P
  9.     for (unsigned int ii=0; ii<infos.size(); ii++)
    $ S! R# J( ~0 u8 H- J- C, d8 _
  10.     {3 B# e: L5 [* w
  11.         out.str(""); out.clear();4 a0 N2 @- ~7 n; K5 ~
  12.         out << "\nAttribute: " << infos[ii].Title.GetText() << endl;) T! c+ H7 x1 A0 |& s  a+ Q( L

  13. 8 f# ]. R/ _1 f4 g- T1 X
  14.         out << " Array: " << infos[ii].Array << endl;4 t2 ?& Q  o8 N  ~  A. \' [
  15.         if( infos[ii].Category.GetText() )3 s% k" _7 Z( e; |
  16.             out << " Category: " << infos[ii].Category.GetText() << endl;
    ! n6 x3 v! o3 P
  17.         else$ d& F' e$ l$ C
  18.             out << " Category: NULL"  << endl;9 Z7 P, h5 X2 R2 d
  19.         out << " Inherited: " << infos[ii].Inherited << endl;
      D( z6 f9 Y$ e
  20.         out << " Locked: " << infos[ii].Locked << endl;+ z* P/ z; x! h3 r0 g1 x' G) ~; X
  21.         out << " OwnedBySystem: " << infos[ii].OwnedBySystem << endl;
    6 B2 x8 S9 n0 Y
  22.         out << " PdmBased: " << infos[ii].PdmBased << endl;- u! A3 G( B" P
  23.         out << " Required: " << infos[ii].Required << endl;
    4 m8 l0 x2 q) P* B
  24.         out << " Type: " << infos[ii].Type << endl;
    % g* j0 B3 j! f- S2 ]9 g. n
  25.         out << " Unset: " << infos[ii].Unset << endl;
    / a' e! [+ W) }9 r; E6 t

  26. + `  y7 r! b+ b
  27.         swiTCh ( infos[ii].Type )% w2 c0 R/ q" N& l9 p
  28.         {
    : I, x; A; W( C* i  [
  29.         case NXObject::AttributeTypeInvalid:. w1 e7 ]% B8 _& T* O1 T
  30.             out << " Type is invalid." << endl;
    4 ~$ g) H/ H% Q" c+ \, ]# J0 @
  31.             break;! N2 A7 I: ~: ^7 ]) ]/ s
  32.         case NXObject::AttributeTypeBoolean:
    1 k7 W+ i+ x0 A' B; _* ^" E/ P
  33.             out << " BooleanValue: " << infos[ii].BooleanValue << endl;
    7 G7 W8 E1 u# W, t1 P. B8 |( l
  34.             break;2 t- I$ H# S% B$ Q" r
  35.         case NXObject::AttributeTypeInteger:
    : Y( X5 v" T7 r' S, N. }
  36.             out << " IntegerValue: " << infos[ii].IntegerValue << endl;
    5 Y+ a* u; ]6 w7 _( C" q" z6 w
  37.             break;4 h$ ~5 b6 i6 W# W; G. e
  38.         case NXObject::AttributeTypeReal:+ y% K5 E- ?2 Y+ ^
  39.             out << "RealValue: " << infos[ii].RealValue << endl;& K  t7 q6 d' m+ e. b
  40.             break;) X% K1 H' c8 x2 C0 o3 y, t) b
  41.         case NXObject::AttributeTypeString:
    % C3 @9 V7 x# f3 w* S1 C
  42.             out << " StringValue: " << infos[ii].StringValue.GetText() << endl;
    - c7 e. X4 X( T! _, u
  43.             break;
    & M5 _3 Q8 E. `- T+ @1 F- w2 P
  44.         case NXObject::AttributeTypeTime:2 x1 F# t7 }: s8 \
  45.             out << " TimeValue: " << infos[ii].TimeValue.GetText() << endl;
    3 ^; G# g! U' q* Y+ ~
  46.             break;& P1 v& V8 ~' m! K! |4 ~, B2 x8 D
  47.         }  e3 |# D% B$ y

  48. . M, f3 ~$ q6 c% L/ c
  49.         print(out.str().c_str());% A% g/ C2 w! i8 X8 v! d( n  z6 R
  50.     }% j( P. s6 T$ M

  51. / q0 J) S$ ^+ N) w5 W, y+ H
  52. }: W9 n" H! p9 ^6 Z
复制代码

; I! E6 K1 x7 a& c+ p/ S$ C1 F# J# I. |; [+ Y/ w

. H" r0 Y# Q" N* F- a' y
上海点团信息科技有限公司,承接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二次开发专题模块培训报名开始啦

    我知道了