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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x

/ l6 W! L) G" p) g. w) f1 |5 W+ LNX二次开发源码分享】关闭NX后,做点儿事* W7 w0 j5 u7 q( `

% l0 C% K0 g3 [* ?$ \7 V' ^* R7 D5 r, ~0 {[mw_shl_code=c,true]/*
: E- i( x( H  I: @6 ?, q% f1 o# d- i0 e3 n. h. W5 h
    ufusr_ask_unload is invoked immediately following the completion of ufusr/ z. D, G+ T$ E/ G
    (or ufsta when the dll is run from a startup folder) to find out when you" ^! i" r9 \/ \! S
    want the dll to be unloaded.  If ufusr_ask_unload returns
" e5 z- z1 w7 ]) ^  L- n    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
- i7 m* e: h  l- ]2 s- K    unload when NX is terminating.  To prove to yourself that this works, set
0 F7 R& X) Q' \: c# ]! F' H9 j( j    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not) A5 r: x  z& X! @4 `1 R
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX
/ f9 T/ j: e  Y  L1 r# D    Log File and make a note of the full path to the syslog which will be shown
5 e1 k- U6 S5 R9 c5 b    as its own first line.  Run the dll built from this code (nothing noticable
' }1 S- Y1 p% [& J' S    will happen.)  Exit NX.  Find the syslog and open it in any text editor to$ ]; r# U; [  A1 X0 v% D3 W1 ?. O: u+ i
    see this line near the bottom:9 N  F- n. y, j! j. Y
& A  r' m+ G% V( V
NX is shutting down - running ufusr_cleanup: s6 }* b1 V: B- e

3 B% V4 e9 C0 K1 c' t9 {0 G  s*/
! S" ~, U1 S, N' y) ~9 |#include <stdio.h>6 w( ^+ D0 Y$ I, H
#include <string.h>
7 M. t1 v; Z' W7 r: k#include <uf.h>
& ~8 N5 r+ t- Q" x1 L/ ?#include <uf_ui.h>8 d/ \; `2 l4 h& g' s/ u. L: _
#include <uf_exit.h>0 K2 J. o& D7 ]; W
, Y" L- j" I/ V/ d. j/ U
#include <stdarg.h>) l) a) Q2 f8 O* q/ i' R  {

! Z# {# A( S: F# Q0 p; D. Z( ^static void ECHO(char *format, ...)
. p, X7 X+ ]7 i( p6 Z9 C{
6 x- ^6 j6 e  }- i8 E    char msg[UF_UI_MAX_STRING_LEN+1];" f% O8 d$ H9 U
    va_list args;2 n% G7 `( A7 e0 w9 |6 b8 B  c
    va_start(args, format);
) ~5 X3 \; E6 S- f5 w    vsprintf(msg, format, args);
  G: ~% F/ c5 K$ q$ H4 v    va_end(args);
# s0 Y  b" _! v% v7 _    UF_UI_open_listing_window();
" B* \1 L; ^& W4 c; ?    UF_UI_write_listing_window(msg);
- b, q5 z0 l6 A& m    UF_print_syslog(msg, FALSE);! y2 n6 q3 X6 z% u2 W1 Z) S) ?
}2 m, o' |/ v: K9 y# Q: q

  y$ M' {: e/ L, I% ?/ O#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))6 o5 t0 g6 v. m' g4 S* C' c/ o

! t! M/ V. p7 n# Astatic int report_error( char *file, int line, char *call, int irc)( V. X! t) C5 G* q4 F3 M
{8 ?' |* t; i5 x1 e  S
    if (irc)/ Z5 T# W* j8 ~. S* a
    {+ O$ Y: }- `  K
        char err[133];
  Z2 F" p3 V3 m- u7 F0 W! ?* ~' Y( y$ ^% q  t7 u( p
        UF_get_fail_message(irc, err);
* H1 N1 _. Z. ]9 p- y* r+ Q+ n        ECHO("*** ERROR code %d at line %d in %s:\n",! |7 ?  J* P3 m. v- R3 x
            irc, line, file);
/ g% O' S* S! H/ O# y) i        ECHO("+++ %s\n", err);
! A9 o( C3 b8 p5 T        ECHO("%s;\n", call);$ M* ?: L' [8 k
    }
$ i: n6 h/ b& C3 u, W; |0 [4 I# r% }
    return(irc);
: F$ i! m2 G0 ?0 L8 t8 H}% `$ Y$ q9 c. g, D' J! T
2 e1 F& q$ Q& ~4 @$ R
/*ARGSUSED*/
  r+ g8 x, j8 ]2 j9 w( ^, Rvoid ufusr(char *param, int *reTCode, int paramLen)7 p' p9 d: g, i% k; _
{) Y1 W, o! e: k5 X8 o! @
}
8 U7 A6 ~5 H  k) t. Z6 L  }5 [/ m( q) _
/*ARGSUSED*/
, O2 |3 f! H  [void ufsta(char *param, int *retcode, int paramLen)
- p1 c9 c9 Y. x$ \{& k4 W& J  _+ j" k' j
}
& ]. D4 N9 w0 L
" F  ^" c$ F( G' r& E  m- R" gint ufusr_ask_unload(void)2 k. _1 U' {9 ]$ O" Z
{4 i# }* q5 r5 X6 A
    return (UF_UNLOAD_UG_TERMINATE);3 h% Q6 L& k5 |
}2 {5 i# y  Z* h" V( c1 N4 f

, k) F3 N3 t* @: x& t& u6 ivoid ufusr_cleanup(void)
) E" E  q0 ]! h( G( O+ N. _  e{
8 y+ G- H3 v2 v* M    ECHO("NX is shutting down - running ufusr_cleanup\n");/ U- E' S7 H6 q6 g/ W: E; o

9 g, R6 x) r! |& ?1 O0 h    /* put your code here */9 f7 K2 I+ m; E; A0 i; c
}[/mw_shl_code]1 U5 Z' v/ y* O* ?" @& p
上海点团信息科技有限公司,承接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) t1 S% @7 B: f+ {3 I0 |
请问这个函数是怎么用的?有什么用?

  F$ ?( G7 z+ t; d4 k* G入口函数 改成 ufusr_cleanup
* l! m: I/ q4 Z
% Y1 c: @/ R! X3 k+ ?# Z% G意思是 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二次开发专题模块培训报名开始啦

    我知道了