查看: 4312|回复: 1

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

[复制链接]

6

主题

4

回帖

60

积分

管理员

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

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

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

×

4 R& }, O: D2 r7 c, GNX二次开发源码分享:报告当前工作部件的所有属性
5 F5 g/ x  j5 |) m0 I主要是用过workPart->GetUserAttributes()获取属性信息;+ ?( d, [; K% Z
  1. void MyClass::do_it()
    8 Q, T- U9 K0 w- U" g( l* V
  2. {+ {$ A; X' I1 P2 I
  3.     stringstream out;8 a& @2 u% `$ X. F# J
  4.     std::vector<NXOpen::NXObject::AttributeInformation> infos = workPart->GetUserAttributes();
    % c, G7 r4 o1 I- e, w/ t- s8 D
  5.     out.str(""); out.clear();
    0 \* U2 K* j1 C5 v2 u# k& c
  6.     out << "\nAttributes found: " << infos.size() << endl;
    $ V% d- K% j$ ]% N& W: K
  7.     print(out.str().c_str());6 P6 R9 C3 ]  N2 F: N5 h" b  R+ M

  8. 0 c9 m% l. G& n* J# _
  9.     for (unsigned int ii=0; ii<infos.size(); ii++)
    # n2 }1 n( f+ `" x: @0 Q
  10.     {
    . z1 M5 }4 ~7 a( t* j; V
  11.         out.str(""); out.clear();5 k' D6 ?4 V9 {! M# Y
  12.         out << "\nAttribute: " << infos[ii].Title.GetText() << endl;
    - c  m$ K( z" x1 a" u

  13. . H! y3 e! e. L+ f) @
  14.         out << " Array: " << infos[ii].Array << endl;
    8 z. E8 Y( m4 T, A; i  a: |0 A9 X
  15.         if( infos[ii].Category.GetText() )
    7 e8 J% Y% O! M( r2 o/ k) P. B, Q
  16.             out << " Category: " << infos[ii].Category.GetText() << endl;
    + w" ~  `* H4 F6 H+ M" H
  17.         else7 \4 R8 P9 ], \: S1 o; T
  18.             out << " Category: NULL"  << endl;/ q4 `3 ~8 |% }; _$ o
  19.         out << " Inherited: " << infos[ii].Inherited << endl;
    ' \1 Z; y4 g# S
  20.         out << " Locked: " << infos[ii].Locked << endl;4 {/ r% l1 X- e0 b/ R# t6 O2 z" u
  21.         out << " OwnedBySystem: " << infos[ii].OwnedBySystem << endl;6 ~, W6 s4 E2 Q4 d: o
  22.         out << " PdmBased: " << infos[ii].PdmBased << endl;4 R0 a2 E8 k! ^1 `. M0 }! u
  23.         out << " Required: " << infos[ii].Required << endl;. X4 s1 ~) @; X
  24.         out << " Type: " << infos[ii].Type << endl;. d' j( P) \1 m1 c' i' l
  25.         out << " Unset: " << infos[ii].Unset << endl;
    1 C+ F6 B' q0 `: b! H
  26. ' r# G0 a: i6 s* A9 g
  27.         swiTCh ( infos[ii].Type )
    5 R/ u* X3 G/ S% [- U  {
  28.         {( i4 g+ z2 z; |1 @# S0 D
  29.         case NXObject::AttributeTypeInvalid:
    5 i8 d, ^: f, v! {
  30.             out << " Type is invalid." << endl;+ d6 h1 B2 Z, |- j" t! u
  31.             break;+ O- l$ `9 g: i, r2 x/ C7 O" k
  32.         case NXObject::AttributeTypeBoolean:4 H/ u. {  g; M
  33.             out << " BooleanValue: " << infos[ii].BooleanValue << endl;
    % v" a0 U1 O. I1 A6 B
  34.             break;
    + r* V9 \0 V' }9 y2 j. y4 F; g3 |  z+ l
  35.         case NXObject::AttributeTypeInteger:
    . Q+ A; [: Z1 X  Z
  36.             out << " IntegerValue: " << infos[ii].IntegerValue << endl;
    / ]* G' k* s- j$ D1 e+ I( L0 `
  37.             break;
    7 q/ ]# o$ h+ Y8 v& j" f
  38.         case NXObject::AttributeTypeReal:
      Z' @, ^; o$ P- c) }8 A
  39.             out << "RealValue: " << infos[ii].RealValue << endl;; a7 b8 k# i0 E+ B+ ~0 a
  40.             break;
    1 Y1 n$ p% r& p/ U4 c/ W9 F* a2 b# e
  41.         case NXObject::AttributeTypeString:/ V7 b) I; p' I# w6 Z' I$ J+ l
  42.             out << " StringValue: " << infos[ii].StringValue.GetText() << endl;
    4 T9 ~- @; O0 O5 A+ C# k2 w% s) E) e
  43.             break;
    9 r) k1 D4 U2 e) y1 h+ Q. m
  44.         case NXObject::AttributeTypeTime:
    ' Y. f9 W  K  L" N3 q1 F" h8 q* T
  45.             out << " TimeValue: " << infos[ii].TimeValue.GetText() << endl;5 R, _% }- r; p9 f8 Y
  46.             break;
    1 X& ~! y6 }4 g: ~  _6 t' @4 v, |
  47.         }
    4 x0 ^( W3 g- g, o4 C

  48. " i; S- O2 e' p8 ^6 a$ `! L! h+ d
  49.         print(out.str().c_str());- r1 b- Y4 Z* K/ d0 }/ P6 m+ X
  50.     }
    ) K& ?0 [5 ^/ P# {; b' z1 x

  51. & s. W' }" @: d, ?
  52. }
    / X/ r2 Q* ~, F2 G$ d* r8 ~* _
复制代码

; ~4 {# g& x' m0 H( V- S* U
( o  G8 D4 \9 i6 |
3 B6 B: `9 R$ J8 x- _6 R/ q
上海点团信息科技有限公司,承接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客服返回顶部