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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x
0 n% n1 m, e+ k2 c- R
NX二次开发源码分享】关闭NX后,做点儿事
, P0 `7 J- M+ a6 j; w
0 z* e/ v4 j8 W( O& H$ W9 M& y" ^[mw_shl_code=c,true]/*( U5 A, e  K( _9 y0 w% }

) |1 P8 ], B' {# e6 [# Y3 n+ b    ufusr_ask_unload is invoked immediately following the completion of ufusr
" G$ R& J3 `6 O7 X  g5 {, u    (or ufsta when the dll is run from a startup folder) to find out when you
" V9 L' r5 i+ s) o+ P    want the dll to be unloaded.  If ufusr_ask_unload returns
( B% j/ G. R! F+ o$ }( n    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is0 J7 d$ b; n; R3 L
    unload when NX is terminating.  To prove to yourself that this works, set
6 l6 W% w) y' s) J( y$ X  s    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not7 w8 }6 I1 v" O
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX/ S# t9 F/ L+ @9 z4 k; X
    Log File and make a note of the full path to the syslog which will be shown; s. r3 l. e! ]3 [! M% S
    as its own first line.  Run the dll built from this code (nothing noticable% g* E# C2 F( g+ t4 q" Q/ I/ f
    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
. M. O/ f6 r2 ^- K3 F. T    see this line near the bottom:4 e% i, x$ [2 n- R4 B
) `+ d7 B* n! d% o! f' \& ~
NX is shutting down - running ufusr_cleanup# C, z1 T4 t# b7 _% r

# e  d4 G& o* T*/
0 u( S0 V8 @. A3 u#include <stdio.h>9 }% i6 y+ W7 M6 z( j8 i" j3 E! J
#include <string.h>
1 H: C# }+ Q2 L: r4 m% a+ K#include <uf.h>
5 V; Y0 y5 [7 d( A* K#include <uf_ui.h>
7 R! P) {- u# ^#include <uf_exit.h>) s5 `: t3 ]5 D; P5 j( G

2 X6 c7 u. S- S/ c) a0 a9 N#include <stdarg.h>5 H9 C) C( A# h, T+ D4 E+ t

# x- `" X8 i5 w! f. v. R1 sstatic void ECHO(char *format, ...)  y& r- J" S+ b8 b- V
{7 M( U! w7 y9 C4 C/ ~: C- _* Y
    char msg[UF_UI_MAX_STRING_LEN+1];, T! Y/ s7 r' ~$ a- t9 h
    va_list args;
9 q# a* J: L/ c( [+ K    va_start(args, format);
: `( a4 i$ R  j$ ?    vsprintf(msg, format, args);1 K0 k& w: y4 a5 K# S, y2 _
    va_end(args);6 [+ F$ I% r. d6 W
    UF_UI_open_listing_window();: b" x1 e" O, ^' `5 K. l" {
    UF_UI_write_listing_window(msg);
0 f8 R- D! Z7 l0 r: }3 s) S- K% Y+ l7 [    UF_print_syslog(msg, FALSE);- q1 t) C# m! H4 T5 X& F8 ]
}; X) u, G1 h8 O

0 t: A; m8 O- [#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X))). @( l# U: A: p4 M5 I$ T1 j
: l( N* s& ?8 j) B2 k
static int report_error( char *file, int line, char *call, int irc)
. [+ s4 C( H) I1 e{
* H% F) C2 }5 \# ?" Z) R    if (irc)4 n4 S6 t9 w" \" n7 T1 x
    {/ x" u4 w2 J4 v2 w" T" g$ t  h: }
        char err[133];
5 t& K/ e  R' a1 b( ~& D- y, T4 x6 R/ N, C( t4 \: d8 u
        UF_get_fail_message(irc, err);: S' S& l" j3 m( U) y7 c5 v
        ECHO("*** ERROR code %d at line %d in %s:\n",
( i! m7 l) p: G. {! u            irc, line, file);, \( \$ ]% |$ A( W
        ECHO("+++ %s\n", err);7 X3 i8 m5 x2 o
        ECHO("%s;\n", call);- X& e7 A" L, g2 K( W. k
    }
! f+ w& x# [0 S, B# i% O! g3 N( s0 Z3 j" _4 x
    return(irc);
* Y/ i0 t9 F! W1 R/ s9 @}
6 H% s8 T' }' L. C$ r1 o" L
' |3 j* ~& }& D) ^% ?4 P/*ARGSUSED*/
7 Q) y/ r9 E2 F5 P9 h( v4 f1 w) Hvoid ufusr(char *param, int *reTCode, int paramLen)0 ^3 N$ _7 \/ h. Q, t; w1 c" A) A
{
; P  ^2 ?4 i0 W0 M}8 T8 v1 O. K  w4 R8 D7 Z9 d$ U
$ H. \  I. t" c+ M$ W8 `* V
/*ARGSUSED*/
$ D4 v/ L  H! l- avoid ufsta(char *param, int *retcode, int paramLen)8 Z$ ?+ a. q' p2 u5 R' ]
{( b# _6 W9 L6 h! o
}; G3 D1 E8 o# s. C+ _
; k- n6 X9 {& H- F5 c* x
int ufusr_ask_unload(void)
, |! _8 |0 p' I# {+ a0 Y{; `, t# I9 U6 L- X3 V& D! g  j
    return (UF_UNLOAD_UG_TERMINATE);& m. S' E+ W  S$ {3 C$ w
}
6 S- b: R" B8 B+ w% q9 j: @8 h( Z' C
void ufusr_cleanup(void)3 b8 S9 z9 V- @, d' y
{
. p6 W. \5 {  _' {( a    ECHO("NX is shutting down - running ufusr_cleanup\n");/ _' r1 W/ Q, B

! m; }( L6 P% }9 t1 f$ d" A% H; D    /* put your code here */" z- U8 A& I- f% ]# Z' D
}[/mw_shl_code]. k& S& W  v3 @! o
上海点团信息科技有限公司,承接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
" Y- D: [$ h) F请问这个函数是怎么用的?有什么用?

; w, v# K  r/ f- t/ ~9 p* |4 H入口函数 改成 ufusr_cleanup
* J( d3 X+ ~1 N) d' I8 l1 D) f: v- @, a9 z
意思是 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二次开发专题模块培训报名开始啦

    我知道了