查看: 4150|回复: 1

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

[复制链接]

4

主题

3

回帖

46

积分

管理员

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

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

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

×
! o4 G- ~' @0 W5 N- H; a# ?6 J
NX二次开发源码分享:报告当前工作部件的所有属性
; k9 M" A. f# M8 C8 W$ Y主要是用过workPart->GetUserAttributes()获取属性信息;
- E* K$ @, ~, C
  1. void MyClass::do_it()/ H' `  ~' n' i
  2. {, L) I8 z' E& _+ x' S
  3.     stringstream out;
    * P8 b# K4 m$ K! R4 A% a
  4.     std::vector<NXOpen::NXObject::AttributeInformation> infos = workPart->GetUserAttributes();. y6 z" Z* e& ?/ T4 B! q
  5.     out.str(""); out.clear();
    ( ~5 w, m* H6 n
  6.     out << "\nAttributes found: " << infos.size() << endl;
    ' J. g1 C- `2 `& x. a5 R
  7.     print(out.str().c_str());0 f1 ?1 |% k: P( ]
  8. , b4 c  H9 w  G+ M2 Q
  9.     for (unsigned int ii=0; ii<infos.size(); ii++)
      R3 m3 u, M9 F" s
  10.     {
    ) }7 a. F( c9 V3 z
  11.         out.str(""); out.clear();; R6 |: j) L' n  u2 f
  12.         out << "\nAttribute: " << infos[ii].Title.GetText() << endl;6 w) ^! }9 e* h2 L, P
  13. 1 S' h5 P' Z& X. M( w5 @
  14.         out << " Array: " << infos[ii].Array << endl;
    2 I5 [( i' F& p- K" T5 W
  15.         if( infos[ii].Category.GetText() )3 i3 r2 E; A& z
  16.             out << " Category: " << infos[ii].Category.GetText() << endl;. [" q5 J8 q1 \/ t+ t7 H
  17.         else2 P" i, X, E9 W0 D  Y+ R
  18.             out << " Category: NULL"  << endl;6 [& j% l7 M8 a8 u
  19.         out << " Inherited: " << infos[ii].Inherited << endl;
    9 G6 n6 W) I- ?1 p6 s2 {, r. G
  20.         out << " Locked: " << infos[ii].Locked << endl;6 ?2 A8 x( J! b* B4 j1 }. E
  21.         out << " OwnedBySystem: " << infos[ii].OwnedBySystem << endl;) L' N8 R' P4 Z5 L2 j
  22.         out << " PdmBased: " << infos[ii].PdmBased << endl;
    * o7 F$ B# h4 p. z1 M1 r$ M  ?
  23.         out << " Required: " << infos[ii].Required << endl;
    & {  `; d, C8 K
  24.         out << " Type: " << infos[ii].Type << endl;
    1 b" N; |$ p+ |5 d4 f: Y4 B2 t& d
  25.         out << " Unset: " << infos[ii].Unset << endl;! z& T; v5 S  k: a' {3 {2 k

  26. 5 e& h" Z5 }1 O& a5 b& }
  27.         swiTCh ( infos[ii].Type )9 Q! Z, ]" {) z# x2 H( f, @1 a
  28.         {" x1 s, j* }& J  b
  29.         case NXObject::AttributeTypeInvalid:9 Z& x) o$ i0 R, ?& m
  30.             out << " Type is invalid." << endl;3 P& M/ l! t) \+ k+ @( A
  31.             break;3 {. ^. F1 Z) K$ S
  32.         case NXObject::AttributeTypeBoolean:* ]6 I1 U0 t% n$ g! ]
  33.             out << " BooleanValue: " << infos[ii].BooleanValue << endl;
    - ]; L: i1 t6 O$ r! t
  34.             break;
    " L2 e8 j* Z$ v+ k' C- v
  35.         case NXObject::AttributeTypeInteger:' l! M/ M* q: z) U/ o' |3 }% V
  36.             out << " IntegerValue: " << infos[ii].IntegerValue << endl;! F6 T+ M$ N& Q0 {
  37.             break;
    3 x/ F' y) o- m, ]' ~& t  R. J
  38.         case NXObject::AttributeTypeReal:" W* @# }2 r" h+ i  z( E2 ]* L
  39.             out << "RealValue: " << infos[ii].RealValue << endl;4 H/ ^. W" a* V1 s2 g" [6 P
  40.             break;
    / O; J: H' K) F& E& w
  41.         case NXObject::AttributeTypeString:) F  q8 V+ I  }7 |/ I
  42.             out << " StringValue: " << infos[ii].StringValue.GetText() << endl;( [# v  l6 Y  [) J9 b: Y
  43.             break;
    . _6 V9 @- E$ r4 l; A9 y
  44.         case NXObject::AttributeTypeTime:
    7 C2 h& c" p' X
  45.             out << " TimeValue: " << infos[ii].TimeValue.GetText() << endl;$ `2 t; |& F, D
  46.             break;( {4 ]2 }) L. v
  47.         }
    7 x7 k5 y' c, i& D

  48. / d$ g; o9 h( W1 q% a
  49.         print(out.str().c_str());
    # {. U) }, l' y0 U+ w- z
  50.     }
    / c( `* `+ j+ u4 L1 y; H
  51. 9 `4 i* v. h+ I" j- ]
  52. }( ?8 a  k- c& _' G  r( W
复制代码
# G( p/ J5 j  f5 i3 }
* A) G- N4 K+ A  [

& i+ K5 ~8 e4 x
上海点团信息科技有限公司,承接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客服返回顶部