PLM之家PLMHome-工业软件与AI结合践行者

[二次开发源码] 【NX二次开发源码分享】关闭NX后,做点儿事

  [复制链接]

2023-1-10 20:46:56 4001 3

admin 发表于 2018-7-12 11:12:47 |阅读模式

admin 楼主

2018-7-12 11:12:47

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

x
* O& \2 P8 F; z/ j6 o/ l
NX二次开发源码分享】关闭NX后,做点儿事
4 ], ?1 Q+ y3 l- r! s4 A3 C
  c9 f" _0 m/ ]: Q% n. L[mw_shl_code=c,true]/*: B0 w) M2 N2 M6 E6 }
1 z; R0 d% z, V: G. e& k/ y- J# n
    ufusr_ask_unload is invoked immediately following the completion of ufusr4 N% Z6 }  ?% h0 _% u+ f
    (or ufsta when the dll is run from a startup folder) to find out when you( F. [  E$ c; h$ \2 a# J
    want the dll to be unloaded.  If ufusr_ask_unload returns1 ^, e7 L5 J) F( N" Z2 m  H
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
' a5 L6 _# ?/ P& s& o1 A    unload when NX is terminating.  To prove to yourself that this works, set
7 Z5 y" ~6 G( z4 c$ X1 w* \) M  h0 T    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not5 x, Z  ?, A$ }/ H/ `
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX
" O: B4 T- }( a. x5 ^5 _    Log File and make a note of the full path to the syslog which will be shown
% f6 N% y7 W! z    as its own first line.  Run the dll built from this code (nothing noticable# }5 k# y4 e/ O
    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
5 {5 q5 B, L4 m' f- x    see this line near the bottom:
$ Y+ ~' x/ v4 q. |5 [  n6 a3 r# W) b$ t. S& m9 u
NX is shutting down - running ufusr_cleanup. K: p: o0 J( h( G) V% ~8 k
  i6 @/ {+ A( y) J% ?8 i1 D- D
*/
7 Z8 R/ U3 }! d: @2 s1 S0 g3 G#include <stdio.h>. E  U7 P1 c0 }% V3 `( \
#include <string.h>+ K) D9 v/ ?7 p/ n/ b/ _
#include <uf.h>4 X# H! W- v: L
#include <uf_ui.h>
: ?1 [9 a# {9 ?2 r#include <uf_exit.h>& J2 e$ ]. o9 M* Y6 A2 ]# Z& f. j

" V' s; X( Z; |, h, \& G#include <stdarg.h>' `0 M, [" [; W
1 t8 b5 D2 }% @$ d- F8 E0 H
static void ECHO(char *format, ...). {2 g5 o4 E: d4 e- v6 b& v) |% Z
{
( ]4 k" j9 @9 I/ P- m# W6 K% x    char msg[UF_UI_MAX_STRING_LEN+1];
& Z- t8 A/ o* c+ G5 J% a9 d4 m    va_list args;7 H: L( {9 Z) d# R
    va_start(args, format);9 g2 f) e3 n9 `, D1 Q
    vsprintf(msg, format, args);1 j8 }2 A2 F7 B: h, i
    va_end(args);' P* N, x7 h- R
    UF_UI_open_listing_window();
( E. A  p3 H; i; B    UF_UI_write_listing_window(msg);
: T+ d3 f* ^9 L- P    UF_print_syslog(msg, FALSE);* O$ ?2 Q, I5 k: M$ u/ f
}/ F$ [& P& X# h) m1 B
7 i6 `4 F& P1 x2 p) S# j# V5 J
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
# G: F" y' \/ o  T: {. I9 v1 _4 a
; T2 Z  w) x4 A& D! \6 I' i9 gstatic int report_error( char *file, int line, char *call, int irc)
0 O! C1 a) v& t" j9 L{. w! c4 y2 b6 i! s' v4 `
    if (irc)
, `! q* `- s# W5 V; D8 I    {
2 c8 J5 [) [4 b4 X+ J0 |( J        char err[133];% O! D' b0 n) @6 p7 N6 E, L2 }

9 X) z4 P$ s% n" O9 l- }) d        UF_get_fail_message(irc, err);% o0 z/ x/ f) F* T+ |
        ECHO("*** ERROR code %d at line %d in %s:\n",
/ V0 O$ o: k4 {5 V$ x9 j            irc, line, file);2 g6 w( s: ]6 v3 M6 g! J
        ECHO("+++ %s\n", err);3 G8 O% k1 n2 E6 W5 P# d7 R' U; x9 _4 J
        ECHO("%s;\n", call);
3 ^  t' ]3 }" E# A4 B$ m/ y4 R    }. U$ l5 i+ u2 h4 [) x, F# R! N5 Z) _* y

2 N* W9 R/ u8 `% B4 `2 S6 _7 J- I    return(irc);
3 r& @3 j6 P( N' n: \}# g- R% P9 e3 P) V% Y. `

8 a/ ~  X& R- M' a6 `0 D/*ARGSUSED*/6 I3 ]4 X" k( O- o# R! G
void ufusr(char *param, int *reTCode, int paramLen); A. \4 A5 M* G- \9 _; L
{# o" Y* U9 J$ I) I9 O" `8 l5 w
}
- ^0 `1 w( \- g" M) D& b& K& I+ b( \7 t, W5 `
/*ARGSUSED*/
/ Z) H+ Q. u0 }4 T- d+ `void ufsta(char *param, int *retcode, int paramLen)
8 G. p( e7 S% K; `. t. G{8 |- a- e& O. g+ v1 Y9 w  B
}
, @' `+ v0 i( d3 l2 m, ^% s( z; H2 u3 f" _6 U
int ufusr_ask_unload(void)
' e+ m. `5 C) z9 n5 K{: M& |6 i9 U- t& C
    return (UF_UNLOAD_UG_TERMINATE);/ Z% ~  `2 U5 ~2 U3 l& T4 k0 }3 P
}
: V" }& Y% D" I3 o8 x9 ~$ Q8 B
! D" ]. J' @+ {  Xvoid ufusr_cleanup(void)2 l% Q% A& v8 ]) p
{
, h* j9 x' Z7 z, n    ECHO("NX is shutting down - running ufusr_cleanup\n");
6 {) u! m: V) J; f; N: {8 J8 |5 G4 s
    /* put your code here */" k2 o2 \8 G4 ^, S; ^
}[/mw_shl_code]3 i) g% P7 e4 B5 V) g0 f; y
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

全部回复5

licxsw 发表于 2019-12-25 08:49:24

licxsw 沙发

2019-12-25 08:49:24

请问这个函数是怎么用的?有什么用?
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复 支持 反对

使用道具 举报

admin 发表于 2020-2-13 08:43:55

admin 板凳

2020-2-13 08:43:55

licxsw 发表于 2019-12-25 08:497 ]' J& d9 a0 g0 e5 N
请问这个函数是怎么用的?有什么用?

  f& a/ A4 C) b' s; t" L+ ^8 f入口函数 改成 ufusr_cleanup 7 c6 p2 s! k1 e, B

- K8 q. n( _5 L# m6 F  ~- v意思是 NX 程序退出后,你可以做些事情 ,具体做啥可以自己写,就是个入口
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复 支持 反对

使用道具 举报

licxsw 发表于 2023-1-10 20:46:56

licxsw 地板

2023-1-10 20:46:56

测试了 ufusr_cleanup入口处复制文件到指定目录下,不成功
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复 支持 反对

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了