PLM之家PLMHome-工业软件践行者

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x

$ p+ T  c3 z/ O& _. Y) J- INX二次开发源码分享】关闭NX后,做点儿事& M0 v! d) w0 b; e: a2 |! J8 E

6 ]" K8 W* ~$ D[mw_shl_code=c,true]/*
2 |% X8 I2 o5 O! f1 _6 e8 x6 e2 A) X* K3 F
    ufusr_ask_unload is invoked immediately following the completion of ufusr  c4 r. e" r  L$ Z/ M4 V& b
    (or ufsta when the dll is run from a startup folder) to find out when you5 I  _3 u+ I+ Q1 a4 m
    want the dll to be unloaded.  If ufusr_ask_unload returns3 \( ~, ^  ^0 L. G% l
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
( y. C# y0 E$ }+ F& o8 y& T' e    unload when NX is terminating.  To prove to yourself that this works, set" @. I9 V9 d$ m  z
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not
# a. k4 y, G3 m7 x3 c8 s0 W2 ^    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX
! s* ]  f* D& j2 P) b9 L9 V& y; c4 w9 M    Log File and make a note of the full path to the syslog which will be shown
% T% I: d- T8 V/ L% {% y    as its own first line.  Run the dll built from this code (nothing noticable
6 y: e1 d) _- O  }: p0 G4 \5 X$ e    will happen.)  Exit NX.  Find the syslog and open it in any text editor to9 e! e* B' O2 B7 Q% \. x6 o- |# W! ]
    see this line near the bottom:
! l, r6 Q# l( y- w0 m; Z
( b5 Z2 M: G8 q0 D1 R4 I' p) ANX is shutting down - running ufusr_cleanup6 t0 |( d+ y) }; @0 f3 b4 ^
3 }9 ^, D3 }) M: ]9 Z: ?$ `6 r
*/
3 N0 _7 m" L, `#include <stdio.h>& D* E' z, y, T3 x
#include <string.h>1 {2 I/ P8 y0 |+ R
#include <uf.h>
; m$ C9 B6 R1 f5 d9 l#include <uf_ui.h>1 D* O3 U0 X4 h+ Y9 o1 E, X
#include <uf_exit.h>& m5 }7 ]- [0 J& o9 F
# |" r9 b! d  O) W* G) m5 G& E
#include <stdarg.h>: A) {* N  w! i4 r. a/ h: k8 `

4 q2 i) \5 x0 A1 D/ [static void ECHO(char *format, ...)! m  N: h! @5 ?9 g% T1 X
{
3 N7 t  Y9 M" }7 t8 q, h' _; [    char msg[UF_UI_MAX_STRING_LEN+1];, V: E" d6 T' ]1 S  B
    va_list args;& ]  S4 n# a  x/ ^# X
    va_start(args, format);
; }: E7 [4 Q0 `% Q    vsprintf(msg, format, args);; h. ~, E* t& K2 g0 z6 P
    va_end(args);
; ?! A6 M  X+ K% A- h$ b7 J; [. C    UF_UI_open_listing_window();
9 s% M5 N8 v/ }* U0 Q: X    UF_UI_write_listing_window(msg);
8 a2 v7 @: W3 h3 N! U4 r    UF_print_syslog(msg, FALSE);
4 V- b' x1 H, b$ T" G- p7 o4 x3 L}
  G; S. k1 l; [1 `
$ Z- }6 c" g5 W% g! P#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
4 U  @4 {0 }; t
. c6 y  O0 r9 wstatic int report_error( char *file, int line, char *call, int irc)
9 _  P3 ~) Y- _{, V8 @, s. J1 k( M& ]
    if (irc): a' A, b, J. i5 a# |9 r
    {
. f4 h) y' \$ U; h( G. Q$ ~0 x( g        char err[133];# E1 K8 ^8 v' q

/ w( ^& g3 Z# O8 C3 P" J4 \/ @  ~) P        UF_get_fail_message(irc, err);; v; n  M; O4 J# n" q
        ECHO("*** ERROR code %d at line %d in %s:\n",
; b: _' D% Q5 u0 u- M            irc, line, file);
. r& l( p7 b  f  n6 I        ECHO("+++ %s\n", err);& u% C* J- t. D& `* Q
        ECHO("%s;\n", call);
) k& N0 l& A; }7 n5 k+ }6 `8 W    }
2 }4 j( y& t; z
& W! p- u# w" [, p) z9 s    return(irc);$ L$ B" x3 j/ u0 f
}
& G, o5 f$ E4 w4 ?+ L: I% _4 q2 [' r1 |! B( B# l! Z( U
/*ARGSUSED*/
) I+ ~$ s) A% H6 nvoid ufusr(char *param, int *reTCode, int paramLen)
% r" B9 K1 @% c& S{* C) i+ g- [- h
}
) J7 ?. s7 f. R) d# M% F: I
4 @/ S& U2 k; T+ a% I/*ARGSUSED*/
4 ?. N; ~  z; H" \void ufsta(char *param, int *retcode, int paramLen)8 J; {+ q7 y, @
{4 N+ W' Y4 d2 G$ [& Y4 N
}6 J6 N- k, B- o" o) y( Y

) |1 i: M' y' H; _int ufusr_ask_unload(void)
3 A- W( C. I/ {) ^! z6 @$ v{4 u% h( R! ^% D! f: k) p
    return (UF_UNLOAD_UG_TERMINATE);
: E4 C3 r, }0 l7 j: b}
7 A1 f+ ^# _/ |% |4 d, O+ Z! X* M( [
% A4 e" R+ W! O' m4 w3 r5 H4 N) jvoid ufusr_cleanup(void)
3 p3 T, n/ h; W1 i1 j0 ^{. L; c# A) @+ @$ H/ o
    ECHO("NX is shutting down - running ufusr_cleanup\n");
0 M; P  o- Y" W+ G9 A7 w1 U9 g" ]
" Q+ d) l# x" u) J9 c7 w% L    /* put your code here */3 ]) w( V' {# S9 D+ M
}[/mw_shl_code]7 T0 i$ i) Z0 K0 X3 e
上海点团信息科技有限公司,承接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
. A+ G& h& A% }- I! W# z请问这个函数是怎么用的?有什么用?
9 e* D; v6 w  V) Z
入口函数 改成 ufusr_cleanup 9 O% D* P5 B& o: f& S7 O# t# J
5 d# O8 w" g) X# _5 U) ]+ d8 J
意思是 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二次开发专题模块培训报名开始啦

    我知道了