|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
% ?) |1 F4 K- k" ?" I2 `: ^& j# C' R" mNX二次开发源码分享:报告当前工作部件的所有属性
- i) [0 G0 I9 ?; e% X: V主要是用过workPart->GetUserAttributes()获取属性信息;
1 {. b' ~" f- B' d. u& J& J- void MyClass::do_it()
7 Z8 {5 y7 Q. O4 d- ? - {; e2 w( D( B& p, ?% w/ l0 w& e
- stringstream out;
. ^6 ?: ], X" Z' U9 q8 a - std::vector<NXOpen::NXObject::AttributeInformation> infos = workPart->GetUserAttributes();
9 A' W9 m7 O- [" d - out.str(""); out.clear();
! ^5 V; h) Z# E0 w - out << "\nAttributes found: " << infos.size() << endl;2 J5 q5 D2 x$ n2 ~; I/ N; N1 H7 M
- print(out.str().c_str());
8 R+ n1 D6 V. R- Y0 c0 _' l$ I# D
7 `' ]+ r* k1 ?* h- for (unsigned int ii=0; ii<infos.size(); ii++)- I3 L' d7 n8 N9 r2 Z; U- B
- {$ m1 C3 h* v% X z" s1 H
- out.str(""); out.clear();5 C+ z) F- d- m' T9 w+ t* |; M+ ~
- out << "\nAttribute: " << infos[ii].Title.GetText() << endl;
2 k; e$ W! a- w4 b0 m! y( N - ! ~' Q+ e P$ K) b1 |3 U
- out << " Array: " << infos[ii].Array << endl;1 Q0 S7 l2 t: a+ U
- if( infos[ii].Category.GetText() )7 q; f6 k9 k3 S( D; z+ @' O2 C1 i
- out << " Category: " << infos[ii].Category.GetText() << endl;* g* O0 C% Z4 C2 b6 Z
- else O. U5 _2 `. L0 |. T
- out << " Category: NULL" << endl;
4 E4 N# b* v! D( m' i' u - out << " Inherited: " << infos[ii].Inherited << endl;
7 e1 x+ M3 u0 U+ t3 f" S. F - out << " Locked: " << infos[ii].Locked << endl;! { x+ j4 o5 V9 D! J ^
- out << " OwnedBySystem: " << infos[ii].OwnedBySystem << endl;
0 U/ b% w4 h8 D! k* b! Y& i/ M - out << " PdmBased: " << infos[ii].PdmBased << endl;
) H8 S' c/ m3 V! E1 W! {; a/ K - out << " Required: " << infos[ii].Required << endl;
& p. t6 P' D* U- Z; y, g6 Q - out << " Type: " << infos[ii].Type << endl;
7 l2 o* J. f/ ] - out << " Unset: " << infos[ii].Unset << endl;
/ @5 {5 s/ w6 \
; g) r3 n2 R' n' [* N2 n- swiTCh ( infos[ii].Type )
# c7 D0 ?* g5 [$ E. N - {7 q) x; l7 A+ P+ S8 z# E( ^9 u
- case NXObject::AttributeTypeInvalid:9 G% e# t |6 ^
- out << " Type is invalid." << endl;
4 e" c7 U* @' C+ ]1 s - break;
p8 y; R- y& x t3 N - case NXObject::AttributeTypeBoolean:
$ M |4 \' n4 V+ G9 \ - out << " BooleanValue: " << infos[ii].BooleanValue << endl;0 h, x9 {4 C' \
- break;
! N! d3 T" {( H! Q( W - case NXObject::AttributeTypeInteger:
/ q0 [/ R' `, W - out << " IntegerValue: " << infos[ii].IntegerValue << endl;2 ^: u1 A2 S) ?" E* Q
- break;
' e" Z" z. C& l& @ - case NXObject::AttributeTypeReal:4 ]# d: ^9 p3 }6 Z' R
- out << "RealValue: " << infos[ii].RealValue << endl;0 u- }- X( p! J0 |6 B
- break;
! z) A/ J% i; n4 z1 d7 q - case NXObject::AttributeTypeString:
6 O1 Z2 _+ z! w h6 i - out << " StringValue: " << infos[ii].StringValue.GetText() << endl;5 x3 ]: b! @0 ~- t5 R
- break;% W% J+ O" A% Z# n) N
- case NXObject::AttributeTypeTime:7 \4 _+ I0 `! r7 @6 T2 G
- out << " TimeValue: " << infos[ii].TimeValue.GetText() << endl;
; J: Q' t# c5 a5 G - break;" }) V' o c, [9 X0 t5 G' `
- }
4 f! P" L* I% U
7 L) f% E2 W3 L8 r5 W- print(out.str().c_str());( ]$ Y* Y0 [$ {, ~& x, Z( X
- }" z- m/ j! E2 a1 t$ ^! @
- ' f$ O; e- B# _9 q% O
- }/ I5 H( ~5 ]9 X V/ K$ ~
复制代码 ) l& V! q1 g* N; Y
, p, l+ P! ?& J5 |& _9 {
- o: u9 H" n( a# I- X# M |
|