|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
/ `% ?8 H+ H6 H/ ~3 z) _" Q
NX二次开发源码分享:报告当前工作部件的所有属性
" v$ ]# i" _5 Q+ n! J( C; C主要是用过workPart->GetUserAttributes()获取属性信息;
9 L; {. B+ p; `& I+ g4 m- c- void MyClass::do_it()
# Z' ^8 v2 v4 i4 b9 f3 k - {
8 H' X: A5 N' W1 }% }" x% `2 O: H+ f - stringstream out;
% a* R" P, `5 u/ l/ ~" z - std::vector<NXOpen::NXObject::AttributeInformation> infos = workPart->GetUserAttributes();
6 R/ {8 }# @7 I" D+ A - out.str(""); out.clear();
+ m+ U2 t6 Z0 l( z; p* q3 O% H - out << "\nAttributes found: " << infos.size() << endl;9 T9 D1 g0 M5 u
- print(out.str().c_str());
+ U; h1 u) b5 N$ D2 D/ A4 R
7 n6 t8 z5 |1 X" m+ d- for (unsigned int ii=0; ii<infos.size(); ii++)* k3 H4 P; b. w0 L1 y
- {
9 p. a$ I. @, \6 Y/ o/ x& W - out.str(""); out.clear();% L$ j Y! x! L" Q
- out << "\nAttribute: " << infos[ii].Title.GetText() << endl;+ ?( U3 c* F) n8 {! q3 W* d( Q: \
- : X. U9 G7 f+ I
- out << " Array: " << infos[ii].Array << endl;
$ L1 K- t+ c; s2 M5 @/ Y1 @ - if( infos[ii].Category.GetText() )* j q; {/ V( ^. e
- out << " Category: " << infos[ii].Category.GetText() << endl;
/ E* C3 l; K6 H - else) A7 u; y! x2 ]. D+ ~3 W
- out << " Category: NULL" << endl;* r- n' {4 t \) s9 }
- out << " Inherited: " << infos[ii].Inherited << endl; ~7 A1 w Q9 s- A
- out << " Locked: " << infos[ii].Locked << endl;# R5 }1 K3 _3 C Z7 N/ a
- out << " OwnedBySystem: " << infos[ii].OwnedBySystem << endl;" _! ^; I% j1 g8 J# g
- out << " PdmBased: " << infos[ii].PdmBased << endl;
6 s, [% f3 J4 f5 ~* ^# z - out << " Required: " << infos[ii].Required << endl;
4 q+ q; \7 Z1 S0 k* R/ G - out << " Type: " << infos[ii].Type << endl;
) a* Y. b9 n; M, F7 v' y! q- l, Z - out << " Unset: " << infos[ii].Unset << endl;
9 H/ s2 Q& L5 K* U$ T/ ]0 k+ I - p. \% X% ? H$ n
- swiTCh ( infos[ii].Type )
1 e# k3 N" J" j( y+ u6 G - {
5 g% C$ S7 d7 M! w8 } - case NXObject::AttributeTypeInvalid:
2 G- O8 _ k9 J8 G9 z$ \4 v - out << " Type is invalid." << endl;! j- d6 ?( L/ Y5 T+ O& ~* D7 S: h
- break;) X2 x, R0 x* y" {
- case NXObject::AttributeTypeBoolean:
: ]& G! _; w+ z - out << " BooleanValue: " << infos[ii].BooleanValue << endl;
5 V* e6 W" A' A0 { - break;
* C1 J" \8 ]; u3 ~% e - case NXObject::AttributeTypeInteger:
# X9 y+ L* V+ o. R# { - out << " IntegerValue: " << infos[ii].IntegerValue << endl;$ U3 g6 x- U N, U! m
- break;0 `# K, V( k% f& c1 s7 D; G9 h# l
- case NXObject::AttributeTypeReal:8 m8 t N# B2 e& R* ^ o, z' J$ Y
- out << "RealValue: " << infos[ii].RealValue << endl;; p2 x$ z. d. ^! z7 D5 d( n
- break;& J1 x& b W7 F7 j6 m/ \& U9 ~
- case NXObject::AttributeTypeString:
8 ^# D' p/ u: `* S& } - out << " StringValue: " << infos[ii].StringValue.GetText() << endl;/ w3 C- x* n3 u
- break;
5 I+ g8 r3 C5 A4 [' m - case NXObject::AttributeTypeTime:
) C3 H" z- l ]5 X O, C - out << " TimeValue: " << infos[ii].TimeValue.GetText() << endl;, W; m& b. I( G1 P# E( U" m
- break;
; f) a6 C" A( @) U. d - }- M2 R1 m6 a) `& k
- / u2 H+ ^$ P: Z
- print(out.str().c_str());; r1 |6 S1 v) t) W7 d$ G
- }6 i0 M" I* T. D7 m, W" y* r. u: n
- : r. r3 D( V2 S& D1 @1 p _
- }
4 g( i$ V, {# D! ~+ ]5 ?9 A8 l
复制代码
0 N( q7 L: R& X8 d; S F) R" k; ~# ^8 ~2 l- o" e x
* ?1 m1 H6 q: n2 F& A7 e3 o
|
|