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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x

% \& m0 p+ Z) TNX二次开发源码分享】关闭NX后,做点儿事
- p3 ?" T7 G& s- F% w5 i
- h1 u- H, X+ H1 O4 Q& ^& C[mw_shl_code=c,true]/*6 L6 L/ `2 V7 @6 Q- Y

4 B% O; P% a' C7 O    ufusr_ask_unload is invoked immediately following the completion of ufusr6 F( k% ?& X2 U' `1 s1 S* h
    (or ufsta when the dll is run from a startup folder) to find out when you' p' ?9 k* r8 v  Z5 v9 D# y2 S
    want the dll to be unloaded.  If ufusr_ask_unload returns% B6 M, ^9 D# s
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
& T8 B: z* w, O    unload when NX is terminating.  To prove to yourself that this works, set
% L9 m! o6 ~! H1 h' V* P    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not
( Q7 Y7 a' A2 X: S0 k    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX
" f4 P% R4 i% B    Log File and make a note of the full path to the syslog which will be shown  f1 ]" W4 u2 M7 ^- d3 ]- Z& k8 b
    as its own first line.  Run the dll built from this code (nothing noticable0 I3 b) }* n8 S' K/ O* K; @
    will happen.)  Exit NX.  Find the syslog and open it in any text editor to5 T. `6 I# J' h# Y9 Y0 ^) \/ X' ~9 s
    see this line near the bottom:7 m- h9 k! X: i* ~! u7 _

% `" }" h  J5 y- a1 w* t4 j2 r% F) N. lNX is shutting down - running ufusr_cleanup; j& }& t; M, O/ g7 Z

6 B0 _& P8 ~5 x+ h3 A*/
& o  K6 n9 ~! t6 U5 |! L2 r' T#include <stdio.h>
4 Y; {$ \" S2 b+ F#include <string.h>( r" r1 q; {. h. P6 t
#include <uf.h>5 `: x+ M. s* j
#include <uf_ui.h>
' H: Z$ D$ q8 f$ d7 O#include <uf_exit.h>
+ q  p/ a1 u( N
9 u' l8 R& `7 s7 _( F6 Q7 q#include <stdarg.h>6 u$ E% m8 J7 _: S/ k
2 w) J9 K, Q3 z+ x- l& e5 V
static void ECHO(char *format, ...)! J+ v: y% K! q9 l. x
{8 E# \# W& ~! o
    char msg[UF_UI_MAX_STRING_LEN+1];1 T' V# W  e1 A* o; l% b! O
    va_list args;/ o6 L/ m  Q/ _- e; G  \" R; Q" j
    va_start(args, format);
( z$ k+ B" w0 ], q+ Q. j    vsprintf(msg, format, args);& \% h8 S5 G. [6 ~8 \7 K/ E
    va_end(args);
. Q5 S+ \7 F& R8 U$ _    UF_UI_open_listing_window();  k7 Z* h+ I" I( ?7 a
    UF_UI_write_listing_window(msg);
7 L3 p8 d" O( @    UF_print_syslog(msg, FALSE);! u  M: q7 ]: M0 y  S9 k
}
$ b0 J! K' S4 s6 r4 b* f" b0 \7 g! k! n! q. }' X7 X( P0 l
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
9 V  M8 z9 J, m0 L
0 ^$ D1 B1 P1 b3 Cstatic int report_error( char *file, int line, char *call, int irc)* |3 D: a) z! R6 X, J" v+ l
{, C% e  J; d* f0 ?
    if (irc)
8 p. x) L+ z  ^8 F2 e3 _$ g    {' e% p; w" y2 w) v+ O/ L  x
        char err[133];* P. p5 ?% |, V$ l7 x; S5 ]3 i
0 a! a# m( i) X* T5 P
        UF_get_fail_message(irc, err);9 H9 u" o: ?0 g% H, T" h
        ECHO("*** ERROR code %d at line %d in %s:\n",
. @6 F1 P4 ?# s0 X; p" n* X            irc, line, file);
& E8 z, Z; H$ M5 L9 e* X1 p        ECHO("+++ %s\n", err);, c5 b7 H  N! s  Y' y
        ECHO("%s;\n", call);
6 y! j8 H1 e6 s$ ]2 _    }& x) C/ I; M$ ^% c: R
4 d5 X+ r" L# V% j! q
    return(irc);
- e/ I" P; L7 m8 J& H% ]& R}
  b5 O# o7 Q* B# l- e- q# u! ~1 v( o( @7 W5 i  c3 _
/*ARGSUSED*/
* ~8 J/ L! j% \void ufusr(char *param, int *reTCode, int paramLen): B5 q0 F2 ]5 C) E5 {
{
: K, F  P2 ?# y' C0 Q) {}' i5 C( m" Q  a( c0 H) M! X
3 J2 ?) @* Q% @3 y! e9 k0 V
/*ARGSUSED*/8 u2 m' F5 N6 ^3 V, K' g6 p* l- y
void ufsta(char *param, int *retcode, int paramLen)
, ^) M  `- T" P" i. H{
) \% A% k+ o8 n& I- _. X) ]  m& u: Q}
5 a) j* }# \& ^" _" U6 P
, V) D0 O# R2 @int ufusr_ask_unload(void), _' `1 V- t  V* @; h# t  ^
{
  [$ U( ^4 x! i( l( h5 r    return (UF_UNLOAD_UG_TERMINATE);' Z+ p% n9 s) k
}
$ O* o( \  g. E( h9 S. z! r$ {9 n3 A: g+ X9 p* A8 X1 D9 y
void ufusr_cleanup(void)! a% A. p, r9 p( y% _
{9 A0 _7 U: [, Y4 Z8 d$ _
    ECHO("NX is shutting down - running ufusr_cleanup\n");
- o$ C6 T3 U2 O0 n
! U# Z& x' D6 b: b  o) A    /* put your code here */
% W9 K& F+ N: j* W: U3 K" P}[/mw_shl_code]
- h3 B- L6 }% a- Z# u
上海点团信息科技有限公司,承接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
6 J! C! X. b. E5 S, i$ D1 x) E请问这个函数是怎么用的?有什么用?
8 \  |4 z! C1 W: D5 s5 q) h
入口函数 改成 ufusr_cleanup   A1 h8 B5 ?' u( {$ ^, R
+ @; b/ I% p6 b4 v" c* Y3 S
意思是 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二次开发专题模块培训报名开始啦

    我知道了