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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x

' D* v( p/ ~% k9 J0 }NX二次开发源码分享】关闭NX后,做点儿事. B+ i' O: M( E( G  P9 O6 ~

& f  ?- y6 M- o' T  A[mw_shl_code=c,true]/*% s- J  ~+ ~: b% P! T
0 q9 M' V' k! K- X5 R6 I
    ufusr_ask_unload is invoked immediately following the completion of ufusr4 m4 x$ r  F! L" }2 s' @8 f+ q5 T, J
    (or ufsta when the dll is run from a startup folder) to find out when you8 F, T, x2 B. _- o# p
    want the dll to be unloaded.  If ufusr_ask_unload returns# ]7 R! P/ L3 {! `
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is+ _$ [5 w9 J+ ~  S* X% T$ K
    unload when NX is terminating.  To prove to yourself that this works, set
9 u' z- @2 v9 E! B! ]) L    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not
5 l  B0 K. }- J& w! U    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX5 g1 x4 W/ [" F7 V* q5 u4 j5 Q
    Log File and make a note of the full path to the syslog which will be shown  X: S: g7 J5 n" B7 z
    as its own first line.  Run the dll built from this code (nothing noticable
9 g1 m) _7 ^1 @    will happen.)  Exit NX.  Find the syslog and open it in any text editor to0 F9 ]9 |# E. W; A
    see this line near the bottom:4 ~- X, H/ ^6 @7 [$ [0 x" m
( l  i& J8 D/ d
NX is shutting down - running ufusr_cleanup
: G" T0 a" U: M; N( J8 g. g5 h. m$ }) ^6 W/ Q
*/4 e, |5 z$ {! `/ S
#include <stdio.h>( I! N6 G5 h" K. d
#include <string.h>, P) C; g* m! y) h) a9 [  W# E( s
#include <uf.h>
) R, q  l+ |: G/ J#include <uf_ui.h>' a' O7 F& A0 x2 g+ u6 h+ m
#include <uf_exit.h>
) z# N& l0 }- u" D) g/ G( S
# {3 z2 Q! J/ G7 b( p5 D3 m* G#include <stdarg.h>
4 i' a& ?9 \  D( f
# m- R0 {" e2 L4 m% z6 fstatic void ECHO(char *format, ...)
: m' F' r# U/ V{2 c- g1 t# w# w7 U9 T
    char msg[UF_UI_MAX_STRING_LEN+1];1 o: w6 v6 o! u  E9 E- l3 [
    va_list args;- w  N. q5 L) P. M
    va_start(args, format);: K3 z' n3 m; |" S  i# q( e
    vsprintf(msg, format, args);
1 c1 u1 ~" U; q( b3 U% l    va_end(args);6 h# |  }* b+ {& P. e7 q
    UF_UI_open_listing_window();
. M* o3 Z$ W2 C- K    UF_UI_write_listing_window(msg);8 H2 x" Z$ G( K0 G" _/ W' }
    UF_print_syslog(msg, FALSE);( O# A0 ?$ E4 i* b
}  r/ e3 M# e8 C

% m. @/ h( Z8 S$ \5 |#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
* a) L  @, M8 u8 Q* O& E
) m! o& ]( Q" ]$ B' lstatic int report_error( char *file, int line, char *call, int irc)0 j) H  h. ]$ w+ p
{  h6 p0 D) K4 W
    if (irc)
! o& {: v  e* e: s  ~# K. @    {. V0 u" O- M- P5 R8 P, O) r
        char err[133];  B! q7 @  [2 x" ^5 Y
0 B; ]- Z# Q( O6 `5 l% R
        UF_get_fail_message(irc, err);/ n0 b/ [+ r" p. E  p0 W8 U
        ECHO("*** ERROR code %d at line %d in %s:\n",: y+ e. X# u; |
            irc, line, file);
4 u" e* z* k3 L0 O4 [        ECHO("+++ %s\n", err);0 G6 X# k: y% x6 X; s
        ECHO("%s;\n", call);
: S* U- _- ?1 I' C4 v8 D6 {1 m    }# k5 ~: v9 k7 A- T& F0 x. j: a

! L6 z: }6 O9 Y1 y, _/ d    return(irc);/ v. h+ \0 D6 P
}0 Z0 V; K0 K9 m, ]
0 ^% g$ `7 [2 h& [1 A1 C
/*ARGSUSED*/
6 D8 [! \  G/ b; G# S& gvoid ufusr(char *param, int *reTCode, int paramLen)
$ T2 p: V1 E+ v{
7 I) A+ y! h! U9 O4 ?  F}1 O8 Z  f0 x. ~# m; k8 x- M  l2 l
: A* P4 a' A5 n" T. {/ @2 p( f
/*ARGSUSED*/7 S1 g1 B; G- {; N' \  [
void ufsta(char *param, int *retcode, int paramLen)
8 C3 w7 r$ k1 R; ?{
/ ?/ c2 w" g, c8 ~- W}
9 C) X: T. G3 `! C" H' W
+ ]7 o, N( k. E% B3 Nint ufusr_ask_unload(void)
. u1 D1 h/ q) R) J+ H( U{3 J/ @+ W+ {: z" {) c2 g$ k- n
    return (UF_UNLOAD_UG_TERMINATE);& x9 y& a3 _- _0 ]# h
}
( N# s; K9 F8 |! H0 }9 q
5 _1 v' k, w- rvoid ufusr_cleanup(void)( @1 h9 S6 ^( V( ~; @7 S0 I
{
7 R7 g) w* y% M( u" N    ECHO("NX is shutting down - running ufusr_cleanup\n");' ~. k% y' X7 }' x; F
9 H9 a, i# B+ T: H5 O
    /* put your code here */
: h+ p% y: t3 B( t  ]( a}[/mw_shl_code]
3 g) `1 g/ r$ n: |$ A' L8 B
上海点团信息科技有限公司,承接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:49; M% K$ q' l, ?6 d7 }
请问这个函数是怎么用的?有什么用?

4 n1 N# ~1 b$ z$ P. O入口函数 改成 ufusr_cleanup   Z1 R, C! ^, Y8 @1 J9 s' l
) p1 u# y* T' l& v* m$ q
意思是 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二次开发专题模块培训报名开始啦

    我知道了