|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
* I8 ~& ~$ Q |7 d- DNX二次开发源码分享:报告当前工作部件的所有属性
& i# N( F A& j# n主要是用过workPart->GetUserAttributes()获取属性信息;
4 O! W5 ^/ Y) c! E2 i- void MyClass::do_it()- W, B1 A' d& f+ Q) i
- {5 _$ x- M6 h- @' c' A
- stringstream out;6 M% p: f3 H( r3 ]) t8 a, I6 E
- std::vector<NXOpen::NXObject::AttributeInformation> infos = workPart->GetUserAttributes();
1 p% J& V C+ u. V - out.str(""); out.clear(); t% u: u8 ~! `' M J
- out << "\nAttributes found: " << infos.size() << endl;3 {; k3 W# c, o. a
- print(out.str().c_str());3 V$ k2 P( \/ U
- ( t8 t, g2 ]7 u/ ^; i% m9 H
- for (unsigned int ii=0; ii<infos.size(); ii++)7 x7 @1 \) D" Y: j. |! U
- {
" r. W! S& ^4 N+ z, R( |+ u - out.str(""); out.clear();5 Y+ ?% f1 M# b/ M, |
- out << "\nAttribute: " << infos[ii].Title.GetText() << endl; i, L! A1 {8 c3 u+ S
& ^- H) o, s; i- out << " Array: " << infos[ii].Array << endl;
; t7 O# l8 Y2 X - if( infos[ii].Category.GetText() )
$ t5 k% N8 W: i3 D* q- T' x - out << " Category: " << infos[ii].Category.GetText() << endl;
0 T2 @! \1 ~3 @0 ^% P - else
( d6 H' Z3 i! H ? - out << " Category: NULL" << endl;
{ O) q2 e* ^9 W/ e4 r - out << " Inherited: " << infos[ii].Inherited << endl;
! p+ _6 S9 c9 n9 ~7 ^- x/ r. k - out << " Locked: " << infos[ii].Locked << endl;- ]# H' ? {: q& ^
- out << " OwnedBySystem: " << infos[ii].OwnedBySystem << endl;% `/ ]2 B; `+ [4 Q
- out << " PdmBased: " << infos[ii].PdmBased << endl;2 p# u2 d4 a2 y
- out << " Required: " << infos[ii].Required << endl;
+ p& V4 Y& Z" ], V; c( ? - out << " Type: " << infos[ii].Type << endl;. |3 ]. X$ v9 H) T- y
- out << " Unset: " << infos[ii].Unset << endl;
; W, X/ m" c- v" q4 J
& X: U; Z8 |4 o7 [1 G- swiTCh ( infos[ii].Type ); L7 p- q" k( p( b6 G
- {
6 ?1 u7 p, R, t- e" j - case NXObject::AttributeTypeInvalid:+ k a j2 Q* h4 W+ M& ~. F, T' F
- out << " Type is invalid." << endl;- d2 _, Y. K6 y& F4 ?% v) L' P/ m4 D
- break;, p8 J& l9 w5 L Y n+ ]7 n+ I
- case NXObject::AttributeTypeBoolean:7 ]6 C* q) o+ d" i( u
- out << " BooleanValue: " << infos[ii].BooleanValue << endl;
8 t& f+ [/ Y0 e- f8 c# P- N - break;( D# k' P: y* o4 k
- case NXObject::AttributeTypeInteger:, V0 ^0 h8 m5 X$ }) A+ Q
- out << " IntegerValue: " << infos[ii].IntegerValue << endl;
# f5 n9 p* \8 N1 ]8 ` - break;
; e% w# I+ B; `7 r - case NXObject::AttributeTypeReal:
) `; A6 k& z' q. X: l% U; c3 b# I - out << "RealValue: " << infos[ii].RealValue << endl;
( Q8 f3 f. H% | - break;$ @0 x4 U- l9 ?8 {: n0 |: ~* `
- case NXObject::AttributeTypeString:
7 _$ h1 ]/ x' Q' E - out << " StringValue: " << infos[ii].StringValue.GetText() << endl;! `1 X1 T4 `- x9 J) p" ~* h
- break;
' z" _9 \3 O# b - case NXObject::AttributeTypeTime:
Z: b2 Z6 o, ^3 |6 c+ }; _# k - out << " TimeValue: " << infos[ii].TimeValue.GetText() << endl;
5 w. I- D+ L! L& H8 U3 D( r - break;
! h9 o8 R: N3 d" o7 c - }7 T, k& y* v" q! Q7 m. x# ~
7 D) D: ] O$ _ w' I- print(out.str().c_str());6 w8 X t* _) k" K4 [
- }
) A/ \5 A, ~( P) V8 Z% B7 e5 [: d
' g9 |# a, i) n# r: f- }
1 i" w' L) M, w3 _/ ^# u
复制代码 . v9 e! b4 j/ \" D' d! o6 h
/ Z3 g; _4 D6 y7 T
9 g4 b6 l% L4 ^$ o1 k( @
|
|