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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x

7 q0 [+ E5 ]" ?2 W/ pNX二次开发源码分享】关闭NX后,做点儿事9 m' S2 Z# |0 g  D
6 i/ d/ J' j5 W6 Q# x9 U
[mw_shl_code=c,true]/*" I+ z0 p% e  A* J* ~- r- y
3 M& ~6 ]8 B. j0 |( L5 O. ~
    ufusr_ask_unload is invoked immediately following the completion of ufusr: z% C7 d% I3 ^7 M/ u
    (or ufsta when the dll is run from a startup folder) to find out when you2 U+ ]6 ?8 {, z* {$ L# d
    want the dll to be unloaded.  If ufusr_ask_unload returns
6 s3 a$ o6 A$ ~. D2 L    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is: z) W6 ~- l7 Y  x, I3 K! [
    unload when NX is terminating.  To prove to yourself that this works, set! K! Z8 Z+ w4 E7 K0 V
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not: B' y2 U1 Z. Y& T
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX
/ E% ?1 S; d$ Q    Log File and make a note of the full path to the syslog which will be shown) P# @& G" f7 g; i+ z+ `0 w* P
    as its own first line.  Run the dll built from this code (nothing noticable
- ]  G' w3 N  b$ ?    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
* `! s' L! [! a) c: {* M3 D6 `+ Q    see this line near the bottom:9 y7 x* z8 n7 |% L: Y- g/ i1 J
* @* n* P# @3 x
NX is shutting down - running ufusr_cleanup
1 [1 Q: B# _6 ]9 v9 b, N7 i. r9 B
; j3 L/ S# \) E/ d; w% ]*/0 S6 S8 `3 R& e+ q5 b! Q: ]6 [
#include <stdio.h>
6 p" J# A' l- J6 }, G#include <string.h>
" R' y6 G7 x, ^7 S, ?) o- s#include <uf.h>; [+ e7 E. s- }+ K& x/ o
#include <uf_ui.h>! Y( l3 c/ c* F' D# C- |
#include <uf_exit.h>
0 C& v7 l/ e- W, b0 Y# I
2 p; z  J$ X0 k& t! L#include <stdarg.h>( E$ a5 |# A6 S0 Q' g/ v0 ?; B
* V+ ~4 N9 V5 M" x( U
static void ECHO(char *format, ...)
  p2 S) |: w1 Y; M: j{* d+ J; P( _0 d% h
    char msg[UF_UI_MAX_STRING_LEN+1];
3 s5 h% p7 ]; F    va_list args;
' V6 ~( F5 Y9 F+ v+ R    va_start(args, format);
' S! [4 G- a# N9 o0 d; L9 j2 \    vsprintf(msg, format, args);, o2 a+ c1 k  v
    va_end(args);7 X; `9 X: ?( F3 M: @3 \+ }6 z6 {
    UF_UI_open_listing_window();
; J5 V. g# E0 Y* o    UF_UI_write_listing_window(msg);
" ~" M3 g+ c2 B+ o, h0 N1 p    UF_print_syslog(msg, FALSE);
9 Q( x6 i7 ?, N" b5 E& \' g}
) `, r& \4 G7 {0 R
4 ?8 s/ ^2 R: Q. Z0 S2 P#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
, A, p/ n# e) @9 w6 T$ `, d' n3 X" ~% T8 r7 I
static int report_error( char *file, int line, char *call, int irc)5 S% R9 b3 z4 l6 F- x8 }* z  O% ~
{
) ~- t: ?8 N; Z! ^    if (irc)2 u8 z1 h6 G$ B( L7 N+ w6 y
    {
* }! u/ l' ~; x4 }- Y7 G6 l        char err[133];7 i+ @( b/ `# D/ d: C6 x' H% l
; [. h/ X3 {. `- _; q
        UF_get_fail_message(irc, err);3 x- P5 E: {1 E, @  g7 H* W, @; R7 U
        ECHO("*** ERROR code %d at line %d in %s:\n",
9 Y. p' t5 ?/ \) I' j$ O: k            irc, line, file);: f5 ?0 Y1 f+ O9 `9 z& v
        ECHO("+++ %s\n", err);2 ~5 L- Y7 S9 n( d* @' O6 p1 n
        ECHO("%s;\n", call);
8 K# \, h% N; ~3 |    }
/ e6 z5 G. c2 h. {8 e5 d3 Z% G) J! A1 l" |/ p' u3 _
    return(irc);
3 O2 v2 D9 F% Z" _3 z+ m4 ?}3 e' B# T8 [6 J! V5 R8 `

- o; @! _; }+ r$ A( v+ m5 h* d, R* u/*ARGSUSED*/
4 e1 n) }- b* j& v6 c5 M: {9 c$ I2 bvoid ufusr(char *param, int *reTCode, int paramLen), p! i6 O6 F! W" O5 W: ~/ Q, h
{7 X. Y3 n1 Q6 F! W, f$ Y
}
0 q9 y' P5 }% }! S. X# d* H0 R2 s" G6 P! u2 W
/*ARGSUSED*/* q+ h$ ^1 X; m) D, X
void ufsta(char *param, int *retcode, int paramLen)
( @7 M+ |  B/ w$ T{
5 D) V% y, z8 P& C' v& f% r1 p* k2 M}% L& b0 X1 K- q! O
: T( T- L( I- |2 N
int ufusr_ask_unload(void)3 y; M* p6 H( f% @. R& i/ o6 z" T
{0 a: E& z5 P  K) T
    return (UF_UNLOAD_UG_TERMINATE);/ _6 B* [) d0 U2 Z- s' s- Y
}! x+ p0 q+ p% s. I/ P* R

: r) n/ o6 R7 Ivoid ufusr_cleanup(void)- L9 w) ?  s- ~  v7 z
{' t: `8 X8 X! }: T$ b+ f' X& h
    ECHO("NX is shutting down - running ufusr_cleanup\n");( c  o+ `. D& D  F5 H
  {; A! x8 A  f- S( y; {
    /* put your code here */
  A: G* W& T! h" e}[/mw_shl_code]
. V( W. a& l' Z  u0 l/ r4 ]0 i
上海点团信息科技有限公司,承接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
: C- I; n4 e) s. l' t1 q请问这个函数是怎么用的?有什么用?
& M. T% ~3 E( Z2 T: i
入口函数 改成 ufusr_cleanup
  d( e, p0 N3 M
5 `2 O9 O% c0 t# f意思是 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二次开发专题模块培训报名开始啦

    我知道了