PLM之家PLMHome-工业软件践行者

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

  [复制链接]

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

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

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

x

: M0 O2 Z" Y* v& j. G8 e" KNX二次开发源码分享】关闭NX后,做点儿事
4 C" F* z0 I( P4 y$ |+ s0 y  {$ A4 s( U0 c
[mw_shl_code=c,true]/*
, S+ X  x/ k9 S/ @9 k5 \" g, ~8 t  h
    ufusr_ask_unload is invoked immediately following the completion of ufusr3 B  M0 e# l: h5 n
    (or ufsta when the dll is run from a startup folder) to find out when you* `1 g0 Z8 y$ ~  F- L
    want the dll to be unloaded.  If ufusr_ask_unload returns) o2 Y" M1 F9 H3 ~2 N
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is# k0 V; K7 e4 q! s: z2 O' b3 A! a6 X
    unload when NX is terminating.  To prove to yourself that this works, set8 p  H9 v& ?8 k/ N& S2 i- V4 d
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not. p) W& d) N  W! |% I
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX
# `" I/ \& L8 \" a    Log File and make a note of the full path to the syslog which will be shown" E& K' {, `- S  l
    as its own first line.  Run the dll built from this code (nothing noticable
3 i+ ~* b1 ?# i9 {9 G0 L    will happen.)  Exit NX.  Find the syslog and open it in any text editor to$ `4 i7 c1 g$ a
    see this line near the bottom:! g. K' R- E) T& r6 D' j

" X( g8 Y/ p( \/ h. O& }NX is shutting down - running ufusr_cleanup9 P# d5 w3 b# g8 v0 Y( n+ y

; G6 p. u" E9 V1 V*/' `7 x2 R4 ?, q# s6 i
#include <stdio.h>
9 n& P) T# y! O) r- `: A( T3 [#include <string.h>- w8 W6 ~( U- \
#include <uf.h>2 h0 P) O$ A* N) c
#include <uf_ui.h>
6 O3 ^6 Y2 l. q! \- U1 l#include <uf_exit.h>
8 k) X4 h0 i9 g' r: l
% n; ?  D( R0 _1 ?6 E) l" J: |# X' O#include <stdarg.h>
7 v5 ^$ {8 S# d( l7 c- Z
" b4 N( s% V( ^3 B7 Hstatic void ECHO(char *format, ...)) k4 y9 m. W6 G0 ], b5 h/ Q
{; \. m, r9 \8 L8 x2 j0 x
    char msg[UF_UI_MAX_STRING_LEN+1];/ A$ ^6 o1 x0 m
    va_list args;
/ K2 ]2 D: H' x    va_start(args, format);( S7 L6 R& A9 m# r+ W
    vsprintf(msg, format, args);
. g' c- P2 M! G& @+ \2 X; _    va_end(args);
$ i+ W$ Z; H' N2 U7 ]% h    UF_UI_open_listing_window();& b1 H) W/ l( i& p) Y' \
    UF_UI_write_listing_window(msg);
6 \6 P$ q) Q" o5 r% ^: w    UF_print_syslog(msg, FALSE);
) R6 G/ b, u+ M! i# _: U% Y7 y' _1 L}9 d  c/ j8 y7 J
# h7 }4 ^* }* u
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))+ M' t9 c/ d4 }8 @

/ S  C' [+ [& \( x; Jstatic int report_error( char *file, int line, char *call, int irc)
) G$ p5 t) {0 H2 R{* v2 O" g+ J$ g# B& \8 t
    if (irc)
5 Q% l: R* ^$ x5 h    {/ M+ w4 V) ?7 _  L6 e$ [3 n  W7 R
        char err[133];
# X( b/ b' Z. r0 A! b9 b/ U( y& @% E. e$ M4 A) J" {
        UF_get_fail_message(irc, err);. {9 e7 ?- Q% ]2 g! Q! ?
        ECHO("*** ERROR code %d at line %d in %s:\n",, `& B- `, [& d8 u
            irc, line, file);
4 _, s; O. X3 [  z5 q& m( s        ECHO("+++ %s\n", err);, D- \! V4 ^$ Y. G. H
        ECHO("%s;\n", call);
7 t  s' z$ C& Z- C, t    }
: g2 J" Q: ]# c/ i* Y0 x( K: ~1 V7 w  K8 g% B# w
    return(irc);8 o) C; C6 t( [% I7 D
}
' P) L. N$ E9 w" u* x% k; K8 k3 N$ j9 m% j$ U* W9 M0 {
/*ARGSUSED*/
6 a% \% {5 |/ M! x+ i6 s: \& yvoid ufusr(char *param, int *reTCode, int paramLen)
1 W- D5 g6 V- ~- e& C$ m{( [0 R; I) s  J' \4 }9 F
}* k! R+ W2 Y, A. \0 N5 U& ^( G
7 [6 U" i8 j& _3 M8 C% n- F' I
/*ARGSUSED*/
* ]" v# t" p1 P+ ]# l. Tvoid ufsta(char *param, int *retcode, int paramLen)7 \* ]* r! k. _
{* n) Y- M: @% J8 t. U3 y5 l7 q
}
4 }8 c. @9 T/ `' p) e5 X# ~$ B* M& b7 t; a; ^' E
int ufusr_ask_unload(void)5 d* Z9 X0 w/ e" F
{3 F2 t$ p' N0 N
    return (UF_UNLOAD_UG_TERMINATE);" `4 E: F' |) \: W
}
7 ~+ L. H3 v2 O0 b! N6 ~: N" R* G' N2 a7 q' A* g
void ufusr_cleanup(void)
1 u/ C, c8 u' K* T8 S0 E+ Z{  v2 B' w" S$ C* ^# Z( q
    ECHO("NX is shutting down - running ufusr_cleanup\n");6 y5 b. D( m. F: }4 o) z* A/ F

, k6 B8 h/ E2 F/ p5 H    /* put your code here */. y" O8 I9 R" Y. d- H
}[/mw_shl_code]
; j9 M2 S8 P; f9 R6 s  h' n
上海点团信息科技有限公司,承接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
: N- ^& `# K* S" F  W  u请问这个函数是怎么用的?有什么用?
& `# b/ u7 }0 o
入口函数 改成 ufusr_cleanup
4 R) g( W& o7 F9 I8 U
, r" W1 h$ B6 N2 B意思是 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二次开发专题模块培训报名开始啦

    我知道了