|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
4 R& }, O: D2 r7 c, GNX二次开发源码分享:报告当前工作部件的所有属性
5 F5 g/ x j5 |) m0 I主要是用过workPart->GetUserAttributes()获取属性信息;+ ?( d, [; K% Z
- void MyClass::do_it()
8 Q, T- U9 K0 w- U" g( l* V - {+ {$ A; X' I1 P2 I
- stringstream out;8 a& @2 u% `$ X. F# J
- std::vector<NXOpen::NXObject::AttributeInformation> infos = workPart->GetUserAttributes();
% c, G7 r4 o1 I- e, w/ t- s8 D - out.str(""); out.clear();
0 \* U2 K* j1 C5 v2 u# k& c - out << "\nAttributes found: " << infos.size() << endl;
$ V% d- K% j$ ]% N& W: K - print(out.str().c_str());6 P6 R9 C3 ] N2 F: N5 h" b R+ M
0 c9 m% l. G& n* J# _- for (unsigned int ii=0; ii<infos.size(); ii++)
# n2 }1 n( f+ `" x: @0 Q - {
. z1 M5 }4 ~7 a( t* j; V - out.str(""); out.clear();5 k' D6 ?4 V9 {! M# Y
- out << "\nAttribute: " << infos[ii].Title.GetText() << endl;
- c m$ K( z" x1 a" u
. H! y3 e! e. L+ f) @- out << " Array: " << infos[ii].Array << endl;
8 z. E8 Y( m4 T, A; i a: |0 A9 X - if( infos[ii].Category.GetText() )
7 e8 J% Y% O! M( r2 o/ k) P. B, Q - out << " Category: " << infos[ii].Category.GetText() << endl;
+ w" ~ `* H4 F6 H+ M" H - else7 \4 R8 P9 ], \: S1 o; T
- out << " Category: NULL" << endl;/ q4 `3 ~8 |% }; _$ o
- out << " Inherited: " << infos[ii].Inherited << endl;
' \1 Z; y4 g# S - out << " Locked: " << infos[ii].Locked << endl;4 {/ r% l1 X- e0 b/ R# t6 O2 z" u
- out << " OwnedBySystem: " << infos[ii].OwnedBySystem << endl;6 ~, W6 s4 E2 Q4 d: o
- out << " PdmBased: " << infos[ii].PdmBased << endl;4 R0 a2 E8 k! ^1 `. M0 }! u
- out << " Required: " << infos[ii].Required << endl;. X4 s1 ~) @; X
- out << " Type: " << infos[ii].Type << endl;. d' j( P) \1 m1 c' i' l
- out << " Unset: " << infos[ii].Unset << endl;
1 C+ F6 B' q0 `: b! H - ' r# G0 a: i6 s* A9 g
- swiTCh ( infos[ii].Type )
5 R/ u* X3 G/ S% [- U { - {( i4 g+ z2 z; |1 @# S0 D
- case NXObject::AttributeTypeInvalid:
5 i8 d, ^: f, v! { - out << " Type is invalid." << endl;+ d6 h1 B2 Z, |- j" t! u
- break;+ O- l$ `9 g: i, r2 x/ C7 O" k
- case NXObject::AttributeTypeBoolean:4 H/ u. { g; M
- out << " BooleanValue: " << infos[ii].BooleanValue << endl;
% v" a0 U1 O. I1 A6 B - break;
+ r* V9 \0 V' }9 y2 j. y4 F; g3 | z+ l - case NXObject::AttributeTypeInteger:
. Q+ A; [: Z1 X Z - out << " IntegerValue: " << infos[ii].IntegerValue << endl;
/ ]* G' k* s- j$ D1 e+ I( L0 ` - break;
7 q/ ]# o$ h+ Y8 v& j" f - case NXObject::AttributeTypeReal:
Z' @, ^; o$ P- c) }8 A - out << "RealValue: " << infos[ii].RealValue << endl;; a7 b8 k# i0 E+ B+ ~0 a
- break;
1 Y1 n$ p% r& p/ U4 c/ W9 F* a2 b# e - case NXObject::AttributeTypeString:/ V7 b) I; p' I# w6 Z' I$ J+ l
- out << " StringValue: " << infos[ii].StringValue.GetText() << endl;
4 T9 ~- @; O0 O5 A+ C# k2 w% s) E) e - break;
9 r) k1 D4 U2 e) y1 h+ Q. m - case NXObject::AttributeTypeTime:
' Y. f9 W K L" N3 q1 F" h8 q* T - out << " TimeValue: " << infos[ii].TimeValue.GetText() << endl;5 R, _% }- r; p9 f8 Y
- break;
1 X& ~! y6 }4 g: ~ _6 t' @4 v, | - }
4 x0 ^( W3 g- g, o4 C
" i; S- O2 e' p8 ^6 a$ `! L! h+ d- print(out.str().c_str());- r1 b- Y4 Z* K/ d0 }/ P6 m+ X
- }
) K& ?0 [5 ^/ P# {; b' z1 x
& s. W' }" @: d, ?- }
/ X/ r2 Q* ~, F2 G$ d* r8 ~* _
复制代码
; ~4 {# g& x' m0 H( V- S* U
( o G8 D4 \9 i6 |
3 B6 B: `9 R$ J8 x- _6 R/ q |
|