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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x

' F1 J4 l; O+ U! G! n7 VNX二次开发源码分享】关闭NX后,做点儿事
- V# t# Y' ?/ V. U, J; m0 j
) M* G* X) J) U& V) o( |[mw_shl_code=c,true]/*6 g- c0 [+ V) N- m) }; R
$ \, {9 }( B  ^+ I" c* ^% N
    ufusr_ask_unload is invoked immediately following the completion of ufusr$ e2 F* j+ F3 K/ V, f. p
    (or ufsta when the dll is run from a startup folder) to find out when you+ I7 u# ~- }% z: d, |5 f
    want the dll to be unloaded.  If ufusr_ask_unload returns
! W, Q! t& C$ u+ n% @    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
$ {8 D6 V4 [# L1 |7 \    unload when NX is terminating.  To prove to yourself that this works, set* G" k7 v( d/ c" A
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not
- u/ A/ c% ]: ]' e* L2 c    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX! W1 L: _, E/ e
    Log File and make a note of the full path to the syslog which will be shown
5 A  Q  @9 Y- T" g; R; g    as its own first line.  Run the dll built from this code (nothing noticable4 s# F0 `: a; ?3 s) B/ F
    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
. H2 s6 k' O( @9 a: W! }- S& X; b/ T  `    see this line near the bottom:
8 n" k8 A& p( w( n' {
3 V$ o3 z: T8 q( x& X/ G5 m* R+ ZNX is shutting down - running ufusr_cleanup# D2 k6 a$ W4 [% |, n
! I7 c+ r9 P! D4 x. \
*/
) ~& P' G; ]0 t8 I# V6 K. ?! C#include <stdio.h># ]% T' w) K8 p# ?& F+ r. i+ X
#include <string.h>
9 x0 W2 }* J' i9 c$ S8 E#include <uf.h>
$ ?5 }- k- s6 s" o+ W# z, `# F#include <uf_ui.h>, R# q' I7 P# ]
#include <uf_exit.h>2 z1 D( @6 n4 r/ |1 L; t
* d% c$ g1 K2 ]; L# K$ w7 K5 f$ I
#include <stdarg.h>: C; U, K0 N# b

* A6 R; Z: q, n( z2 _( z7 qstatic void ECHO(char *format, ...)) X8 @) U4 y9 b# x2 D* w1 c5 Y
{
8 H' {7 c) ]# O2 S    char msg[UF_UI_MAX_STRING_LEN+1];$ _8 S( k4 U8 w! |$ g2 \
    va_list args;
6 u1 e+ N. ~0 d* g' C    va_start(args, format);" I6 \4 E' h$ b# X
    vsprintf(msg, format, args);
# p) ~. e* f5 W5 Y; T; Z' l0 c    va_end(args);
, R% k5 |% D4 n2 X    UF_UI_open_listing_window();3 M3 ]8 z6 T! B6 @& q/ `* b+ j
    UF_UI_write_listing_window(msg);
% P2 c( o/ A% h. m* g    UF_print_syslog(msg, FALSE);" f( a# B3 v4 N# E4 \8 b1 h# P$ b! u
}4 \/ G1 E3 L1 N" ]6 b! n( [

4 w; S7 B( }0 f#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
- p2 G& d" W4 F- G: x0 I7 K1 F/ j( _& y' s' H& r
static int report_error( char *file, int line, char *call, int irc): m* u8 C: @+ c) V' V
{; ~. m4 y9 B  p9 y% T
    if (irc)) L$ B- A+ \) A) v' E* d2 G
    {  \( {0 ?# L* s: G
        char err[133];  V/ o& N2 _0 r$ J7 V$ h

, Q0 j6 t, x6 y1 W8 _' V        UF_get_fail_message(irc, err);
+ T5 c' y5 K5 o        ECHO("*** ERROR code %d at line %d in %s:\n",
* P* j- O! `* v! R; x            irc, line, file);8 m4 o$ H: N3 g* [' Q4 C. B
        ECHO("+++ %s\n", err);
- `7 d( o6 w' F( m! |3 H0 W        ECHO("%s;\n", call);: Q( t& l! O/ a5 E6 M* N9 Q
    }
- Q- H4 n$ r9 O; U+ ]0 N$ S( A" W9 |
6 Y5 [& b: p9 ~! U/ f4 L! G    return(irc);* o/ J+ v+ @( C% O
}, I* |/ z7 M& E0 T( N' I

8 ?: k6 Q9 [5 M4 M1 C' @/*ARGSUSED*/8 u" |0 P( ^4 @6 W6 F7 P
void ufusr(char *param, int *reTCode, int paramLen)
9 u* W: V+ e, l8 O$ q; p9 y{
. Q/ m. v% s2 |2 Y$ z}0 o# V, p+ I  I

# r+ ^' N! o: ^/*ARGSUSED*/
- _! l# V, k( K2 qvoid ufsta(char *param, int *retcode, int paramLen)
; h1 f$ p: w* d: B{" m( p$ q$ H* ~: m5 P$ L
}
6 f- M2 v) w: P+ }9 e, G( J  L1 `% A! f: I
int ufusr_ask_unload(void)3 _+ w- j* W6 F9 T7 y
{) K8 b7 |$ I7 N
    return (UF_UNLOAD_UG_TERMINATE);- s3 d# A! u& V# ], l# C4 {/ T
}9 s- ]8 `) l/ U( S) k

1 q8 p( j) g& o3 B& Q, kvoid ufusr_cleanup(void)
$ L, e' i4 Z% Q: \{# f, [+ x1 ^/ l* H8 k
    ECHO("NX is shutting down - running ufusr_cleanup\n");
/ W- c8 o, d+ E/ j% h5 S, I
4 }) W) S- E7 n4 H. a    /* put your code here */: q- j& k$ S  t; c' U, w
}[/mw_shl_code]- t  \( s+ V4 a+ l/ ?8 d5 y. X
上海点团信息科技有限公司,承接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' t0 J7 S9 O8 K% v1 z& n
请问这个函数是怎么用的?有什么用?

1 \5 y3 j$ Q7 ]) G入口函数 改成 ufusr_cleanup 2 U5 t! ]8 Q6 a' C- Z0 i5 R

5 j3 _& p$ ?" G* t意思是 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二次开发专题模块培训报名开始啦

    我知道了