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

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

  [复制链接]

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

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

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

x

& l0 `/ x1 |" TNX二次开发源码分享】关闭NX后,做点儿事
1 j1 b. c) G. {
  E) a+ N) X/ @* E- D& G[mw_shl_code=c,true]/*5 ~8 q: ~* e% G
% e, `8 A3 c. }8 j: H$ m( u
    ufusr_ask_unload is invoked immediately following the completion of ufusr: w  l1 Y; t6 p' {. c
    (or ufsta when the dll is run from a startup folder) to find out when you' y5 [4 R# ?3 |8 f
    want the dll to be unloaded.  If ufusr_ask_unload returns
( O; o- g" c( Z$ {4 ~$ w8 k: C3 u    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
! h" l3 |( e5 C2 q6 D    unload when NX is terminating.  To prove to yourself that this works, set& V2 z# _+ e/ Y0 y1 ~; i3 i
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not6 K* \' ]  a( K4 `# ?+ ]
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX* a, S& k0 C4 s, U
    Log File and make a note of the full path to the syslog which will be shown" m7 a9 P* P: a  X
    as its own first line.  Run the dll built from this code (nothing noticable; j# Y' O5 w6 u6 V
    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
$ \+ ~4 f, z. z4 B/ o/ m" B/ k    see this line near the bottom:% a% C: s) s" r( [) R
# a0 g7 Q+ T* \6 H1 }
NX is shutting down - running ufusr_cleanup/ U5 ]8 R9 i$ t5 x$ t9 h5 @. O; M1 O2 Z

$ z5 B% A, T$ B; a9 a*/: `* ], N0 y  h$ Z
#include <stdio.h>1 `' l1 S, l$ Y; m
#include <string.h>) Y! Q& S9 ]4 `8 g" b
#include <uf.h>
1 S: G) }7 N. r  W9 A; h8 L3 b#include <uf_ui.h>
( |. f2 h+ L& B% d#include <uf_exit.h>. l+ ^3 T1 S1 A' l
1 j+ h. i+ \) q( z2 x8 ^
#include <stdarg.h>
( {% y& A1 y- p% ^- D/ q( @! a- p+ U9 O* T% {+ g4 \! ^4 @
static void ECHO(char *format, ...)
# F$ s3 I! m! h8 @{
3 ?0 h5 c6 C5 M2 r5 F    char msg[UF_UI_MAX_STRING_LEN+1];! k0 ^/ X  P5 T- J9 I
    va_list args;. S; h2 r, q( q2 j1 [) m8 U
    va_start(args, format);( s0 T* P& Z; H7 ?4 o: a  E" ]
    vsprintf(msg, format, args);7 S4 e- X9 l# I- u8 N
    va_end(args);3 n$ o" X) ^% w: w+ p( |
    UF_UI_open_listing_window();+ J- J, `; w% |. [4 k3 [
    UF_UI_write_listing_window(msg);
. w5 o; O( {8 i9 @; w+ F    UF_print_syslog(msg, FALSE);
' y( A- o- E7 H}& J: q( O! ?" v) X' k
. x( \3 i( c( }, G) I& Y
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
  O1 I0 ~; o% V) i% J/ @9 O7 N3 r) h4 B$ p" B
static int report_error( char *file, int line, char *call, int irc). K8 i( z/ X9 G
{
. s' I$ ~6 G1 f+ p# K    if (irc)9 Q7 x& S  d% S5 m5 T
    {% U) a# B: ^' M9 M: B' s8 l
        char err[133];- ]+ o: |. v: N; I% |8 ~

# h+ l) R7 \4 Y1 [* X( L+ }; f        UF_get_fail_message(irc, err);: P, w4 W' a$ s% h
        ECHO("*** ERROR code %d at line %d in %s:\n",
7 r! F2 K$ t6 K, X- D! t8 \8 E& U% `            irc, line, file);
4 q% ^. e3 }8 z) I; M# E3 a6 ?3 {        ECHO("+++ %s\n", err);, [, h( l  W. y6 p; A6 H
        ECHO("%s;\n", call);
5 `) `) P5 M! R, F    }
2 h4 J: F1 c, S/ P( g& f8 N* ^/ g! T2 a) ]7 Z+ Y5 J
    return(irc);
5 G7 J9 g, {+ g5 Z( v}" t" K. ]! F! w  o9 M

( {# m% r5 Q# z) n/*ARGSUSED*/; u9 K/ h4 A) |$ Y
void ufusr(char *param, int *reTCode, int paramLen)
+ O4 S: ~1 F% g1 ?{+ f# B1 g  L' A6 w1 {
}2 @6 L5 f; J/ F, w/ b4 c, D. E
; ~3 A7 h6 c+ c8 Y
/*ARGSUSED*/0 n3 ^, Q0 W' M3 s# D( k1 D6 W! I
void ufsta(char *param, int *retcode, int paramLen)* n5 q, s5 u" u" w, x" j$ Y- m- W7 O) ]
{/ O0 g8 J  l% x0 N. J
}
% k; H3 r, J( e3 i+ w8 V% q9 l/ B$ R1 c1 J( R( L& r; k& j0 T
int ufusr_ask_unload(void)3 k9 I2 o, l: [; |; b3 S9 x) {
{
$ E. @1 [5 m1 D: U/ f    return (UF_UNLOAD_UG_TERMINATE);  r( h8 ^3 t3 U/ A1 \3 K/ C, @
}
/ s- k9 x+ f: I; D0 e7 x$ J
+ O% h: l8 r( Bvoid ufusr_cleanup(void)
/ |5 u  u( A& o0 x: I{6 k: e. s* z% k. C
    ECHO("NX is shutting down - running ufusr_cleanup\n");% K7 \+ u0 a9 y* H5 P* O6 o0 g

& k, m+ d1 T- [& ]& D    /* put your code here */% o/ f  a, Q. H# E- e9 t4 Y8 U: I
}[/mw_shl_code]/ v" o2 R3 _* |) |! U
上海点团信息科技有限公司,承接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: W9 f7 J4 {. f' b" |2 G" ^: [0 g
请问这个函数是怎么用的?有什么用?

, I" v+ {! X" J8 F% ?3 J; g入口函数 改成 ufusr_cleanup 5 i' O) F3 {7 g" r
7 N% }4 l. @" I: }* x+ Q, K
意思是 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二次开发专题模块培训报名开始啦

    我知道了