|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
8 m) t/ [7 m" J' y# f/ D; l
4 h5 G& x0 [7 y: i3 q( f
NX二次开发中,删除一个对象的代码分享
4 A9 b, b5 c! l2 e3 L
6 O2 n3 u E( y8 ?+ ?5 d, n
% J; j c j' Y b仅供参考!!" A; a+ y8 u8 O& W# y1 Y3 S% V2 u0 N
- Q& Y5 w/ [+ T
- int deleteObject(NXOpen::NXObject* selectedObject)
' H, o' W' y" C* s C - {. V* _. X* @9 S2 K5 ~# R
- int error = 0;
: a/ o$ ]) x# Z2 d0 e0 S - try1 T- r" E; f+ A- {
- {
$ o& \4 M% u% F+ B; j E - std::vector<NXObject* > obj(1);' W7 Y! |7 ?+ x# H2 c7 f: q
- obj[0] = selectedObject;8 z1 `! M- d: k4 _' ]6 y
- int nErrs = theSession->UpdateManager()->AddToDeleteList(obj);, E# ~, y0 a6 y2 G3 Q
8 x( C |5 Y$ C3 v5 T- //Report any errors - normally the error list should be scanned and each error processed( T+ h3 m1 W4 l8 g+ I1 Y1 \0 G3 K
- if(nErrs > 0)* H# a# L. ?% J* D
- {
9 t. M" f* H$ Z4 g8 h; M - error = 1;
5 W" j5 J: U% R: j" {) J h* ^! d1 Q - std::stringstream tmpString;6 R$ E W! B. Q7 W; v* t
- tmpString << "nErrs =" << nErrs;
+ J; Y) T4 ~0 Q' T3 d1 \- F6 _0 l: j - SelectionExample::theUI->NXMessageBox()->Show("Add To Delete Errors", NXOpen::NXMessageBox::DialogTypeError, tmpString.str() );
, J& p$ O4 s/ Q( h' Z3 e* |+ R - }' L) I& J9 n! c1 K: ^
- }
7 \, Q8 j5 A6 h7 } m) @ - caTCh(exception& ex)
' M) r3 T* {8 ]: L( p( I, O - {
7 A i8 @" R% U& [( e - throw;
! m0 u. s9 |* I. b* [2 y: ^1 h - }, ]; s* \9 O# n
3 }- x0 j$ i5 Y" J$ f- return error;1 i8 G2 s+ ~# v$ }
- }7 K+ n1 @/ v9 g! o! c' |7 c
复制代码
/ P/ H9 |' ~8 h1 _5 P& \% Q6 O/ u7 C) j" x0 x' Y0 f1 n
) P1 E7 {! m! E& k* C# `3 q
|
|