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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x
1 H3 ]# ^$ n% W, e: r! E, t' R
NX二次开发源码分享】关闭NX后,做点儿事" r' r. C" G5 u/ ~! V0 d1 O
7 E% R) q# f2 q) T
[mw_shl_code=c,true]/*
& ^. ?" i6 f: d. r, N1 y
# C( I5 M( E, h! F$ s. T: \) U    ufusr_ask_unload is invoked immediately following the completion of ufusr  u& L, b8 U/ Q) x6 e% V
    (or ufsta when the dll is run from a startup folder) to find out when you
8 e/ B# \& r7 W* I+ i    want the dll to be unloaded.  If ufusr_ask_unload returns
1 o5 L8 D, i4 F, z) l% K    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
. ]1 @$ Z! t3 p4 H/ D    unload when NX is terminating.  To prove to yourself that this works, set
* e: a- J7 b* F7 G    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not% |% E% l( u3 M/ u
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX
' h) m  K, T9 ]5 V    Log File and make a note of the full path to the syslog which will be shown1 A) ^/ C5 Q* n9 Q
    as its own first line.  Run the dll built from this code (nothing noticable$ n4 n5 ~9 ]/ p7 T( c
    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
  v; n- @6 s+ d8 y* |    see this line near the bottom:) a0 M$ z+ ?' ]# r% l$ m" w, L' q
/ o; R. p1 c- J- Y* Q4 @. X
NX is shutting down - running ufusr_cleanup2 G- l2 E* G. H

6 g# Q* f5 w* I0 t7 J  ~; ]. V*/
5 J( h7 m: G, m8 c2 U. V! i#include <stdio.h>
  |; m& ^( |% F& @. @#include <string.h>
( \/ q! m! ^3 l#include <uf.h>
0 m% S4 S8 o" x" ~& N8 c: z#include <uf_ui.h>
, K. w# c, c( o8 }5 P#include <uf_exit.h># T- V9 p% C) a5 ]% Q6 Q

3 [1 c4 c" e4 s#include <stdarg.h>
; M& A" Y% e5 k8 ^( m( t" N8 g% D" D; R8 Z" ^4 T
static void ECHO(char *format, ...)
8 j+ y6 ^! G1 t0 ?" R% n' c{4 }" x0 y$ O+ l8 `5 ?8 b. K
    char msg[UF_UI_MAX_STRING_LEN+1];9 X& q3 m( _7 }
    va_list args;( p9 K7 x8 v4 `! t/ o8 e% g8 W2 v
    va_start(args, format);
4 P2 c2 A' V9 p' [    vsprintf(msg, format, args);* r$ k) b3 ?8 |' H, m" D
    va_end(args);2 U6 h9 Z2 w3 ?. H0 H& D
    UF_UI_open_listing_window();1 E, U! o9 E4 b1 V6 s: i
    UF_UI_write_listing_window(msg);& P# w% F# a/ j$ f3 V' o" r1 L
    UF_print_syslog(msg, FALSE);
  ~% U8 y7 \/ ~, W4 [; X$ i1 _}" s5 h8 v. S8 q# B; p5 v

2 q' y0 q4 j( L7 |- G" z8 t4 N#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
' G, V* J9 z# ~* ?  V
* I  W' E" I* E# x) m  S2 `/ zstatic int report_error( char *file, int line, char *call, int irc)
8 e8 C/ N8 y. R- @{
$ a' A7 i' o7 e" c$ ~4 [  N    if (irc)
+ x; E5 Y0 H! ], |  h    {
- x8 y9 E' ^2 T* @        char err[133];3 x& K$ Z) [- @! o
" Q- D7 B3 k4 l1 j# K$ f' V
        UF_get_fail_message(irc, err);
/ G. b, Y6 r( q# ~+ B        ECHO("*** ERROR code %d at line %d in %s:\n",  U3 O& @3 C( T
            irc, line, file);/ x0 o" J) g, r: i# X
        ECHO("+++ %s\n", err);
; b- x$ \" n. n4 G- {! |6 Q        ECHO("%s;\n", call);6 M, j* |5 i2 }2 g* K9 c6 t1 ]
    }. Z  E9 b* @% h& T
8 H0 |) S" k7 t- Z
    return(irc);
# q1 ^7 a1 }0 _/ D; ?}: u5 m( H3 M) B8 N% C: ~
* n" w4 X9 X- i/ p; e- j& ^- Z, ]
/*ARGSUSED*/
6 y- Q. A9 E  C, \0 svoid ufusr(char *param, int *reTCode, int paramLen)4 I/ V+ A8 Z: b6 x5 f, B* L9 O. c
{
; v  [3 I8 [5 B! ^2 C* x4 u5 x}
% ~9 l9 |8 M3 k7 V5 l0 }6 d: o2 f  }: y+ r
/*ARGSUSED*/
) z/ S4 [4 M6 ]/ G1 Cvoid ufsta(char *param, int *retcode, int paramLen)# a+ T$ `4 m) `. L/ y
{
& e! A& m% X. A8 e! x7 m; t}. j9 P6 X; G6 @- K

( }  X0 P9 C. p1 Vint ufusr_ask_unload(void)( t  ~: P& }3 l: H
{
6 q& j" S7 Y" V+ f9 c- @    return (UF_UNLOAD_UG_TERMINATE);" n( R' u) h2 V, d
}
" Q8 H0 f, x' _+ {+ g  N% P4 {: W' I+ V, t
void ufusr_cleanup(void)6 |6 i, w/ F9 q# R' Y2 f. {( {; O, t
{" p# R8 e3 a! q
    ECHO("NX is shutting down - running ufusr_cleanup\n");, f( \. X$ O' B3 M" R8 P

1 i- i: P( M  G1 ~+ k9 H    /* put your code here */
& K# f2 E- ^" C+ r/ x) A}[/mw_shl_code]
8 \3 F- v' E$ Q
上海点团信息科技有限公司,承接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
. L* Z1 A7 O* u, I5 O* y请问这个函数是怎么用的?有什么用?
5 \' i+ O9 O. w3 [8 G+ K
入口函数 改成 ufusr_cleanup
6 O1 I( N  ]& H. G( H& r4 U
% w) ]% {" ^1 E% t; R- ^意思是 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二次开发专题模块培训报名开始啦

    我知道了