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

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

  [复制链接]

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

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

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

x

" T- V2 B$ Z& d- R% J0 h9 UNX二次开发源码分享】关闭NX后,做点儿事6 ?' Y  x( @; |

, d/ I/ t) p8 Y0 H2 x0 Q2 t[mw_shl_code=c,true]/*
  V- }; L  p+ k! W9 Y: m4 b$ [6 B: g, W; H  S$ Q. }
    ufusr_ask_unload is invoked immediately following the completion of ufusr: O# Z- Y; G$ Y9 H" I' }6 g+ S
    (or ufsta when the dll is run from a startup folder) to find out when you
7 G9 Z5 [0 u1 ~* {    want the dll to be unloaded.  If ufusr_ask_unload returns# o2 N& I: b# O! G0 F  K
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
8 ~3 |" _# v# T    unload when NX is terminating.  To prove to yourself that this works, set
& f* s4 H* P* [' B9 `    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not
& j3 o2 m* g  ~$ Q6 C; C5 }    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX
' M9 @$ |0 r7 b. T4 z) h    Log File and make a note of the full path to the syslog which will be shown1 Q. n) C0 X, F3 S
    as its own first line.  Run the dll built from this code (nothing noticable  m+ `7 N+ H- U6 E# m, c
    will happen.)  Exit NX.  Find the syslog and open it in any text editor to- i! V" T  k8 V3 ]  [0 B3 D
    see this line near the bottom:) e7 d3 t1 \) D" `" ?9 e

& x% D$ L$ d; E4 S6 }6 _. u2 q+ oNX is shutting down - running ufusr_cleanup% `2 q& B; j1 P9 @: r

% v# O. }- X! l$ M*/- U/ q5 ~% H* g6 V3 h! V
#include <stdio.h>5 {( g9 D* F6 J$ I2 S  Y
#include <string.h>6 C6 j# v. H( W6 z
#include <uf.h>9 w* J6 _- p# L! ~- k# q
#include <uf_ui.h>5 Y# _5 T  C$ M4 V  P) c2 @
#include <uf_exit.h>
# R' z5 Z9 v; W: B! ~7 g: V- @$ c9 k2 Y4 X) K" R9 k% A
#include <stdarg.h>
; O6 L3 L$ D9 {
" g6 C  P; k* m! d& Ystatic void ECHO(char *format, ...)  O5 b+ j: Z. E8 s# o% j
{
* ~* Q" d8 p' g% [    char msg[UF_UI_MAX_STRING_LEN+1];$ q$ S+ |$ }! i! O
    va_list args;
! F& T7 J0 N9 d6 R5 ^; d    va_start(args, format);
& P" y& I! e. F    vsprintf(msg, format, args);
! O6 q+ o/ u0 c; t1 A    va_end(args);
* B2 `) b) h8 \3 O8 j: q    UF_UI_open_listing_window();. r" V( F  w# z2 H" _8 E* Z
    UF_UI_write_listing_window(msg);
% J4 d) Y8 M- f: V1 q" v    UF_print_syslog(msg, FALSE);+ ~% }+ u5 d6 m/ N3 L' h) J
}+ ?7 N; s5 |# h0 |- A9 O4 I+ n& V

( ?' t7 U' R- x! a#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
, A+ k2 N  p% R% \
- \+ O3 `+ l: Y1 [, gstatic int report_error( char *file, int line, char *call, int irc)
4 K0 h" O) Z/ g{
* q0 v  N$ G' r5 U    if (irc)3 r" V# D" Q% l) b( U( Q2 ]
    {
; h( q% Z! g% k" o* d& ]% T. ?        char err[133];
: y2 A; `4 T- p# ?& A# _* l6 O1 Q9 P1 t, m8 x: Y& p
        UF_get_fail_message(irc, err);  D% s, R% K" K. p
        ECHO("*** ERROR code %d at line %d in %s:\n",7 l+ r1 k! f1 W$ ~
            irc, line, file);" b( x$ k* L: f7 F4 U
        ECHO("+++ %s\n", err);
6 N2 [4 c# L. w" _$ p2 v1 j* w' D        ECHO("%s;\n", call);
2 E: e" ^' F4 }' H6 H  H% ^    }, E0 F  t1 q) ?. v
4 j" H5 B" J/ g0 m9 F+ u. ]. |
    return(irc);
% n) Y3 G" U  M}% ?% E, [% W& B

8 F, U1 Z" x! L, `7 c" h/ Z/*ARGSUSED*/
* r- |, T) [6 T4 l$ f9 G' Zvoid ufusr(char *param, int *reTCode, int paramLen)
! m# c4 \7 P! |# H{
% ]8 b, r4 H3 p, y1 C}' A3 B/ s: a" [6 Z0 J: b/ \% J/ q
4 O; R7 L! q8 b- _
/*ARGSUSED*/
! R6 w% [- M; P" Vvoid ufsta(char *param, int *retcode, int paramLen)1 K: w# X" D- I0 R9 v8 a' i/ K
{
" L3 z# [7 j( m$ f- F' K4 R}
, I1 ]% D& O) |( Z( }( \/ a9 j/ m/ Z: i( R7 j5 N6 S
int ufusr_ask_unload(void): {; M) p7 z8 q3 h, a$ X+ e2 E
{
- `% t4 g+ Z# z    return (UF_UNLOAD_UG_TERMINATE);! j  d* j9 J! K0 `, V) f
}
2 D, U9 r9 X: D1 x. Y0 T
0 B: w0 B' t( p& ovoid ufusr_cleanup(void)
- c/ q. _. B3 H( W0 R% M{
; ]$ ^8 _) a& G# ^4 f    ECHO("NX is shutting down - running ufusr_cleanup\n");
& y5 S( J/ M. t. o7 [  i! A* b9 S: z& }' E8 d
    /* put your code here */% P" ^/ e) m: E/ p/ s9 M
}[/mw_shl_code]3 u: f0 @+ M1 Y( y9 R1 A
上海点团信息科技有限公司,承接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$ `) A6 H0 Z5 S0 P- m
请问这个函数是怎么用的?有什么用?
* h. J2 T. n) p& q/ q. t7 a
入口函数 改成 ufusr_cleanup
  u) u8 |. U  Y3 K. E$ @9 V2 N/ S2 e9 I  ~2 P( p- p/ N
意思是 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二次开发专题模块培训报名开始啦

    我知道了