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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x
9 x) l$ O# ?* D: w
NX二次开发源码分享】关闭NX后,做点儿事9 v6 X" \/ |! m3 [! T3 H  \
. I9 V3 l$ z: a) r
[mw_shl_code=c,true]/*
' j5 ?# Z& S5 C1 n1 j/ o4 E# n0 k5 ?' U" k% [
    ufusr_ask_unload is invoked immediately following the completion of ufusr
; R8 a" q, n6 F0 g* X4 m    (or ufsta when the dll is run from a startup folder) to find out when you3 z& Q9 K; H- h+ ]
    want the dll to be unloaded.  If ufusr_ask_unload returns
+ p8 Y" ^! I5 w; n    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
  p. i* v. `! y+ V    unload when NX is terminating.  To prove to yourself that this works, set& O+ {5 y! U; U. S% q
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not% J5 c; d# W0 n  {( g( N
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX8 }4 w! o5 U* r: i- `+ w
    Log File and make a note of the full path to the syslog which will be shown
$ c( |7 C0 a' d) ]' O* `    as its own first line.  Run the dll built from this code (nothing noticable' n0 z' s: v! ~
    will happen.)  Exit NX.  Find the syslog and open it in any text editor to! a7 [7 R) c; x* S- W1 k! o+ f
    see this line near the bottom:
" T/ Q. \$ l. X# {7 r
  H( D+ R; c. Q! Y1 [2 WNX is shutting down - running ufusr_cleanup
, M8 I9 Z" n! g# t. X, R$ v6 j9 I6 ^1 X, \1 v; Y7 L
*/0 S' h4 H- D. a; w  E* }& l, `! V( ]
#include <stdio.h>! G: n+ \& k, h7 C: \+ M1 Y' O0 X! l
#include <string.h>
+ Z$ N" [& F7 |: G#include <uf.h>" a0 D3 ^  O8 ]+ N+ ?, I
#include <uf_ui.h>! j- h7 s/ ~; e, F8 h! B
#include <uf_exit.h>
! e# z% b8 r- _4 ]' s
, P, o; p# O7 f$ O5 E1 D#include <stdarg.h>  g4 M5 A  r/ F3 P" F4 [6 x
6 o6 V: u" a# r' l
static void ECHO(char *format, ...)
& W+ p) w3 }; ?. g% E) h{: ~8 X9 u( h8 Z( s- ]: Y% Q! L( [3 d
    char msg[UF_UI_MAX_STRING_LEN+1];
# w, T! X* O% |0 l% X    va_list args;
, B. {: A9 i& s    va_start(args, format);" }. @& ]/ }- I; C) l% U% ]% W1 S9 a
    vsprintf(msg, format, args);
6 {; D/ W: O+ {: O% L: K    va_end(args);) ?' \/ U3 H6 E/ v
    UF_UI_open_listing_window();
3 L7 q" ]( U, ]# I+ c, H    UF_UI_write_listing_window(msg);4 Z) \! E1 Q5 @5 c
    UF_print_syslog(msg, FALSE);6 r  V% R7 U& l+ n4 h3 D7 F2 Y& x
}9 u8 N8 e8 K0 w* F

7 A* v4 ~6 I6 w5 d0 C& P#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
  M: W7 Y, W' d8 k) S) B4 _' k( c! C$ D9 H4 B5 [" l* O
static int report_error( char *file, int line, char *call, int irc)
9 r) Q2 n! }0 K9 _{
4 m- {. Z0 z% l, B  V    if (irc)
& G( k4 ]$ ]; q7 V: O    {, o+ I9 S, l) C, |' `  _
        char err[133];: Z3 L# S& J! }! [. F  U6 D$ C

) L* u6 g, n* D2 J  u        UF_get_fail_message(irc, err);3 l, z9 e- n$ L$ T0 W$ Z$ V
        ECHO("*** ERROR code %d at line %d in %s:\n",4 j8 h7 l7 l1 N7 Y: L1 S: y
            irc, line, file);( o. V: q; w7 g! g9 D2 @
        ECHO("+++ %s\n", err);
  V2 a7 [3 S+ ~3 p        ECHO("%s;\n", call);6 s# ?, k# m2 f
    }
9 Z9 i& l" _+ Y4 Z! K# M8 }
% _5 T6 b0 G# x/ O3 g) T% q    return(irc);
' I9 P* ~. I7 N}
7 b- c  o% G) Q" p
' ^: _' u0 a" C# i! p/*ARGSUSED*/
2 x; U9 B7 T3 v9 yvoid ufusr(char *param, int *reTCode, int paramLen)
$ y8 ^3 L: u& I" x) i4 I. a6 C) l{
0 E6 f4 F1 Q. y' C2 J! E}
) C- E* B5 K. P8 }* c) K
: U1 h3 R( ^' Z7 J' R6 t) ]/*ARGSUSED*/
$ t  E" L/ A# T4 u* A0 Y1 Tvoid ufsta(char *param, int *retcode, int paramLen)
* x  J9 l& H2 b0 L' t% v6 i/ k{
! o' s" K, @. X6 G( w}; W+ K3 C8 u" d. U6 w$ Z

5 r9 X( P1 J. C; ^0 ]6 h" vint ufusr_ask_unload(void)
- I) V6 w3 z2 t7 I: l! t{" h. H) w9 x" }3 h9 N
    return (UF_UNLOAD_UG_TERMINATE);5 O5 g3 P# @" z& ^) u
}
9 V* }6 @* H# g/ U
# {' m& N! I2 `# |void ufusr_cleanup(void)
, y( h0 |* n+ O; `1 Z5 p% I{
" F( s' H) d, X; o7 L9 o$ `# }    ECHO("NX is shutting down - running ufusr_cleanup\n");- C0 }& r) @$ L4 j; q5 S
7 h' ^7 x" p4 c0 I) _
    /* put your code here */
& C  Z# @7 P0 I$ N. ?}[/mw_shl_code]' d2 k' V5 q5 B; H
上海点团信息科技有限公司,承接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; R* x" X* |8 J请问这个函数是怎么用的?有什么用?
  a* q3 @/ u* e/ |1 E+ o
入口函数 改成 ufusr_cleanup ) @  Q! m! [; b: l) U  S: D

: c% z2 Q& S) J4 h6 }, d& {5 K8 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二次开发专题模块培训报名开始啦

    我知道了