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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x
) K% }9 ~. S- ?$ K! Y' o/ _
NX二次开发源码分享】关闭NX后,做点儿事
$ B( o, H3 n. r. f8 l  u) p: o
, w6 _2 L; r  {0 d' _. y8 C[mw_shl_code=c,true]/*1 a' k9 f1 o6 u+ c
  n  T, F2 r. Z+ ]# b( b
    ufusr_ask_unload is invoked immediately following the completion of ufusr
1 _- b1 t7 g) @; l4 u! D8 L    (or ufsta when the dll is run from a startup folder) to find out when you7 }6 t- r! }" }
    want the dll to be unloaded.  If ufusr_ask_unload returns$ e* N5 g8 W2 j7 @0 m" g$ B, o
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
: W" @% ?2 Y( L' r6 V( A    unload when NX is terminating.  To prove to yourself that this works, set: o6 C' W( l; \/ B% j0 b3 v- j
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not
! P. m# p1 l- T. W) k8 n    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX5 v& c& Q7 Z6 C6 i0 z
    Log File and make a note of the full path to the syslog which will be shown* e5 q: a2 }; d8 P8 t  V+ L* _- c
    as its own first line.  Run the dll built from this code (nothing noticable. K2 b0 i  h/ l* g' R
    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
* l. Z$ M. X' m3 P& _+ l+ t    see this line near the bottom:. ?2 N( }1 {- g1 O8 F

8 N; x/ R% G3 U$ [' e% c- mNX is shutting down - running ufusr_cleanup
+ L6 v' U/ y7 e
  n+ ^6 b5 t' E$ Y5 M# u- y9 m*/( S7 z& h9 J, k  R) y& z5 m+ C
#include <stdio.h>/ S/ Q/ A2 e5 w  z" Q1 e; Z
#include <string.h># u0 c7 }7 D; r- ~& A
#include <uf.h>" K/ A2 R* m1 {* Z/ y* V
#include <uf_ui.h>
1 o- w( F# F# o6 U0 j8 \  [#include <uf_exit.h>% q( D' ?. o# ^3 x# o+ z

: C  ?7 o  T2 F- R; U" k- r2 P#include <stdarg.h>; |$ x. q; Y* r
* g- N+ K2 W' e9 i
static void ECHO(char *format, ...)6 u2 n6 ], d, Z$ }& t- `3 v/ S
{8 k& B: t; X- i
    char msg[UF_UI_MAX_STRING_LEN+1];
5 g  j4 }. U' _: F/ _- C# `) d    va_list args;" A3 s2 T7 H: v- E6 _2 E
    va_start(args, format);
# e& g# ?  K/ ^' \/ ]5 p$ H5 }; p    vsprintf(msg, format, args);8 K  N' u! W7 ]6 `; s: R
    va_end(args);% p4 g& _3 `9 e3 B/ r
    UF_UI_open_listing_window();
# @6 N  K5 y. L    UF_UI_write_listing_window(msg);2 y" Q0 H9 D; G  d2 y0 z
    UF_print_syslog(msg, FALSE);* r& C+ _# G9 X  F* c8 Z6 }
}
* j$ `( I; y9 U, w: U
  Q: I8 a/ w  u, k, m#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
8 j8 d% s2 A1 ]( ~: ~) ]4 X. n" p* l% W
static int report_error( char *file, int line, char *call, int irc)
- k" |5 [: m2 s0 X  {3 E! l3 \{4 f. k6 \% D8 a+ s8 l) g9 M# C& ?- b0 o
    if (irc)% Z8 M" t3 F' ?8 R; \! F
    {
, U1 a! T( l- r  [) s7 A% F* H! g  r        char err[133];  I, W# m( f6 u3 Q4 H

' q; c1 ?  n: }" N6 ], g4 k# E+ l        UF_get_fail_message(irc, err);
6 ]3 P) u- e% [        ECHO("*** ERROR code %d at line %d in %s:\n",2 [$ ~) t" m2 C% _( _- O) z
            irc, line, file);
1 T- g4 u  G2 R1 ?! t9 d        ECHO("+++ %s\n", err);
( ^4 ?. F- s( m- f4 J) R0 }        ECHO("%s;\n", call);+ B; j8 u9 C& u9 z* K9 \/ Y* o
    }
: a5 [! c' y! D. n, l; f0 L
. s" ^" F* P! x3 }+ q. @1 r    return(irc);5 I" c8 r! c$ w. c: r$ o
}
' \) d! D, s' o8 ^/ J
' s5 v' q. w' L7 y/*ARGSUSED*/; z* [2 ?3 J; T* L
void ufusr(char *param, int *reTCode, int paramLen)
, X" I) |8 \, v; q) N: P0 W5 b0 t- @{3 |+ V3 d; s4 p. q# c# O
}+ W0 T5 g! L2 x7 T
' S  |. V, w9 L5 w* P
/*ARGSUSED*/5 e7 o- B3 W( ?% Q/ x: E8 c/ N
void ufsta(char *param, int *retcode, int paramLen)
9 J1 C9 ?" Z% t{& Z: V. O$ G& G% @! L! ]
}. W. D) L8 K4 {% Y8 u" x

1 @. S2 T: J) eint ufusr_ask_unload(void)
" R+ b* x& x2 p. G. |1 e8 S3 k{  ]5 y5 A" ^8 }) H4 C) k
    return (UF_UNLOAD_UG_TERMINATE);" i& a# x5 D* _' X' d# h; S4 c
}# J* E; a  P' c7 ]# \" G

# L% \+ @3 |" \. E+ nvoid ufusr_cleanup(void)  `( a/ u! ~3 B/ e
{
9 e. U! l0 Q( z. r' y5 x' U9 D    ECHO("NX is shutting down - running ufusr_cleanup\n");
8 {* B7 I/ q4 K3 J: @3 L* s9 T( a8 \; R8 s& n. @
    /* put your code here */
; N' X& y4 n, w4 L/ u, @4 H2 s  d}[/mw_shl_code]+ O9 _4 R+ o) J( 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
6 q( q6 T" f/ r$ H请问这个函数是怎么用的?有什么用?

0 x2 V- G: \6 X: h* P入口函数 改成 ufusr_cleanup * `+ ]( x8 ~0 I- B+ F0 T' s

% v0 G% B2 W8 W4 q; y" Z% Z+ p6 e意思是 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二次开发专题模块培训报名开始啦

    我知道了