PLM之家PLMHome-工业软件与AI结合践行者

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x
- Y3 ?8 H! K  s' v4 e
NX二次开发源码分享】关闭NX后,做点儿事6 `; W1 @  R% P! f) d9 k) w) m( [& R

0 T& W2 W& N5 ^" h7 y' d0 d: @' m[mw_shl_code=c,true]/*
5 {+ j/ u+ w- [; o# n% z
" P+ Q7 v0 s# `* q+ N" W    ufusr_ask_unload is invoked immediately following the completion of ufusr
# ~' W: @: e0 _5 V- ~& b    (or ufsta when the dll is run from a startup folder) to find out when you
  X5 |; D7 ?" ?& Q! g  o    want the dll to be unloaded.  If ufusr_ask_unload returns) d9 {# F. ?% s7 D6 e6 [+ \5 W
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
* w) P- f6 R. p+ c/ G1 |    unload when NX is terminating.  To prove to yourself that this works, set5 j6 Y/ A- m9 m3 p
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not& S( A+ s, I. e' l1 s8 i) q
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX& i* \6 c$ F4 q, g
    Log File and make a note of the full path to the syslog which will be shown. V  \5 |6 x  D+ W+ a# K% D
    as its own first line.  Run the dll built from this code (nothing noticable8 A: E( a5 k0 y8 N- q9 ~
    will happen.)  Exit NX.  Find the syslog and open it in any text editor to$ `5 s' Y/ i# x) o  D! R/ M
    see this line near the bottom:) G' @$ m: |- |6 i- n0 U
# Q$ l, ?) Y) Y" X( T
NX is shutting down - running ufusr_cleanup
! z7 t* c3 m: v! `" Y" ^$ V& v+ e
, k' E0 M7 s2 N+ T( n9 P! y*/
2 X/ \  K, F6 Y1 L- b$ `7 g3 t#include <stdio.h>
5 y0 b- r  _5 W) d* z: _5 G7 w, L#include <string.h>
- C+ s4 O2 [& N#include <uf.h>
! H7 I' Z! ]; e) V; x/ r5 ?9 ]#include <uf_ui.h>
& x* a! l( X7 d, y" E4 J2 U#include <uf_exit.h>
& l) ]* v) y2 J" C8 b% d
3 a5 R6 \+ I8 _+ B1 C' ?#include <stdarg.h>1 t9 T- h; l" N& x( o
0 w( M& }* a4 J0 V3 M. v
static void ECHO(char *format, ...), \1 ]. x6 @" @9 U, H
{
$ Z7 U/ `$ O' B" t- I    char msg[UF_UI_MAX_STRING_LEN+1];  M# i' h% a4 J, y/ z
    va_list args;$ s3 `, t6 F- V& f: W5 P
    va_start(args, format);: ]' \2 y  h/ E5 W# y
    vsprintf(msg, format, args);
) V- n9 I* ~7 P; f% d8 N. e* Q    va_end(args);
; a. g$ p3 c& z# G  Z0 z, X9 ]( B1 ~    UF_UI_open_listing_window();5 k+ T! v. d$ `/ A8 M' q
    UF_UI_write_listing_window(msg);+ _9 _; V8 J* t8 }8 u; k
    UF_print_syslog(msg, FALSE);6 K3 {1 Z# f7 _  s. \# ?3 E7 |% \! h
}
2 A( r! n6 L3 r& {6 X$ M% {- B
; t9 O! H/ v9 I0 |#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
! [* m+ S) |6 l
7 N2 p4 ]3 \1 q- `2 Hstatic int report_error( char *file, int line, char *call, int irc)
" f# ~/ ^/ ~' Y' I{
4 ]& w5 N( l, S- @    if (irc)* ~6 j' l& V  V+ Y6 W
    {
7 H$ F& w  @7 i7 @+ k  ~+ `        char err[133];
! M0 R4 }- r3 d; ?. ^/ S: H) v0 i# v! l9 H3 d
        UF_get_fail_message(irc, err);
: p7 ]  ~* D9 H, v        ECHO("*** ERROR code %d at line %d in %s:\n",, N5 \1 x! ?4 b4 [8 h9 s
            irc, line, file);
3 \. e- {1 n9 Q8 g        ECHO("+++ %s\n", err);
" f, q+ _8 G- X1 G  Q- A+ o        ECHO("%s;\n", call);, H4 H# t/ E/ [1 y6 Q0 I0 }
    }
9 g/ A, y1 v3 f9 {, O
- ^: i' h: i$ o/ V1 J    return(irc);
3 j- [4 W0 x; Y+ ^, p! s" f}
5 ]' h# A+ N6 R9 L' o! F. F& F/ ^9 G% [( {
/*ARGSUSED*/( m9 P0 `( J. }& E
void ufusr(char *param, int *reTCode, int paramLen)
% E! {; T6 B5 z8 Q2 k{
3 W9 U' c' [5 x: b" c4 U}
( |$ P3 E* C5 [/ G# G. n$ T5 J2 K2 z$ t; m
/*ARGSUSED*/
0 V+ k+ i, _' W4 Y! E) [void ufsta(char *param, int *retcode, int paramLen)' M3 f( o5 j) f! ]' A0 X$ Y- j2 D
{7 x. e5 W  @" T  P. h" s
}5 `9 {) x! |2 X9 A3 W& U* g
$ B5 W" s0 a) m! ]
int ufusr_ask_unload(void)7 N- ~( Z2 f0 |2 B8 d6 Z
{
$ k! T, u( i, x+ Q: x4 o. P, C4 r6 g    return (UF_UNLOAD_UG_TERMINATE);2 a2 \5 j- @$ `  k" T0 x! D* Z
}7 z: N  M) W* S/ Q

) I& ?$ M* k4 vvoid ufusr_cleanup(void)
; T/ H8 h6 h) ^* b# p5 c{7 ?9 i' e3 R; ?- {% v- U: m
    ECHO("NX is shutting down - running ufusr_cleanup\n");3 q$ L' R3 }  Z  M; l' R

* n% C! t* M8 I/ g: O    /* put your code here */8 D! v: e% [* r6 N
}[/mw_shl_code]9 _$ o* Q$ F+ l3 N0 x  ]- g
上海点团信息科技有限公司,承接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:491 ]. B( v, ]; x
请问这个函数是怎么用的?有什么用?

. [5 Y' A. m9 j9 @* n8 p入口函数 改成 ufusr_cleanup
  H$ L6 x% J) ?5 k. n: S7 b
, x/ |" y% O  X0 T7 ]' H0 \  F6 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二次开发专题模块培训报名开始啦

    我知道了