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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x
7 e6 e+ G' W0 L9 w
NX二次开发源码分享】关闭NX后,做点儿事
; c" l# q3 J7 m; v% o( o; A: M& Y0 h# V  \, S7 C
[mw_shl_code=c,true]/*" P7 L. b& @9 y/ k/ g
. m# b, s0 o) m, M2 u+ U% R' ]
    ufusr_ask_unload is invoked immediately following the completion of ufusr
) k5 f' ]/ u0 C  s" v6 T1 E+ o" W    (or ufsta when the dll is run from a startup folder) to find out when you
, H( T( s8 V0 f" x    want the dll to be unloaded.  If ufusr_ask_unload returns7 ~2 I6 J8 ?: |: \9 X
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
# A' H: `6 `. W) T5 A    unload when NX is terminating.  To prove to yourself that this works, set
8 }  Z% w6 S# t. s' ?    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not
4 f6 B, P" L6 D; U# E: T    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX) X* Z: Q+ w- a# \
    Log File and make a note of the full path to the syslog which will be shown& e7 ?2 ]# d# P. ]
    as its own first line.  Run the dll built from this code (nothing noticable& n, `' V: K7 L/ R+ A3 E# Y
    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
" i8 U3 X& Z! A- V4 ]5 C    see this line near the bottom:& [+ Y5 P. \+ _$ R$ v

1 E) S& W' K/ O! v# o- N# D; n3 ENX is shutting down - running ufusr_cleanup6 V3 K" @0 G$ A; r: {/ G: D
. Z6 v8 j6 |# O
*/
4 `; X3 T3 X) @  a6 S, p#include <stdio.h>+ @" D6 z* G/ Z
#include <string.h>
) w1 n) N8 v9 u! h#include <uf.h>4 m+ v$ r: _$ _2 Z
#include <uf_ui.h>
& F  a, T: ^' j$ ~$ h% A3 V; B#include <uf_exit.h>& d  P- M0 B. J
8 ^5 _' F9 d0 V
#include <stdarg.h>
) l. c8 v& i; y
) ]# G+ A5 i: P3 I- |$ L$ Lstatic void ECHO(char *format, ...)- S) w  l, b: D8 s7 t
{+ ?2 [8 _& D% o* I: [1 f6 [4 \2 D% P
    char msg[UF_UI_MAX_STRING_LEN+1];
: B7 A& K% [4 e0 M7 W/ }5 ~    va_list args;
( V1 [% t) n# d+ ]9 S8 l8 v    va_start(args, format);: I" w' I$ x; M+ b& q7 J" ^
    vsprintf(msg, format, args);* G/ I- A2 e4 T. Q0 _* j7 G
    va_end(args);" J6 a; Z- s% Q6 @/ d; D
    UF_UI_open_listing_window();$ ?$ r" W* N; \, K8 J3 z4 I# x
    UF_UI_write_listing_window(msg);
: q) x) P1 O0 v7 o    UF_print_syslog(msg, FALSE);
) ~: i# L. [' W}
! \; `3 A, _2 ]+ f  ?) ^4 y4 n* W' U0 H- a
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
8 u( l/ r: E! P  z
9 D2 z  y+ G% b3 k* jstatic int report_error( char *file, int line, char *call, int irc)
2 b) T# w- U8 ^1 A% Y9 _0 ?0 N{: P6 c( V/ O: H2 p+ f! ~: u
    if (irc)' D+ T- s0 v& c! V, P4 j& ?8 a
    {% [- {% `, }; N8 L" |+ z3 V
        char err[133];
; k; P9 H( p/ ]) L5 t9 _, ?/ ~6 U  {8 w* n+ o
        UF_get_fail_message(irc, err);( c1 i$ i6 {; O- v( p- @% ^
        ECHO("*** ERROR code %d at line %d in %s:\n",, ?6 t3 a0 s+ J8 z! L
            irc, line, file);
) Z# S) e9 r8 ~8 Q        ECHO("+++ %s\n", err);
$ R8 P8 }( ^5 k4 |) J( q        ECHO("%s;\n", call);% n8 N' s1 n' @" @# e* r
    }
6 Q8 V8 Z# d4 {0 k; D0 B5 _% x9 G4 K6 C1 s. f$ _) H! }6 k2 _
    return(irc);4 q( R, M5 k! s+ J( v0 `
}
% z0 {! D5 K; O  F+ G( n6 }* t. L8 W: C8 w' s; H' r7 c( T0 B
/*ARGSUSED*/
* T1 |% i* a( Q( e+ h9 O  u6 X, {void ufusr(char *param, int *reTCode, int paramLen)
! L4 ^4 [+ G  W' [9 p$ b{3 G2 u2 X3 m3 O* [' j
}+ H: ?' u9 O% X9 I3 I
4 M1 Z3 ^* @! f4 E1 Y/ S8 y% B' N
/*ARGSUSED*/
, D4 B/ |" i) n. P$ \void ufsta(char *param, int *retcode, int paramLen)7 m% U) k1 S5 @# y9 ~+ N
{7 I- D, F$ c$ _, {4 }3 ?. i
}  r5 [$ A: X- ?7 y9 y

  V+ ?" H; ]& @# U* kint ufusr_ask_unload(void)
! g3 q- |( v! H- K{
1 v. Z! _6 e6 a. P    return (UF_UNLOAD_UG_TERMINATE);
. D( @! Q  |7 L9 d* Y& ^}
$ _0 P1 g& W: |$ I5 u$ v/ }4 z' W3 E( {7 H2 ^% W( _  H
void ufusr_cleanup(void)
$ `2 Y8 u' G& u' f6 S3 q{( a' u' H) ^5 A" Y8 J, x- G* C% j
    ECHO("NX is shutting down - running ufusr_cleanup\n");
7 G) y7 b4 v( T; Y( S' s  ~2 `- F7 L4 Z
    /* put your code here */1 `4 R' ?7 N& K% m! [
}[/mw_shl_code]+ M( A1 n2 u7 m* M1 I: S
上海点团信息科技有限公司,承接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& y0 I( g; j$ T1 A- W
请问这个函数是怎么用的?有什么用?

- h' z: I+ p( b0 t$ w; `. d  E: D; a入口函数 改成 ufusr_cleanup 8 g$ b5 e8 v- X- D

! U8 m9 D! q2 |0 U8 I& K! |意思是 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二次开发专题模块培训报名开始啦

    我知道了