|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
# I5 F: |+ ^. U' {% z' V
/ {3 y7 Q( m2 k* P! }0 }+ |6 tNX二次开发中,删除一个对象的代码分享 i2 j# U2 E, ` v6 w
$ H& }0 y* S- }8 ^, X4 y8 k% V0 p& S3 p( v3 l
仅供参考!!
- S+ L2 r( c9 I5 t& n7 R8 n
; H% e5 }& l6 P R3 P- D- int deleteObject(NXOpen::NXObject* selectedObject)
0 {$ f" K; |, `* F6 y - {
3 @. f6 a- n% a8 x( |3 _0 X; ~5 f) p - int error = 0;3 c* ^( G& U1 j( L% U6 k
- try
' Y) l) f7 z0 h& o4 Z - {
% c; W+ C1 I2 l! M+ Y - std::vector<NXObject* > obj(1);
( T4 E5 o$ X S. j. b# X - obj[0] = selectedObject;6 F; ~( s6 f3 ^ m; K, K9 l
- int nErrs = theSession->UpdateManager()->AddToDeleteList(obj);, G. \, w7 }" {: z8 g: `
- # z8 _* |1 J$ P: D
- //Report any errors - normally the error list should be scanned and each error processed
, u' h" [! b6 M9 N5 l4 C$ `+ g3 m - if(nErrs > 0) Z9 g$ v0 y& o* S2 a( I
- {( y2 ~ e5 d1 |+ `
- error = 1;
. b& X. s# }( j1 A; \/ I/ o - std::stringstream tmpString;6 ~' o! \( v5 d" w9 g
- tmpString << "nErrs =" << nErrs;! K. [2 ~. V; n. @5 ?
- SelectionExample::theUI->NXMessageBox()->Show("Add To Delete Errors", NXOpen::NXMessageBox::DialogTypeError, tmpString.str() );
4 O, Y2 d% p: F5 Q - }1 B" ^* i C; r d. ~9 X/ [' P( K
- }. l& {% B) ?% F( O5 M2 J5 J
- caTCh(exception& ex)' q, D) d* V- c5 B( U
- {! t0 [+ |" O. [) _) d1 g; U( r
- throw;
- Z+ B) D! G- {0 F9 u# h - }
x8 E" N) ]6 b2 w( l; Z - ' a8 t( z. k: |& B& L3 I0 `6 y
- return error;" b4 y+ x2 r* _( G; P( Z! ~
- }+ v7 F0 ]. z" h) B9 A
复制代码
5 p. e9 D2 v3 A, W
5 ~) g# V/ t1 Z$ Q) s- i" Q0 }! p& K5 z# i( @/ W
|
|