|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
4 T- R9 R! E8 l$ k2 u ~( a& w* |NX二次开发源码分享:报告当前工作部件的所有属性) `4 J& k/ f, Q$ u0 \6 S- @
主要是用过workPart->GetUserAttributes()获取属性信息;
. n* }* f9 v# R" f- void MyClass::do_it()/ ]$ L% B1 i) ^4 z- [: \6 t
- {
# J/ u( o+ I: P8 [ - stringstream out;
( W" F0 a, q$ Z3 R* J+ b - std::vector<NXOpen::NXObject::AttributeInformation> infos = workPart->GetUserAttributes();% M: f! w& r7 f: m- D
- out.str(""); out.clear(); p3 I5 K8 m* {6 \9 e7 I3 L7 v
- out << "\nAttributes found: " << infos.size() << endl;2 u6 d2 v) r' Y* ~
- print(out.str().c_str());
& [) g: Z- [. B
! J9 s9 l D7 Q! J7 M2 R- for (unsigned int ii=0; ii<infos.size(); ii++)
/ [1 ^; v g. q- @1 E% X8 K: \+ [; Z - {1 H( B1 p, Y7 t% |, M1 ~
- out.str(""); out.clear();
" q3 Y" `! J7 r% i - out << "\nAttribute: " << infos[ii].Title.GetText() << endl;8 [$ P+ K) S# S, V3 u# x: ~$ s
- 1 y; D+ g/ E; R
- out << " Array: " << infos[ii].Array << endl;
7 S" U4 Z1 t8 v$ R! s- B - if( infos[ii].Category.GetText() )
0 Z4 f$ Z" f: M/ L$ K2 q. s5 W% B! q - out << " Category: " << infos[ii].Category.GetText() << endl;6 Q; m @; }' C* d* S7 E
- else; ^2 H7 ]; G; U+ N. J3 d& i9 o" p
- out << " Category: NULL" << endl;. U* h* T* k0 R: b b! w/ l' T
- out << " Inherited: " << infos[ii].Inherited << endl;
: b) W$ Q5 g, J5 i - out << " Locked: " << infos[ii].Locked << endl;+ u) J5 j( w3 T& i7 P* i% P9 v
- out << " OwnedBySystem: " << infos[ii].OwnedBySystem << endl;
% n6 ]$ L, w1 w$ F ~! \ - out << " PdmBased: " << infos[ii].PdmBased << endl;
9 I( N; ^6 k7 V! O o0 X! v5 `6 O5 q - out << " Required: " << infos[ii].Required << endl;
$ `# S! \8 A5 ?8 p0 I% T. O - out << " Type: " << infos[ii].Type << endl;: k4 M) d9 z: G( m! r- n9 E
- out << " Unset: " << infos[ii].Unset << endl;% K/ _1 s/ y2 M9 L$ y7 I$ G
2 h u) S; m3 V8 y. I- swiTCh ( infos[ii].Type )" d: [& R5 T4 B( X& \" S
- {
5 {9 u( C7 o/ y - case NXObject::AttributeTypeInvalid:7 |& k6 u& s4 q. r8 v+ e" M
- out << " Type is invalid." << endl;- k, O3 e5 q! _: c/ ^
- break;
! x5 f, c( a) ]2 H - case NXObject::AttributeTypeBoolean:% S# `& x$ D, {
- out << " BooleanValue: " << infos[ii].BooleanValue << endl;$ k6 ^) v/ Z7 W
- break;# \# B7 _( P- ?* ^
- case NXObject::AttributeTypeInteger:
9 K) J* A$ \- R) ]# \ - out << " IntegerValue: " << infos[ii].IntegerValue << endl;
; b0 S' B, D1 ?9 J' u" q - break;3 f% j0 x6 [& k4 w. W4 B
- case NXObject::AttributeTypeReal:
2 {0 Y& k+ V' c5 o; o3 v - out << "RealValue: " << infos[ii].RealValue << endl;5 k6 P6 v: b2 f, p
- break;
$ _4 z3 f" f3 R* S3 C7 { - case NXObject::AttributeTypeString:
+ B3 D# Y" X, K w: f - out << " StringValue: " << infos[ii].StringValue.GetText() << endl;" T$ G8 O& }: _% k
- break;- `% ~ L8 u: R% p( V
- case NXObject::AttributeTypeTime:) a2 } I" h& k! e' z" {, Q
- out << " TimeValue: " << infos[ii].TimeValue.GetText() << endl;
( T2 d Y% T# L' H. g, B% v; M - break;
& v, }" Y [' ~# C7 O - }
/ `3 w9 @; ?6 N% m8 t F( u8 s
) m! |+ T$ I' E- print(out.str().c_str());
; \7 q. M+ K! O1 p! L8 O: Q6 ^3 a+ x - }
4 t/ K$ D+ M! O( T$ y - 0 j. r' P6 |# u( k
- }- g/ g" _! N9 [, B# v
复制代码 $ b5 J/ _' a$ _ E
* O3 R! ?& K. D" \3 L- {7 e
5 P4 F' G/ J" Q6 l |
|