|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
% O6 o1 ?4 K/ l- c( H) V- q8 ^7 R% S
NX二次开发中,删除一个对象的代码分享+ g7 A' F! p' e
( l& C: G8 j. {7 k6 v! _
: E; `9 w$ n; v% O2 p* a仅供参考!!, ~9 D. b0 d% X
! ]$ h' _8 R4 j- ^3 ]2 q' M% C- int deleteObject(NXOpen::NXObject* selectedObject)
% S d6 D6 Z; Q2 { - {
! m; j* L* O1 i5 K* W - int error = 0;
8 G+ j7 b6 F5 ^! V) W$ o3 U) @& G; U2 x - try, Z# O& H" N7 R" e3 s) C/ }6 k, J
- {5 U1 W3 ]/ b: r. \
- std::vector<NXObject* > obj(1);
0 L( m% {' J, I - obj[0] = selectedObject; c+ f. Y: U3 E. ]
- int nErrs = theSession->UpdateManager()->AddToDeleteList(obj);$ f. D; @7 u* E' O' I
- 6 F- J( m9 r% f
- //Report any errors - normally the error list should be scanned and each error processed
U7 ^% R8 G$ S! `; _$ f% k6 V8 D% v - if(nErrs > 0)
2 W& M7 n" s% S6 I7 q/ x2 R4 c - {
\& n: Y4 I6 ^ - error = 1;9 f6 [2 t& t0 u5 G
- std::stringstream tmpString;* X0 o( D8 R) ~( J( S; ^
- tmpString << "nErrs =" << nErrs;# Y) k. r4 ~" r8 W% _0 b, }
- SelectionExample::theUI->NXMessageBox()->Show("Add To Delete Errors", NXOpen::NXMessageBox::DialogTypeError, tmpString.str() );: Y9 z7 H2 c* W# f
- }# D5 L; e# j. x4 Q& \
- }
2 R3 A0 j" R7 ]- d5 c - caTCh(exception& ex)) H* X* x2 L$ `, z* v
- {
" c. ?; X* ]8 v- @, Y - throw;
( }' R7 }1 u' F0 ~/ A: S! ` - }+ V# S: G' m) F( V5 j
- ' y+ i+ i# F4 h: E( X
- return error;' y+ |$ _! }3 _0 H) a
- }
- c0 ]5 s/ } S' q% [, w6 s2 R
复制代码
& S- ?6 B! q) n* L. ^
7 `: x, ^8 X `& H. ^2 I: D- J% b3 l9 s
|
|