|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
, s, u* b V% ^5 B
NX二次开发源码分享:报告当前工作部件的所有属性
# w. c o, P% O( W4 L/ m主要是用过workPart->GetUserAttributes()获取属性信息;
( N# W: |7 X5 E$ D, J- void MyClass::do_it()
9 @+ g! A+ C, K R$ x) u. R - {5 _" E: h: i- I& n" @9 w. A
- stringstream out;
! t9 T3 c) K) b* `( p. ` - std::vector<NXOpen::NXObject::AttributeInformation> infos = workPart->GetUserAttributes();
- Y2 |$ j# V( B - out.str(""); out.clear();4 H8 l T" I6 p0 v6 z
- out << "\nAttributes found: " << infos.size() << endl;
4 S8 S9 |# y" f2 Y2 J - print(out.str().c_str());+ s) T; P& Y2 Q( l* K
9 Z% n1 L' g1 Q) M- for (unsigned int ii=0; ii<infos.size(); ii++)
5 K' s9 |# [* E# w5 \/ h - {
2 b4 t% P' x C: O6 }$ F# U" M, U - out.str(""); out.clear();' c# Z; i6 b* y. e9 t1 u$ b, n
- out << "\nAttribute: " << infos[ii].Title.GetText() << endl;1 x* ^0 w h! S% X @' Y! X8 I! i* u
- 7 \2 G2 k% t& ?8 @1 p; o1 e
- out << " Array: " << infos[ii].Array << endl;
( n' v. a6 L) v* L/ v f0 A9 G - if( infos[ii].Category.GetText() )
4 |' x/ @ B. E4 z2 r( c - out << " Category: " << infos[ii].Category.GetText() << endl;
1 H J" `6 G5 N R& i- ~7 g. U+ M - else" J5 D7 Z0 _, d! V$ j$ {$ c# I9 j
- out << " Category: NULL" << endl;9 h/ ~& K' T% W. H
- out << " Inherited: " << infos[ii].Inherited << endl;' P: ]" i$ b0 S: r1 [$ K
- out << " Locked: " << infos[ii].Locked << endl;
' X# ~3 @$ X5 @& Y+ p% L0 T; h. _ - out << " OwnedBySystem: " << infos[ii].OwnedBySystem << endl;
. L5 |$ f8 E' w - out << " PdmBased: " << infos[ii].PdmBased << endl;
- ?, d w ]5 ~! l1 U8 y+ H - out << " Required: " << infos[ii].Required << endl;
4 m! E% Q: H: a7 x - out << " Type: " << infos[ii].Type << endl;
5 a5 J k9 z8 o' R& O" b - out << " Unset: " << infos[ii].Unset << endl;+ t$ h. D6 K \" i) l! \
- ! R$ K6 w0 z! l" y+ ^5 ^
- swiTCh ( infos[ii].Type )
" A# o3 o N0 j! a) {2 b* { - {
6 L9 `5 I0 f' r& J - case NXObject::AttributeTypeInvalid:
% k( H0 u5 S2 a* h - out << " Type is invalid." << endl;$ U2 m' X, v* e) I) X n
- break;
! w% W' p% c8 e - case NXObject::AttributeTypeBoolean:' E5 F0 Y$ h5 ~% V
- out << " BooleanValue: " << infos[ii].BooleanValue << endl;
( @" s1 p" P F* e - break;% L& i d5 O- [/ R) A* L1 X
- case NXObject::AttributeTypeInteger:0 I* K5 R( k" M# m* h- d
- out << " IntegerValue: " << infos[ii].IntegerValue << endl;
& [4 T& Z& m7 C. b) G3 { - break;% S2 ~ ?/ p+ c9 H0 P) m# u% `
- case NXObject::AttributeTypeReal:
3 n$ D4 z8 c% u" Z/ ` - out << "RealValue: " << infos[ii].RealValue << endl;
9 S* K" m- R9 N" N9 {% W - break;
: ?2 S. f2 n3 W8 ^3 v: R - case NXObject::AttributeTypeString:
$ W9 \5 p$ O! j3 X$ Q - out << " StringValue: " << infos[ii].StringValue.GetText() << endl;: q( f& n6 Q+ y( H" c, k3 X. [% ^+ P
- break;: i3 U7 m! j* N/ R
- case NXObject::AttributeTypeTime:3 L+ S$ w: i9 W/ O9 H
- out << " TimeValue: " << infos[ii].TimeValue.GetText() << endl;3 @( `/ Y9 r) }- h& a4 r9 f, U
- break;1 A* C3 K: x9 M: Y& G$ J$ O
- }$ ~ N, L2 L( b. q2 T
2 u# r, m: T" J9 n, [. {, p9 f- print(out.str().c_str());
0 J( H/ w: D: h/ I9 J' Z% s - }, p1 d+ O1 n1 ?# h; r
- : Y6 a' Q3 V7 G$ S: z9 T
- }
" g/ F' L' h; C% O) G' m! Q
复制代码
: x$ @: k4 x5 T0 ?) i# x4 E. H# [4 h* b; U. N1 @ J1 r+ N; \
; A3 v8 r( Z. v5 Z* H5 v" C
|
|