|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
& z- s$ Z3 p( GNX二次开发源码分享:报告当前工作部件的所有属性
3 l" g& a% p9 w3 C/ H主要是用过workPart->GetUserAttributes()获取属性信息;" r6 C1 G, E0 Y7 J- p
- void MyClass::do_it()
# O+ z; ?) p# s3 G+ F; ? - {! i& H4 k% T; S4 Y+ z
- stringstream out;- Z) B5 _ v) c# v3 U/ s3 j" ~
- std::vector<NXOpen::NXObject::AttributeInformation> infos = workPart->GetUserAttributes();
# Q/ n! B: [9 ^0 G4 W8 X, Q2 C - out.str(""); out.clear();
/ @) \, `) e3 ~4 K, P, N - out << "\nAttributes found: " << infos.size() << endl;
& h( Z" r0 h7 E P! Z4 n - print(out.str().c_str());
! o! @! T& X B" v6 o. P* { - - X; p; d& n* N" [* Y" V$ k
- for (unsigned int ii=0; ii<infos.size(); ii++)
2 s$ V: m1 W' o) L% m8 B/ u - {
) u, T- J( k7 |, O& R4 J - out.str(""); out.clear();
% ]6 C- q" K% M3 u; A1 ]) j( ?: Z - out << "\nAttribute: " << infos[ii].Title.GetText() << endl;3 N) W# b% }, ^' H
- , G0 N3 c2 ^" c+ ~' t6 J+ S1 d
- out << " Array: " << infos[ii].Array << endl;! M" {8 J: D( P, p9 s
- if( infos[ii].Category.GetText() )
7 G& x8 x* b3 G- C9 ~5 U8 t - out << " Category: " << infos[ii].Category.GetText() << endl;5 r3 H5 `" {' E4 ~3 Y7 g
- else
3 V' i6 H* c9 M7 ~" s: F - out << " Category: NULL" << endl;2 X( o+ D: F5 N2 b7 p1 E9 g, m
- out << " Inherited: " << infos[ii].Inherited << endl;5 E4 k/ }9 t! M7 `, x1 ?
- out << " Locked: " << infos[ii].Locked << endl;3 Y; T, |! J( u' I0 l
- out << " OwnedBySystem: " << infos[ii].OwnedBySystem << endl; E k2 p& l% N ?7 _
- out << " PdmBased: " << infos[ii].PdmBased << endl;
$ ^ J2 d& G& i7 ~/ r5 w - out << " Required: " << infos[ii].Required << endl;
4 ] s: b! ^0 a1 k; s: @! \7 f - out << " Type: " << infos[ii].Type << endl;& L8 o: h" ?+ x) B: W" \1 _& i
- out << " Unset: " << infos[ii].Unset << endl;2 v/ x3 Z E/ K3 Z7 |
; i9 c$ B% H- M) ^# B9 P- swiTCh ( infos[ii].Type )+ O; @( ^0 U3 K: O, X
- { H/ R3 L" ]4 _
- case NXObject::AttributeTypeInvalid:. Y( d$ ^, b) _7 D E4 u- L+ f
- out << " Type is invalid." << endl;
" k0 `% E) h1 u X( \# I - break;
5 W+ r+ K6 K& u5 P) X$ w - case NXObject::AttributeTypeBoolean:* o5 J/ Q" _+ ~5 ~& Z1 j8 D: x$ G
- out << " BooleanValue: " << infos[ii].BooleanValue << endl;
: U8 w/ u( v/ ~$ H* @' z c: d$ Z - break;9 s$ E4 Y* ~$ ~# i
- case NXObject::AttributeTypeInteger:
/ ]3 m8 s& \) C2 b: S! Q' J- y - out << " IntegerValue: " << infos[ii].IntegerValue << endl;
- C( J% Q3 e1 f3 `9 | - break;: W; ] ]. t K9 T' |$ O4 a
- case NXObject::AttributeTypeReal:
) _5 i: L' N; N0 |# u4 J1 R; s8 R - out << "RealValue: " << infos[ii].RealValue << endl;9 O7 _& B' D5 s5 E9 D5 N; p
- break;
6 g$ @: v7 j4 y+ b$ Z) G6 _ - case NXObject::AttributeTypeString:
7 l& n+ C" p/ y- r% n - out << " StringValue: " << infos[ii].StringValue.GetText() << endl;% r3 ^/ c/ ~$ X5 ^/ I
- break; a8 m6 J5 M. l7 ^
- case NXObject::AttributeTypeTime:
, R' H& v1 n! v - out << " TimeValue: " << infos[ii].TimeValue.GetText() << endl;
+ y+ r8 u" ^& r3 G - break;
# [4 T0 r+ e& J+ g$ F( T% J - }6 j, V7 x9 R4 e' ~* q
2 Q) F5 `: B+ J; E2 S- print(out.str().c_str());
2 f# h/ ^9 u s* N - }
3 a' c! G& q/ i1 O! x3 c# Z - - s6 r8 M! m( L5 Q5 @) m
- }
$ m. [) i, M# L) o
复制代码 . t0 j' a4 t$ t/ K
5 G) b1 Q! _ \) X: Y* y2 h9 z, {: u" y( h! k0 r6 |
|
|