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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x
+ x3 w! Q9 W3 x7 L6 t2 R" S8 B  ~
NX二次开发源码分享】关闭NX后,做点儿事" I$ A2 d6 I# u. ~
6 F& k8 ^% L1 t; a9 ~
[mw_shl_code=c,true]/*+ z" K$ ^, y+ r$ n5 O. S
, U4 ~" H% C/ |0 N" G
    ufusr_ask_unload is invoked immediately following the completion of ufusr
6 a2 x* w+ r  ~' X3 i3 g' O    (or ufsta when the dll is run from a startup folder) to find out when you$ M, p$ E2 ]* L# }) E8 R
    want the dll to be unloaded.  If ufusr_ask_unload returns9 R% t. I* o  A0 H6 E& A
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is6 h# _: m# Q( ^
    unload when NX is terminating.  To prove to yourself that this works, set
7 g7 P4 U0 ^+ T4 |4 U    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not! @  @+ ~5 s  \+ \! W/ q
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX7 M9 S1 `' J5 G$ k% L0 @
    Log File and make a note of the full path to the syslog which will be shown
) \  {/ h* x0 B& h    as its own first line.  Run the dll built from this code (nothing noticable( ]" ^7 g+ ?5 q8 [$ W
    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
  ^$ w8 S# n8 i5 T' H. V7 J    see this line near the bottom:
' m: I8 w% b: j% x" o7 @: s8 T9 d; x# ]
NX is shutting down - running ufusr_cleanup/ G2 U7 D1 W5 ?' e
% O, v. g" O0 D4 N7 q
*/
4 A, F. B9 \/ Z' h/ J) U+ Z& H) D2 E* q#include <stdio.h>
1 u3 v; P& M5 g9 _#include <string.h>/ _9 e% @. D, w
#include <uf.h>
/ i# u( u- @" {! ~3 S2 p#include <uf_ui.h>8 M+ s7 A1 q+ I+ N1 G2 X: Z
#include <uf_exit.h>; ?) ^5 O$ P/ ]" W
9 U0 \$ G4 q) E; ]4 u2 Y8 v
#include <stdarg.h>$ X, C# U% j- J  I7 A
; ^0 ^9 `. G- x5 W/ f1 F, a
static void ECHO(char *format, ...)
; M- B1 d' y/ @. E8 z{
5 Z) c8 l! j2 F* g7 d# C0 K    char msg[UF_UI_MAX_STRING_LEN+1];
3 U- P0 |7 u1 ~! {* c    va_list args;) @! O5 B, \0 u& G, d
    va_start(args, format);
# e; v% k9 H* [3 r0 @    vsprintf(msg, format, args);
) Q5 b  ?* \5 c2 g1 |3 N) t    va_end(args);
) \  X) {$ O  C6 n. q    UF_UI_open_listing_window();
# v& |, U* q8 N7 g+ Q    UF_UI_write_listing_window(msg);
& b4 o- O6 q6 K3 J( ?- ]. o0 j3 |, S2 @    UF_print_syslog(msg, FALSE);
5 T) N( y' L+ C# x5 j' T2 y}
# z1 a* e% b9 }6 r4 t7 g6 e  k
) h6 V+ J9 F  R#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))1 f" b3 Y3 X3 h4 ?( j6 c
. `/ H* e6 E5 @1 D
static int report_error( char *file, int line, char *call, int irc)
* d  ^7 i. }, l1 L2 F$ x1 k- s2 {, h, y  x{$ d; ^; |; Y% o7 C! P- L
    if (irc)
, \" k  j$ n  ]: g5 x2 T, I    {
9 _& K8 e( B7 f9 i; a- A$ Z        char err[133];
8 A5 a+ ^3 s/ I7 A
0 Z: H% R( D: _/ ~" ^        UF_get_fail_message(irc, err);1 P( r. n3 D) d7 [7 w9 ~
        ECHO("*** ERROR code %d at line %d in %s:\n",$ @* `8 m1 }% k1 P
            irc, line, file);) k3 e8 _# t) P
        ECHO("+++ %s\n", err);
/ K. F' N% V7 |+ n4 d0 P) ~/ ^        ECHO("%s;\n", call);
" K9 |" K6 g$ ?0 N' B* b& {    }* I# z, Y: P$ z6 N
4 W' ]6 K7 `& Q5 a. p9 N* B0 ^
    return(irc);
; v; _2 c" _, ]7 U3 U}
2 g3 ]1 T, w- a9 Q. l, f1 C" W2 \: _( U) z/ B, p8 B! G
/*ARGSUSED*/) m2 o" I  Q* j3 V$ Z
void ufusr(char *param, int *reTCode, int paramLen)
0 v& D3 A9 j9 K% E{* E1 D2 V+ [4 E4 b) I# C: r! J5 U4 x
}! z2 _2 b" P' j+ m4 U* b6 u- c
$ \. R5 s& w; G/ Z+ R7 k* e: _: W
/*ARGSUSED*/9 v2 @! E2 x  r( m9 u) H+ W$ Q/ ]; ^
void ufsta(char *param, int *retcode, int paramLen)
9 L, Z4 n4 J/ K1 x2 |{' a( m. \2 E4 u0 X& h
}
" ?9 L- ]7 L, \$ @3 N8 B4 |/ P8 o1 E# N
int ufusr_ask_unload(void)( q$ Y/ H* n& L
{$ d& t0 Z& l5 l( M' h$ n0 @
    return (UF_UNLOAD_UG_TERMINATE);0 M0 Q. `, `0 t  M) z) j3 e) O! |9 R
}
# X: A2 I- |+ y/ L
4 G5 R% r6 x4 M7 W( {  ]8 k6 _void ufusr_cleanup(void)
! C* [" t$ e) V0 p6 i{
! n' O: y. ~" v5 z: o) u" I    ECHO("NX is shutting down - running ufusr_cleanup\n");; y- C! X/ P, r  |# f) ^7 C! }1 U" F

7 b5 C- G% ?3 y- j1 e    /* put your code here */
# \' P8 M' p' ~6 L; N2 b/ h+ ?}[/mw_shl_code]
! N/ @' k. h8 A' @# q! ?. E  B) O$ ?
上海点团信息科技有限公司,承接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# F6 O$ L3 W& k1 ~. v2 _
请问这个函数是怎么用的?有什么用?

1 d6 O, a5 w4 U, ]- F入口函数 改成 ufusr_cleanup
' `" v3 ], q. d$ I* b' Z
- T8 t: M) A- ~+ @5 J, W' U! P  h意思是 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二次开发专题模块培训报名开始啦

    我知道了