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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x

  [- e" C* N( I/ [6 ?( i: q9 m9 _: GNX二次开发源码分享】关闭NX后,做点儿事
7 m: f! |9 D+ p1 h: q
" K$ l. G# ]9 d# k0 Q- C# M[mw_shl_code=c,true]/*; t% b1 C7 m- ~, r/ \

4 J; p1 X: W' K# d    ufusr_ask_unload is invoked immediately following the completion of ufusr
/ n5 x& Y: T3 l- M$ K9 Q1 }; o  c. ~    (or ufsta when the dll is run from a startup folder) to find out when you9 Q8 a) b, I/ |- I8 x; l0 ~
    want the dll to be unloaded.  If ufusr_ask_unload returns
8 R3 Q4 Q  w1 \7 H3 p. @    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is- T5 L1 A! x2 |6 ^5 P) S
    unload when NX is terminating.  To prove to yourself that this works, set
- D, m. N0 v' R) z8 T; ?    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not
" t: ~* k" \' Z$ W1 R# F    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX  F. j  _) z( t
    Log File and make a note of the full path to the syslog which will be shown
# x" h& ]1 v' b$ p) b    as its own first line.  Run the dll built from this code (nothing noticable& F4 X% f" r9 X$ T4 M+ W+ ?& R( X
    will happen.)  Exit NX.  Find the syslog and open it in any text editor to7 w0 a$ J% q6 a  l5 f9 N
    see this line near the bottom:
" l2 X. L; t$ o1 Q/ X* b  V+ q/ w4 h
, \/ H& y, _- K" }NX is shutting down - running ufusr_cleanup2 n: E# ?# x0 n* E: m

4 T/ r* m% l" a& |" j' e% S6 ]6 u*/$ n6 y/ y$ s* w1 C7 \
#include <stdio.h>
7 K9 q4 K- m8 ^& p#include <string.h>
0 _: i$ v) I* Y1 [3 m/ r5 u( B, O#include <uf.h>/ Y. Y7 J$ L. Q1 g
#include <uf_ui.h>
( j6 y/ J/ `4 |* V8 W#include <uf_exit.h>
$ C' M) N$ q9 H% `& d2 X- G
& [* k+ u4 _9 K- C#include <stdarg.h>5 Y, X  O5 E/ z. Z5 Z* K2 e
; b. o8 q8 C5 I' ?2 g
static void ECHO(char *format, ...)# b. B) S4 k" H8 U- a0 `
{
" c& a, I* J% V% ?9 S    char msg[UF_UI_MAX_STRING_LEN+1];
) Q3 J/ A$ H4 C+ g    va_list args;
2 V% j4 N  E  w& Z, h    va_start(args, format);
5 W; I, Z9 J" {. y& m/ }    vsprintf(msg, format, args);8 F  B. A; S& I! _. E
    va_end(args);+ e( j* ?6 C+ `* J4 [" a
    UF_UI_open_listing_window();  {9 @& S6 |- p
    UF_UI_write_listing_window(msg);
8 U. ]2 o: `, E. A! I* n, l/ l    UF_print_syslog(msg, FALSE);
) x. J% ~3 M, P# m# r: v}/ S/ S) }5 L( B9 v4 }( s9 M

0 d: o3 t  B9 {! D#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))1 G8 {% S1 o9 q+ S8 g/ u1 ~
( U; {( a6 Y7 s5 D* I( e/ a! J
static int report_error( char *file, int line, char *call, int irc)
( W% Z7 B  s7 P% n+ ?. S{0 \+ y+ i- o' D! w, ^* ~0 k
    if (irc)5 K" N4 K* X: _% N! o/ [0 n) |
    {
' |: ~( }) l. T& {7 F( b        char err[133];
) ]0 j' B) u2 n* D+ }* j8 ]) {
1 i, z" `2 ]2 K4 G* h        UF_get_fail_message(irc, err);' ~( ~- T0 N6 J* J# u
        ECHO("*** ERROR code %d at line %d in %s:\n",
( G" M# ~  [# g+ o# H: d- r! O- O            irc, line, file);. q) X$ Q4 Y/ k+ x, r* r
        ECHO("+++ %s\n", err);" U% n6 Z/ D6 n
        ECHO("%s;\n", call);
9 b+ x! z2 R- Z) V+ G* U. @    }  L1 {: L, N' k
% d+ c* j5 x/ ?1 e8 ^( T7 P
    return(irc);
, C( I1 s2 f6 O. M) B/ ^}
& U' [* f* ^9 w
5 F4 c, a: U+ \, ?. W% ^' T/*ARGSUSED*/
1 E' u+ X% u3 G  R" Ivoid ufusr(char *param, int *reTCode, int paramLen)
2 K6 K0 o: Z+ k# n- p- _( ?2 b{
" V* {9 C# u8 z& h, K}* i, \  w* I6 u5 T
1 c& a# ]% b% ]
/*ARGSUSED*/
# h5 e! p. P' h" v3 w  pvoid ufsta(char *param, int *retcode, int paramLen)
  ^$ w6 v$ a$ g+ a$ p! }1 F. h( P( F{9 t, p6 G/ U# l+ V; B  k
}
. A8 a  [, U! g9 E0 b' g  ]( b
int ufusr_ask_unload(void)0 H9 r6 g3 s9 b3 A$ P# L
{: S$ i8 c$ H; g0 g6 M9 u5 d. P
    return (UF_UNLOAD_UG_TERMINATE);8 v% U# |& i1 I! n
}8 e$ G" G& o& y- d
3 p& [# ?. x/ [
void ufusr_cleanup(void)" a; D& P# _: E
{
  Z8 J) ]4 E$ v; I! O( S    ECHO("NX is shutting down - running ufusr_cleanup\n");, o  H& p3 |8 k- u) }( i

6 h% ^9 a) S' k! m+ T    /* put your code here */
/ ]. i9 F. k) u+ j3 Q}[/mw_shl_code]
, r  B# g1 Z# h* t
上海点团信息科技有限公司,承接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
) D8 k& e8 `0 B4 s请问这个函数是怎么用的?有什么用?
! Q! s! x4 ~/ B, u8 B1 z/ H
入口函数 改成 ufusr_cleanup # w, l( |5 e& i

& l6 |& K$ V7 B8 R) S2 a' P意思是 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二次开发专题模块培训报名开始啦

    我知道了