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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x

: g5 g1 D4 t' |6 K) a5 |4 ENX二次开发源码分享】关闭NX后,做点儿事  ?' _4 l( O5 P+ o" ~( c
2 ?& I' e. \# k
[mw_shl_code=c,true]/*
- K) p3 Z: s( L
: d: J* F; L8 S  ]1 Q6 I    ufusr_ask_unload is invoked immediately following the completion of ufusr" Z; }' Y& Y* z  @( R. L) L
    (or ufsta when the dll is run from a startup folder) to find out when you, u" ~" z# f5 e" e$ E
    want the dll to be unloaded.  If ufusr_ask_unload returns( _* v" t. G8 s( Y! e  C
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is  {2 M) I& x7 E: ]8 E7 L: E
    unload when NX is terminating.  To prove to yourself that this works, set0 o4 ?) w1 [1 H8 Y
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not
) i$ F! `; M9 y, Z6 @1 E* R% A+ W; r    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX: c1 I# y+ Q/ w
    Log File and make a note of the full path to the syslog which will be shown8 p7 J) F! l0 g' ~
    as its own first line.  Run the dll built from this code (nothing noticable
+ B' |" C5 M4 U    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
* e) h0 |7 Q+ h( ~* Z    see this line near the bottom:- X9 g7 a% y4 m, Z1 A/ J$ ]
* c) Y) v- N/ `. @6 s- n: m
NX is shutting down - running ufusr_cleanup/ x# d7 Y4 G+ g, e+ o
% O1 C5 i, c% ]. u
*/4 N& c5 B" q; ~% y; Y5 i
#include <stdio.h>) l* w6 u0 P* F* X
#include <string.h>8 J) ?, I3 D& n# T% U, |
#include <uf.h>
% `! B1 H8 G) I- e, L, D#include <uf_ui.h>! T! H4 |, D* m9 t$ f
#include <uf_exit.h>' R  S3 i3 E' M. ~

5 i+ R/ w& f  j# {8 |#include <stdarg.h>* w  o  a5 O  |: H( W/ b- h! @/ g

# j. ?7 u2 R9 m# C' d5 astatic void ECHO(char *format, ...), U# o4 d7 d  F+ @7 e! r3 `
{) c0 c4 u- e9 Z5 n; h4 S( n2 S. N
    char msg[UF_UI_MAX_STRING_LEN+1];
7 l, I, U3 ]8 n  o1 ?0 u8 S7 \8 M    va_list args;
  b" I, q1 C0 ^) X    va_start(args, format);
& x( V* ]0 t+ x+ m" \    vsprintf(msg, format, args);1 @. r* E0 F! n$ l8 O% j( @3 o0 K/ w
    va_end(args);$ ?% m  x3 e8 q4 e7 X
    UF_UI_open_listing_window();
3 _# e7 T, H6 r: ?, `4 T. c+ \* P% A2 s    UF_UI_write_listing_window(msg);
: c8 N+ c4 E+ ]7 ?; n4 {    UF_print_syslog(msg, FALSE);
, [/ f- [1 C, K5 P0 B6 Q}2 x5 q! Q: H, r
0 Z; e1 X$ x: k' K; o5 M' U
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))3 e8 i  b9 Y5 }/ b

% I3 a0 i1 |( T1 rstatic int report_error( char *file, int line, char *call, int irc)2 L" T4 S0 z0 s2 T+ x
{
3 O$ t4 h( ]! M1 ?. u$ O% E    if (irc)
0 U2 d) J# x7 t# D    {
5 Q% L; J1 p& D5 z6 v& n8 P# `        char err[133];7 x. k1 S+ q$ n& e# C6 r* A3 X. x; d

/ b7 y# V3 O/ [% x1 [/ C8 T& n" m        UF_get_fail_message(irc, err);. z  |% x( E& r" N; t4 F
        ECHO("*** ERROR code %d at line %d in %s:\n",# B% U9 V- \% M) ^+ |
            irc, line, file);
. ~* G' f' H: S; w7 \        ECHO("+++ %s\n", err);
3 t% Y, V7 t% a, ]0 z* x8 s        ECHO("%s;\n", call);
# w( ?7 M6 q7 s- [- R3 ~    }
0 [) J4 ~1 J+ n% r, M) f) r: q- q
    return(irc);$ i* ~5 R' K' R
}9 u0 @3 M- h0 n* j1 P/ y3 w" r, Q

6 N( V- f9 x9 l/ S) L2 ]/*ARGSUSED*/4 c& {  _2 h( q# F% Q
void ufusr(char *param, int *reTCode, int paramLen)& N7 J1 q% t, E! }% `3 _
{) D& M/ q7 V; u+ v1 J9 z- I
}
6 B7 k0 i5 e$ h1 |
- L% b4 L0 H' l4 E" a5 j/*ARGSUSED*/+ ]2 |& @( J8 {$ P" A( Z
void ufsta(char *param, int *retcode, int paramLen)9 I5 j$ W6 ]8 l! P3 G5 y7 z7 D5 ^
{9 l" @2 H8 V9 ^  @6 d! O6 @" B  F7 N
}; D3 A* P$ M9 u% E
+ Z9 W$ k1 @3 V2 ^' X4 U8 q' f8 ?
int ufusr_ask_unload(void)4 y1 N  X0 e- v( V6 b8 g6 M
{
; l( s, f; `+ Q' p9 n0 X, b3 h    return (UF_UNLOAD_UG_TERMINATE);! X( z! B, `# ^7 s; N
}; |: E. m! B, I+ e9 G2 \( A3 j
1 g6 b- Q' C. {9 E. ~6 [+ \
void ufusr_cleanup(void)3 h) X6 w) w; s5 ?6 E- p/ A+ M
{, O* I5 t. t4 u7 [2 Z; I
    ECHO("NX is shutting down - running ufusr_cleanup\n");
- Z& o  @7 C' K1 t- V3 b! ^
& A; D8 M7 J7 R+ b- _4 E    /* put your code here *// n  w2 _. Q$ \
}[/mw_shl_code]
  c+ H% q& v' Y  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
+ @0 J7 X* [* ^7 U请问这个函数是怎么用的?有什么用?

$ e) T2 B; q% N) q/ u4 O入口函数 改成 ufusr_cleanup
% i% Y6 [, y7 `; S+ p0 i
7 a: S5 e* B. ~) K. Z意思是 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二次开发专题模块培训报名开始啦

    我知道了