PLM之家PLMHome-国产软件践行者

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x
0 B- k4 C- k- r1 Q1 K  J
NX二次开发源码分享】关闭NX后,做点儿事  a* z, o1 ?/ k' y6 S
5 J  N' U# z# l! ?
[mw_shl_code=c,true]/*/ i5 U6 p# {: s$ K4 d0 h
8 \1 {# `- s: Y, U+ f9 V+ n' q# X
    ufusr_ask_unload is invoked immediately following the completion of ufusr% @% L- Q. D$ n8 @( n. f0 X
    (or ufsta when the dll is run from a startup folder) to find out when you
0 X7 l5 h6 Q; I; w, P. A1 E6 V    want the dll to be unloaded.  If ufusr_ask_unload returns6 C! l& S2 j6 ^& ]- t
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
0 _- O) L  ^( w" e* k' s    unload when NX is terminating.  To prove to yourself that this works, set
7 g: Q1 l) q2 }1 s# r% F, \" S( z& R    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not
7 M6 x( f( n' c9 Y. O    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX. l& |# n2 q9 L# u9 f
    Log File and make a note of the full path to the syslog which will be shown, r* w1 {- [0 u7 k
    as its own first line.  Run the dll built from this code (nothing noticable0 K+ C! ?) g5 D0 u4 m3 ?5 \  O5 a
    will happen.)  Exit NX.  Find the syslog and open it in any text editor to' N8 d$ H+ j4 T0 G0 `; x" T) z
    see this line near the bottom:
5 t' k3 c; q  T$ C# a6 K; ]7 ~* d& V3 y5 D: E& p% U
NX is shutting down - running ufusr_cleanup. Z7 y6 W5 k! D' S
; Q3 j6 E8 V8 X: y7 `$ o$ m
*/
9 F$ I) h0 m& ~6 _9 n: l6 j8 X#include <stdio.h>& b0 C1 b# c; N! N1 _9 q
#include <string.h>
. T4 V% @/ I/ D9 ?; s#include <uf.h># O' M+ t, r* U* X% q; ]- C! J$ k
#include <uf_ui.h>* H+ w! c2 X) R/ k7 j; B
#include <uf_exit.h>
# f& l2 }6 ]5 m+ s1 t4 y& J- L8 b
#include <stdarg.h>
5 h5 h4 H. Z- t1 L2 z" ?! [# j
2 s" k; D; s5 h6 {2 ?* R4 A" {$ zstatic void ECHO(char *format, ...)9 x1 v4 c: W; P2 E3 ?( n
{
3 h! Q2 R$ Y, A; D! ]    char msg[UF_UI_MAX_STRING_LEN+1];9 V( Y4 S* Y0 T, w
    va_list args;8 u' c4 y2 P* j
    va_start(args, format);+ [, D2 z. q) Y
    vsprintf(msg, format, args);6 @* i9 C0 S+ ]3 {' _
    va_end(args);
0 G$ G3 u  n6 s7 e0 N    UF_UI_open_listing_window();
+ b+ ~( Y% m! J5 \4 m8 z' N& i, i+ {    UF_UI_write_listing_window(msg);2 }8 I  h5 i& D( u" X' C
    UF_print_syslog(msg, FALSE);
2 q2 M& [, R0 T- s& i" v4 l}
* l, q2 q5 S. ^6 ]) `8 G! r/ Q+ u  }
1 B' s5 s" Q7 R& A#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))- \. l5 }' u( M, a8 s5 Q5 H

% i( _8 H- W3 h5 gstatic int report_error( char *file, int line, char *call, int irc)' O/ J; _; H: x$ \4 z* J& ?# p
{9 M# r; z$ K1 B* q" w5 w0 {6 W, d
    if (irc)
$ H. J% r. x1 [/ ?5 v9 l    {5 A; o2 o) s" [" s) N1 v
        char err[133];
* W8 f' O7 j1 a  U
, P$ {$ K/ e  @( l  R. C        UF_get_fail_message(irc, err);
7 t" w  x" Q6 N* I# n. z        ECHO("*** ERROR code %d at line %d in %s:\n",
$ P* R6 Z2 ]/ S. w            irc, line, file);4 f1 s4 P1 p3 {% H: D
        ECHO("+++ %s\n", err);% q" A- P# X) S! H$ S
        ECHO("%s;\n", call);! ]/ N2 F2 d- Z) L' X' N
    }
5 ]9 O( O4 t7 N7 J% V
$ R' @0 G6 h+ g0 y    return(irc);
* J1 c# @$ z6 z4 L! l! u. l7 p! M2 Y}
/ _) C1 h- Q5 N& ?% m, Y! b3 s/ v8 K$ d' k- ?: v
/*ARGSUSED*/
$ U' Q) m( R6 B0 J8 \void ufusr(char *param, int *reTCode, int paramLen)
  P: g, T3 W, ~, K1 D% O; Z+ t{
! o, ^1 D1 I2 ^- l}* e# b9 o# z  |* q
9 H' e/ g6 n" B: X& i" E# x, B7 K& ?
/*ARGSUSED*/7 p- W1 M2 ~' G
void ufsta(char *param, int *retcode, int paramLen)
! k$ p; ?* D- b3 m$ A{
$ d' [6 ?* ]9 G9 p. u# o% d/ d- ^}0 F6 H1 l2 L: z8 D9 x0 ~

, p' m0 R0 B+ o) f0 qint ufusr_ask_unload(void)0 i3 {- c+ w5 q2 M6 K
{
8 u, @" l% u' A* Z    return (UF_UNLOAD_UG_TERMINATE);  `3 p0 L; f) Y
}* V* @# i4 w: S3 @# {5 O2 d1 D, t
# A5 n2 v, S0 s% `9 H: C
void ufusr_cleanup(void)
8 ?* M! W9 S; Y( {/ y{* k+ @; A: L. J+ |# G# }
    ECHO("NX is shutting down - running ufusr_cleanup\n");) F# r: E# _0 o2 P6 S

. v+ {3 y) H& B; l( G& g( J+ l3 d    /* put your code here */
9 O3 N3 [- y" i; U* ~  I}[/mw_shl_code]
- c+ V% B: G# n% k0 Z- A0 t# ~% \
上海点团信息科技有限公司,承接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: V9 O9 C: I5 v* c: C请问这个函数是怎么用的?有什么用?

) d3 C# S7 m; S+ P: M9 k入口函数 改成 ufusr_cleanup 7 Q- l, R! V" q
# u4 U2 \5 W& j5 K8 G9 k4 q
意思是 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二次开发专题模块培训报名开始啦

    我知道了