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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x
2 `- |5 f: g' W% b
NX二次开发源码分享】关闭NX后,做点儿事1 B- _7 `+ ?- Q
5 A0 x2 T, T9 y7 \9 D
[mw_shl_code=c,true]/*0 @; t1 _7 L1 p

! s4 m, z7 {* S( S) U/ a    ufusr_ask_unload is invoked immediately following the completion of ufusr
7 J6 |1 R4 |* T% B* E4 ?. n* k- U, \1 h    (or ufsta when the dll is run from a startup folder) to find out when you  q: n1 M8 h# s0 ]2 i8 {) y2 b
    want the dll to be unloaded.  If ufusr_ask_unload returns6 L! r& _# ?( J0 z
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
6 r4 h# h/ D2 l: a( E, ~    unload when NX is terminating.  To prove to yourself that this works, set, u& G- a. m! P5 j
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not+ c+ F) N' Q  Q: `2 s0 L  y
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX5 M7 W9 Z. [0 r/ b9 W5 z& d
    Log File and make a note of the full path to the syslog which will be shown. u( O1 t# R% t5 a* ?* |; n; u1 _) f3 w
    as its own first line.  Run the dll built from this code (nothing noticable
/ R8 t$ [& U6 G6 l/ A$ B  b    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
5 b9 q1 v/ q4 Y: L8 T% x    see this line near the bottom:% |7 I4 V$ h& v. i. Z" T

& b% [! A7 D# a, L# @NX is shutting down - running ufusr_cleanup
0 o/ }% X- r1 j" y' \$ T
" Q3 L& s6 n: y: w) k0 C*/
7 N! ?7 `. O0 Z, H0 k5 P#include <stdio.h>$ K7 I, ^2 ?- |" `% b5 M
#include <string.h>
: [3 I% ?2 S& E#include <uf.h>
+ @, H$ ~! S6 k$ t$ X  o" v* w#include <uf_ui.h>6 ~1 H" O3 o0 q1 r4 a, f2 s
#include <uf_exit.h>
. p: V/ l( K, Y( N+ s/ q. U/ X5 Y$ T4 c$ }
#include <stdarg.h>5 S( w# H3 E# m& q$ F5 b% u' G

- n# |2 m5 Y: sstatic void ECHO(char *format, ...)
3 q$ c3 }9 \* G& r# l( I) x{
! Q: y" U6 U) ]) N5 Y. @: v    char msg[UF_UI_MAX_STRING_LEN+1];6 e2 k+ M" v" `3 G$ c
    va_list args;
7 j8 F( E! ^, A& u  j# B& P' e    va_start(args, format);4 Y) G* R0 ~- ~! s; ]  w
    vsprintf(msg, format, args);
% y- k1 v. N- J. I2 p3 C( W    va_end(args);) i2 I  g& J& i8 B" |
    UF_UI_open_listing_window();
4 b7 r* x0 a2 l& H    UF_UI_write_listing_window(msg);
5 t/ {) p0 h2 O1 N; Z6 I    UF_print_syslog(msg, FALSE);
0 o. t& z, f; K! _}
: }8 E$ z2 Y! P) L# x
0 a1 G1 a# K( F- Q1 ?#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))+ T0 \+ _# t4 Z- D! k  F3 c

6 P% i  H8 h5 y" q* j* bstatic int report_error( char *file, int line, char *call, int irc)
8 G- k% z1 T2 z, f' I{1 m/ L* J/ D& t2 C9 g- Z
    if (irc)
/ G: n, e, S! H' ^% ~8 W  r( Y    {
% G, z& ^! e: y: Y5 V: I; q        char err[133];
; F$ a8 U# S8 X  S# t) c  {2 O5 u. G0 i4 j4 Q5 J
        UF_get_fail_message(irc, err);1 A9 C9 B$ K$ o0 H; s
        ECHO("*** ERROR code %d at line %d in %s:\n",
  S6 k, F) P. d+ x' u+ n- H) k            irc, line, file);5 }6 h. W' a/ D+ q
        ECHO("+++ %s\n", err);2 u+ W# q! W: A* Z+ X, G
        ECHO("%s;\n", call);
, g- k1 ]4 t* ?' t' w8 ~    }
' x* R$ K3 }- h# Y% e3 c( @: ~1 X' i8 _' p2 u4 \) p. n
    return(irc);8 D0 A: @7 u2 A$ X) z
}
, P, |$ w2 \" p4 [3 {: d' f  N( W' ]1 ^7 c* c3 V
/*ARGSUSED*/; Q$ K- g! h9 W# w' |
void ufusr(char *param, int *reTCode, int paramLen)
/ y% T- e" u! S{
8 K  s7 Q# Q- h; b# O}
' f, O* y9 ]# l, S
9 S8 U' y! q; E) B/*ARGSUSED*/
, ]+ l2 d7 ?; P/ D4 r& Uvoid ufsta(char *param, int *retcode, int paramLen)
! A' b  w2 R* k) Q) M0 c# j' n( p{! ~, T7 t% S6 p/ N# r) I+ e5 c, B$ n) ?
}
0 V8 D* [* F) L8 l" u" r( u( B+ X- Y( H: }6 V1 e+ d) B
int ufusr_ask_unload(void)$ v3 m6 t4 f: M) G+ }) I
{
5 w$ Q) V- o  w" Q1 j" e! k    return (UF_UNLOAD_UG_TERMINATE);; Q) k  b' {& k- @  x/ N1 \
}4 ]) J+ {1 H' A
3 M: G( v* X3 H0 g2 ~& K' _
void ufusr_cleanup(void)
: F  I% W" C. x5 K{" ]* ]) l; j; u7 u+ N  g$ Q( C
    ECHO("NX is shutting down - running ufusr_cleanup\n");( b8 Q( L8 L% g5 ^& g7 j

: `' B% q( M0 d  `    /* put your code here */
6 Z* o, ~, K# V}[/mw_shl_code], D- W0 q6 k0 D" X! d! @- z. _7 \
上海点团信息科技有限公司,承接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:494 S, \2 b9 E7 U% S% R0 c
请问这个函数是怎么用的?有什么用?
( l1 q" o7 t' r: }5 G
入口函数 改成 ufusr_cleanup
1 ?! K' i" [2 n1 H
6 g. ]) {1 Q& B( _! l意思是 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二次开发专题模块培训报名开始啦

    我知道了