查看: 4072|回复: 1

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

[复制链接]

4

主题

3

回帖

40

积分

管理员

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

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

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

×

& z- s$ Z3 p( GNX二次开发源码分享:报告当前工作部件的所有属性
3 l" g& a% p9 w3 C/ H主要是用过workPart->GetUserAttributes()获取属性信息;" r6 C1 G, E0 Y7 J- p
  1. void MyClass::do_it()
    # O+ z; ?) p# s3 G+ F; ?
  2. {! i& H4 k% T; S4 Y+ z
  3.     stringstream out;- Z) B5 _  v) c# v3 U/ s3 j" ~
  4.     std::vector<NXOpen::NXObject::AttributeInformation> infos = workPart->GetUserAttributes();
    # Q/ n! B: [9 ^0 G4 W8 X, Q2 C
  5.     out.str(""); out.clear();
    / @) \, `) e3 ~4 K, P, N
  6.     out << "\nAttributes found: " << infos.size() << endl;
    & h( Z" r0 h7 E  P! Z4 n
  7.     print(out.str().c_str());
    ! o! @! T& X  B" v6 o. P* {
  8. - X; p; d& n* N" [* Y" V$ k
  9.     for (unsigned int ii=0; ii<infos.size(); ii++)
    2 s$ V: m1 W' o) L% m8 B/ u
  10.     {
    ) u, T- J( k7 |, O& R4 J
  11.         out.str(""); out.clear();
    % ]6 C- q" K% M3 u; A1 ]) j( ?: Z
  12.         out << "\nAttribute: " << infos[ii].Title.GetText() << endl;3 N) W# b% }, ^' H
  13. , G0 N3 c2 ^" c+ ~' t6 J+ S1 d
  14.         out << " Array: " << infos[ii].Array << endl;! M" {8 J: D( P, p9 s
  15.         if( infos[ii].Category.GetText() )
    7 G& x8 x* b3 G- C9 ~5 U8 t
  16.             out << " Category: " << infos[ii].Category.GetText() << endl;5 r3 H5 `" {' E4 ~3 Y7 g
  17.         else
    3 V' i6 H* c9 M7 ~" s: F
  18.             out << " Category: NULL"  << endl;2 X( o+ D: F5 N2 b7 p1 E9 g, m
  19.         out << " Inherited: " << infos[ii].Inherited << endl;5 E4 k/ }9 t! M7 `, x1 ?
  20.         out << " Locked: " << infos[ii].Locked << endl;3 Y; T, |! J( u' I0 l
  21.         out << " OwnedBySystem: " << infos[ii].OwnedBySystem << endl;  E  k2 p& l% N  ?7 _
  22.         out << " PdmBased: " << infos[ii].PdmBased << endl;
    $ ^  J2 d& G& i7 ~/ r5 w
  23.         out << " Required: " << infos[ii].Required << endl;
    4 ]  s: b! ^0 a1 k; s: @! \7 f
  24.         out << " Type: " << infos[ii].Type << endl;& L8 o: h" ?+ x) B: W" \1 _& i
  25.         out << " Unset: " << infos[ii].Unset << endl;2 v/ x3 Z  E/ K3 Z7 |

  26. ; i9 c$ B% H- M) ^# B9 P
  27.         swiTCh ( infos[ii].Type )+ O; @( ^0 U3 K: O, X
  28.         {  H/ R3 L" ]4 _
  29.         case NXObject::AttributeTypeInvalid:. Y( d$ ^, b) _7 D  E4 u- L+ f
  30.             out << " Type is invalid." << endl;
    " k0 `% E) h1 u  X( \# I
  31.             break;
    5 W+ r+ K6 K& u5 P) X$ w
  32.         case NXObject::AttributeTypeBoolean:* o5 J/ Q" _+ ~5 ~& Z1 j8 D: x$ G
  33.             out << " BooleanValue: " << infos[ii].BooleanValue << endl;
    : U8 w/ u( v/ ~$ H* @' z  c: d$ Z
  34.             break;9 s$ E4 Y* ~$ ~# i
  35.         case NXObject::AttributeTypeInteger:
    / ]3 m8 s& \) C2 b: S! Q' J- y
  36.             out << " IntegerValue: " << infos[ii].IntegerValue << endl;
    - C( J% Q3 e1 f3 `9 |
  37.             break;: W; ]  ]. t  K9 T' |$ O4 a
  38.         case NXObject::AttributeTypeReal:
    ) _5 i: L' N; N0 |# u4 J1 R; s8 R
  39.             out << "RealValue: " << infos[ii].RealValue << endl;9 O7 _& B' D5 s5 E9 D5 N; p
  40.             break;
    6 g$ @: v7 j4 y+ b$ Z) G6 _
  41.         case NXObject::AttributeTypeString:
    7 l& n+ C" p/ y- r% n
  42.             out << " StringValue: " << infos[ii].StringValue.GetText() << endl;% r3 ^/ c/ ~$ X5 ^/ I
  43.             break;  a8 m6 J5 M. l7 ^
  44.         case NXObject::AttributeTypeTime:
    , R' H& v1 n! v
  45.             out << " TimeValue: " << infos[ii].TimeValue.GetText() << endl;
    + y+ r8 u" ^& r3 G
  46.             break;
    # [4 T0 r+ e& J+ g$ F( T% J
  47.         }6 j, V7 x9 R4 e' ~* q

  48. 2 Q) F5 `: B+ J; E2 S
  49.         print(out.str().c_str());
    2 f# h/ ^9 u  s* N
  50.     }
    3 a' c! G& q/ i1 O! x3 c# Z
  51. - s6 r8 M! m( L5 Q5 @) m
  52. }
    $ m. [) i, M# L) o
复制代码
. t0 j' a4 t$ t/ K

5 G) b1 Q! _  \) X: Y* y2 h9 z, {: u" y( h! k0 r6 |
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复

使用道具 举报

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
回复 支持 反对

使用道具 举报

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

本版积分规则

在本版发帖
关注公众号
QQ客服返回顶部