查看: 4210|回复: 1

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

[复制链接]

6

主题

4

回帖

60

积分

管理员

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

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

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

×

& L3 z; R9 N; Q; H( v; v% [/ UNX二次开发源码分享:报告当前工作部件的所有属性
" I' v8 E" _6 Q2 C" h主要是用过workPart->GetUserAttributes()获取属性信息;
/ R6 u# O& [( Z* W7 ]1 G  |* [* o
  1. void MyClass::do_it()
    1 W: L7 M7 j6 w# O1 ~
  2. {
    ' w" t8 L9 j4 z7 V+ ?
  3.     stringstream out;3 t8 x2 p9 P0 W% E' J3 L  n! R2 N
  4.     std::vector<NXOpen::NXObject::AttributeInformation> infos = workPart->GetUserAttributes();
    6 j6 b% n; p2 H' n  V. n' ~: M# l" ]
  5.     out.str(""); out.clear();" p2 K% M3 R1 ^. d# O
  6.     out << "\nAttributes found: " << infos.size() << endl;0 w+ J! n! r( m$ m' `8 n* E
  7.     print(out.str().c_str());
    . b% @) @" I! k  ], t

  8. ' D- ~' j% }) D6 A: W7 G9 L  T9 r
  9.     for (unsigned int ii=0; ii<infos.size(); ii++)4 W- l( M! _2 V* j. W* S
  10.     {1 T* E/ `. N) z7 l' R1 E4 A2 w3 o3 k1 D
  11.         out.str(""); out.clear();- \2 ~- X9 e8 I& k0 o4 u5 K
  12.         out << "\nAttribute: " << infos[ii].Title.GetText() << endl;" Y2 V% r4 X9 v
  13. " N% J" h. y6 J' h- Q" [+ E
  14.         out << " Array: " << infos[ii].Array << endl;
    6 q$ X6 f! w% }) b8 q' O
  15.         if( infos[ii].Category.GetText() )$ v$ x5 {0 e" X1 q  |- ^0 u
  16.             out << " Category: " << infos[ii].Category.GetText() << endl;
    6 _% K5 I% D; D% k% Y$ }" F) D
  17.         else( u: q: `5 C5 p4 Y. D" H  \
  18.             out << " Category: NULL"  << endl;
    0 J1 t: m' o3 e8 @2 @) z0 v5 |
  19.         out << " Inherited: " << infos[ii].Inherited << endl;
    0 R( U$ l. b2 |# ~
  20.         out << " Locked: " << infos[ii].Locked << endl;4 T# h3 }; B/ w* H6 E
  21.         out << " OwnedBySystem: " << infos[ii].OwnedBySystem << endl;. C* l& K/ M: W* D6 W6 v
  22.         out << " PdmBased: " << infos[ii].PdmBased << endl;* `0 g( \0 O, K! w
  23.         out << " Required: " << infos[ii].Required << endl;$ Z3 y  ~/ Z3 C4 Q6 M/ c- [
  24.         out << " Type: " << infos[ii].Type << endl;6 ?' a1 ?( ^. f9 j
  25.         out << " Unset: " << infos[ii].Unset << endl;; S9 g4 k' S& C1 x

  26. ) }" \. X1 D' c/ i0 U
  27.         swiTCh ( infos[ii].Type ); y4 l6 K7 T. e+ T* f' m! o
  28.         {# L# c5 B. C# r2 z: T, f' Q
  29.         case NXObject::AttributeTypeInvalid:& a. f" `7 g5 H. [' ~5 Z' }
  30.             out << " Type is invalid." << endl;
    ; j' g5 Z. I$ j0 W
  31.             break;0 J( j# g2 X3 W) @4 k% _
  32.         case NXObject::AttributeTypeBoolean:
    & {! `6 B4 t8 S& B
  33.             out << " BooleanValue: " << infos[ii].BooleanValue << endl;
    9 {% X) D8 D- g
  34.             break;
    7 s4 ~  U2 ?2 l; U9 m1 S
  35.         case NXObject::AttributeTypeInteger:
    + i; h- e8 }( r  K+ Y% D
  36.             out << " IntegerValue: " << infos[ii].IntegerValue << endl;
    0 r9 ^  d; |7 d, `) i
  37.             break;5 j6 \9 g9 x' N  h6 K$ E7 t9 ~
  38.         case NXObject::AttributeTypeReal:, b9 d2 l7 n6 s7 V% ~' p( \: c
  39.             out << "RealValue: " << infos[ii].RealValue << endl;0 c7 i1 I4 h) ^; ]
  40.             break;
    & R2 |, K- Z: `3 B
  41.         case NXObject::AttributeTypeString:. \  V! ^  r5 o2 y4 A
  42.             out << " StringValue: " << infos[ii].StringValue.GetText() << endl;: k. ]. L. d- G4 v' U. [
  43.             break;  C' z; s4 B5 L; a) \5 a
  44.         case NXObject::AttributeTypeTime:6 v0 x3 |7 [& r) |
  45.             out << " TimeValue: " << infos[ii].TimeValue.GetText() << endl;
    + @5 i6 B; h4 J0 I5 U6 R
  46.             break;
    3 p3 z0 ?+ D' P* O' o0 T! m( V
  47.         }* j; G, ]4 b. j! j
  48. 1 w1 w6 _% N6 J" `  _& n% E
  49.         print(out.str().c_str());
    ) X2 V* F( k- q2 e* X: p4 @% v
  50.     }3 @6 W6 @  O, A* f8 z  Y
  51. 4 V) q3 g+ a  j# m" `
  52. }2 E9 X7 B1 j: V  r# R
复制代码
' O3 n$ @  m$ h: Q2 Y6 i
+ a3 \9 j3 Y0 v( \. V: H0 S

) [0 q. D. W& h% J9 T  _" j, Y) ]
上海点团信息科技有限公司,承接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客服返回顶部