PLM之家PLMHome-工业软件践行者

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

[复制链接]

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

2470

主题

1275

回帖

8万

积分

管理员

PLM之家站长

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

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

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

x

: z" G. f6 s3 M/ s. MNX二次开发源码分享:报告当前工作部件的所有属性
) j$ ?  u! ?4 ]! Z" k- z主要是用过workPart->GetUserAttributes()获取属性信息;0 E% N7 T* W6 B/ `' G) G2 `% m
  1. void MyClass::do_it()8 c, l  _+ F8 ]6 m6 y5 C: v
  2. {: Q; n& ?' [) E% u# [4 X) i
  3.     stringstream out;
    ' B$ [2 l1 |' v# k
  4.     std::vector<NXOpen::NXObject::AttributeInformation> infos = workPart->GetUserAttributes();  ?2 V* F$ A: P3 C
  5.     out.str(""); out.clear();
    + ^( D+ Y' }% D, s5 i
  6.     out << "\nAttributes found: " << infos.size() << endl;7 p5 F3 n+ W3 D, g/ H) L
  7.     print(out.str().c_str());
    - j4 T2 N; \0 E( S
  8. , G9 L! M" G' D2 m2 @- Z& V3 T1 J
  9.     for (unsigned int ii=0; ii<infos.size(); ii++)
    + E7 Y3 a" L" A) }. k% d* L
  10.     {2 w1 f6 h( X; o9 N1 L  D
  11.         out.str(""); out.clear();. R- ^$ ?/ q" c( W( x
  12.         out << "\nAttribute: " << infos[ii].Title.GetText() << endl;
    0 D# y3 H( u% r, P
  13. , `5 A9 E, u7 u8 S# ?
  14.         out << " Array: " << infos[ii].Array << endl;
    ' T  U/ v& j8 I7 k
  15.         if( infos[ii].Category.GetText() )
    8 S1 i6 F% g4 t. {# [7 ?
  16.             out << " Category: " << infos[ii].Category.GetText() << endl;0 b) S: K3 e. {
  17.         else
    5 Z3 W- l7 ]) m  V' ?% k
  18.             out << " Category: NULL"  << endl;
    7 a& [/ U, W( l# [
  19.         out << " Inherited: " << infos[ii].Inherited << endl;" c) y- h+ o" U: p! T
  20.         out << " Locked: " << infos[ii].Locked << endl;- M" s- E4 C9 s
  21.         out << " OwnedBySystem: " << infos[ii].OwnedBySystem << endl;1 l& C3 F( y3 g' F
  22.         out << " PdmBased: " << infos[ii].PdmBased << endl;/ i4 A. C5 H& d& C- G# s; p0 d4 [
  23.         out << " Required: " << infos[ii].Required << endl;1 A& {3 O& }& ~3 i; }
  24.         out << " Type: " << infos[ii].Type << endl;
      A) d3 ~. i7 Z% ]  K
  25.         out << " Unset: " << infos[ii].Unset << endl;
    5 n* D4 c0 p* u9 U$ H
  26. 1 n1 g5 @. E1 V1 C. Y) x$ B
  27.         swiTCh ( infos[ii].Type )& a1 {& {" W& U5 c
  28.         {
    ( D% u0 Q) ~2 e6 t$ j' K! {
  29.         case NXObject::AttributeTypeInvalid:
    + n. L% v" l+ T* b/ t5 F
  30.             out << " Type is invalid." << endl;# C5 \/ z  ^+ b( c2 n$ b' t4 p' l
  31.             break;3 i& U5 L! H+ p. h) g' B7 r+ V
  32.         case NXObject::AttributeTypeBoolean:
    : L% e# P- D2 F1 y; p
  33.             out << " BooleanValue: " << infos[ii].BooleanValue << endl;. {3 ^( W- M) y: G# F. c
  34.             break;: O4 f8 `, L1 H$ h
  35.         case NXObject::AttributeTypeInteger:3 W* B" a" n4 G' e- T' i  p& @6 ?
  36.             out << " IntegerValue: " << infos[ii].IntegerValue << endl;( v% A2 w% P! C" [1 N( J
  37.             break;6 w/ \. o. K3 ^$ {3 a- q
  38.         case NXObject::AttributeTypeReal:
    , P9 F( [. W  q' e0 e
  39.             out << "RealValue: " << infos[ii].RealValue << endl;% C, g3 T1 n+ q9 }2 _& O0 K9 ^5 P
  40.             break;* @! g1 H5 w! B% D
  41.         case NXObject::AttributeTypeString:% P, A3 }* G) z/ `) h
  42.             out << " StringValue: " << infos[ii].StringValue.GetText() << endl;
    7 V- ^1 [! D. p
  43.             break;
    . J7 h$ M- b- {( V* \) X
  44.         case NXObject::AttributeTypeTime:
    2 S% t" X" `1 @+ e
  45.             out << " TimeValue: " << infos[ii].TimeValue.GetText() << endl;
    9 b& R. w" \. F$ R. A
  46.             break;
    + t/ v9 S8 \8 j/ `- ?, b
  47.         }, ~$ E0 f3 s8 z: E2 H
  48. ( Y& D: r1 m1 L6 @
  49.         print(out.str().c_str());
    & @/ q; L& H" k# P( x, n
  50.     }5 h+ _! X1 k( k
  51. , N- n1 s- S  }( A: N
  52. }
    8 ?# c' U& Q) W$ P3 n3 g% r6 l
复制代码
8 F. C. }/ J( ?' N

" O( h" j# z9 `6 i$ M/ @7 E! O2 w7 a( u
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

全部回复1

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

使用道具 举报

发表回复

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

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了