|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
% O$ B4 K( T1 L I0 pNX二次开发源码分享:报告当前工作部件的所有属性/ x2 n7 o6 c( U. ^$ N ]0 Z
主要是用过workPart->GetUserAttributes()获取属性信息;
& @/ J7 L; j1 `+ o- L( w$ n- void MyClass::do_it()9 z. @; e! Y" E7 L) [/ j3 b
- {/ f! Z w: c0 x {/ d# ~
- stringstream out;
K! N' |4 O; r/ { - std::vector<NXOpen::NXObject::AttributeInformation> infos = workPart->GetUserAttributes();7 o8 s" n( z& S- z L6 g" C
- out.str(""); out.clear();
7 w2 h" f4 k0 [8 R - out << "\nAttributes found: " << infos.size() << endl;' B( {/ a {( G7 w% [# {0 p
- print(out.str().c_str());. q$ Z' a' G/ k* M6 s
- ; b y1 D8 q3 O) X" A1 w
- for (unsigned int ii=0; ii<infos.size(); ii++)
' L2 A0 K. ]: B - {
5 _ c- L! Q) Q3 @- _ - out.str(""); out.clear();4 [1 E2 b/ s$ q) y
- out << "\nAttribute: " << infos[ii].Title.GetText() << endl;* R' v {; }# B: m) c
- / m- Z0 V' O) D' V4 K e% H
- out << " Array: " << infos[ii].Array << endl;
7 v$ L: Z# [# t7 D - if( infos[ii].Category.GetText() )
; W( t+ G: J% T0 F% E; N8 ]2 y - out << " Category: " << infos[ii].Category.GetText() << endl;
' ?8 b( e3 c' N0 O - else
n0 h, Y* j" c: y# H& X" F# ` - out << " Category: NULL" << endl;2 ~& {. |, P0 o1 |# w
- out << " Inherited: " << infos[ii].Inherited << endl;' d* {7 U; r. i9 w; d
- out << " Locked: " << infos[ii].Locked << endl;
! F0 r, B6 w& Y2 S/ I% r0 V - out << " OwnedBySystem: " << infos[ii].OwnedBySystem << endl;6 L5 P% I* K- ^8 G2 ?% L- e
- out << " PdmBased: " << infos[ii].PdmBased << endl;# H% |( G3 f3 y: r ]) M9 C" ^. J
- out << " Required: " << infos[ii].Required << endl;7 C6 R+ Q0 W7 \$ H1 o' f
- out << " Type: " << infos[ii].Type << endl;6 T) m! x' K1 u- Z2 s. Y% r: ?
- out << " Unset: " << infos[ii].Unset << endl;9 h0 F$ M! [# v; b5 Q9 k$ I$ m8 }; k
- 6 y+ \$ m/ O3 ^1 M2 P
- swiTCh ( infos[ii].Type )9 e0 |! Z! j8 A P$ G6 W# n7 w. Z
- {- m$ \6 g% O2 ]' t {
- case NXObject::AttributeTypeInvalid:
5 i8 A& k3 ?) h" }. y6 W - out << " Type is invalid." << endl;4 U* N3 X1 N2 O: R
- break;
$ ~' |) t: ]- X( D2 K2 |9 e" R9 z - case NXObject::AttributeTypeBoolean:6 U% s3 h6 s' K5 l8 g1 }/ J9 ^8 A; [
- out << " BooleanValue: " << infos[ii].BooleanValue << endl;- U% r) W! w8 @+ {2 t5 k0 X
- break;( m9 U- U/ x% A
- case NXObject::AttributeTypeInteger:
% H, L# o6 I% X3 L% U - out << " IntegerValue: " << infos[ii].IntegerValue << endl;8 s% B- o5 ] F" s- n7 q8 M
- break;
; g2 x$ V: k/ B- z4 X - case NXObject::AttributeTypeReal:
/ Q% ]! r) H X) k - out << "RealValue: " << infos[ii].RealValue << endl;. k( Y+ k2 V4 W ~# U- C
- break;
3 |4 i$ u% @& D5 H5 E$ k - case NXObject::AttributeTypeString:
, X7 n/ U1 G& j$ U6 h6 f - out << " StringValue: " << infos[ii].StringValue.GetText() << endl;7 L/ C2 |8 [* p/ t* c3 A( |
- break;3 f0 R# a" P; t: e) {& ^6 G+ b5 ]* X
- case NXObject::AttributeTypeTime:
7 ~$ W6 c4 |' F" U% V. t. f3 o - out << " TimeValue: " << infos[ii].TimeValue.GetText() << endl;
b) x3 f1 U" N" l+ _8 @& F" I1 B - break;0 Z, d: c/ W, r
- }) |0 p/ y( ^) P
" `# u. B5 N$ b+ Z- I( P- print(out.str().c_str());
' |6 a) `% u6 H( {* ]) B - }$ }/ O! f" ]% ]* w8 ]( p
2 {5 y. H# I0 l! C ?- }% f& _& z: O- B9 e1 D/ z0 f8 \5 U
复制代码 5 b: o, J- H G) Z2 n
$ y& o8 o, O5 `1 w
: Y4 |; P( J$ N |
|