|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
7 `! x3 Y# M& q; v; H0 t# t9 a+ |" z3 GNX二次开发源码分享:报告当前工作部件的所有属性
v5 w) c& C+ ]$ b1 m- U9 e主要是用过workPart->GetUserAttributes()获取属性信息;/ F% ] m4 _& O% Y
- void MyClass::do_it()' ?* ?4 R% B' z& T/ _/ `& X) s
- {0 W$ [! C7 N4 i( P, {) O; F: N2 ^
- stringstream out;
5 A7 ~! ~- a3 g& z3 T - std::vector<NXOpen::NXObject::AttributeInformation> infos = workPart->GetUserAttributes();# n/ w1 G: g0 B4 y* S! C
- out.str(""); out.clear();
* ]8 D( Z# a8 \% x - out << "\nAttributes found: " << infos.size() << endl; J0 O' l8 }5 i1 v
- print(out.str().c_str());' D/ J6 O x$ O6 @
- , N3 _1 s' O( Q: C/ m
- for (unsigned int ii=0; ii<infos.size(); ii++)( _ z5 k' I6 p- J, r
- {
3 |' M+ @9 r" t# ~9 t4 t - out.str(""); out.clear();) u. H# \8 P. U- ^6 J
- out << "\nAttribute: " << infos[ii].Title.GetText() << endl;: t" d' q& ?: R, u! `* Y3 h
- " C& I0 t+ V. b {+ ?5 s5 j. ^
- out << " Array: " << infos[ii].Array << endl;/ C' t0 e+ A' X8 |! v" H$ V
- if( infos[ii].Category.GetText() )
/ V7 s4 \- z9 s( t - out << " Category: " << infos[ii].Category.GetText() << endl;
4 L! R5 ]! e7 m7 C" T - else
% i ~& j7 k+ x1 o! F - out << " Category: NULL" << endl;
' X, [6 I, o% C. o: j - out << " Inherited: " << infos[ii].Inherited << endl;
& F' s; e+ E/ E" O$ P - out << " Locked: " << infos[ii].Locked << endl;/ `: O+ p1 r5 O, n$ ~
- out << " OwnedBySystem: " << infos[ii].OwnedBySystem << endl;6 j- l9 K# k+ e* V
- out << " PdmBased: " << infos[ii].PdmBased << endl;
: y$ {9 y* ?8 [1 r% m - out << " Required: " << infos[ii].Required << endl;
4 r: A! e2 z u9 \! q - out << " Type: " << infos[ii].Type << endl;8 B, n+ O+ x* r; J) L" P! s
- out << " Unset: " << infos[ii].Unset << endl;/ D, F; v0 ^# r" s- @: }. j8 l* f
- & h! E, p+ s! p8 s1 t( X/ j7 `
- swiTCh ( infos[ii].Type ); i4 h# ?6 t3 O# p( {$ a6 E9 }0 f
- {% I$ y- ]6 P0 d; H; O
- case NXObject::AttributeTypeInvalid:! k* |; M$ R& _; \. @1 m
- out << " Type is invalid." << endl;
0 o% U: A! ?& c - break;
& R* s! { B0 ~& T - case NXObject::AttributeTypeBoolean:
6 d, o/ R, ?2 [+ | - out << " BooleanValue: " << infos[ii].BooleanValue << endl;
N- }. s# M1 _% T2 y - break;" B/ R7 r0 r* }$ B0 t: I o
- case NXObject::AttributeTypeInteger:
8 b& s+ b; ] n7 L - out << " IntegerValue: " << infos[ii].IntegerValue << endl;+ u( s! ?8 v" S1 U* F" m
- break;+ M" k( A+ |. A5 i$ f
- case NXObject::AttributeTypeReal:2 M; y: F: D8 ?6 k: Y
- out << "RealValue: " << infos[ii].RealValue << endl;
+ f& |- N( M8 n. o5 M9 i - break;
5 s: K9 q6 m7 g" q5 M% _/ ]* V. D - case NXObject::AttributeTypeString:0 Q- t6 Z3 G4 c1 t# I* l
- out << " StringValue: " << infos[ii].StringValue.GetText() << endl;. E _( U2 p+ W! v& n) K1 _
- break;# n; k( `4 D% ?* [. }9 S& K
- case NXObject::AttributeTypeTime:5 e2 n% U. h- v! o o. q3 |
- out << " TimeValue: " << infos[ii].TimeValue.GetText() << endl;
p' Y" h' D& q- M$ s Z& ~( }- ^ - break;; G: Q& b4 U7 r/ ]
- }4 L1 j* x4 z& {2 M& m1 i; I
- 3 F$ p8 } C; U( a/ z
- print(out.str().c_str());
6 f4 S' V# H- Q- J- m& |% G - }5 F; B/ B1 z6 W% i; v& {
5 v5 J" Y: x9 L m& Q5 K* Z0 d8 E- }
. y- [1 p% i9 V- l$ ]- p8 Z$ ~5 R
复制代码
( d" N0 i; r7 `" o4 j/ Y' l g7 h* ^# o, N
E5 @/ `* ]& k: ^4 l
|
|