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

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

  [复制链接]

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

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

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

x

* ?* y# G" i' hNX二次开发源码分享】关闭NX后,做点儿事
/ f# x! S& m- ~; }& G9 o* u9 p' X7 I
[mw_shl_code=c,true]/*4 w+ l: I' B$ p
  z6 t4 V8 m6 V; i. t9 L. u, s. U4 e
    ufusr_ask_unload is invoked immediately following the completion of ufusr. @9 H8 R/ V2 [) {& C5 p: T9 U
    (or ufsta when the dll is run from a startup folder) to find out when you
# `$ O3 C8 ~, x& Q+ M: D/ Q    want the dll to be unloaded.  If ufusr_ask_unload returns/ D- V) V) T8 P2 m' l, f
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is+ L8 p3 t- Q$ g; q3 \+ a: s
    unload when NX is terminating.  To prove to yourself that this works, set
' s' P6 b6 M# M/ }9 `    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not
$ o( P: X5 V- g3 `. S/ B3 ?: k    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX9 W. [4 V4 N# Q# {' R2 _+ k
    Log File and make a note of the full path to the syslog which will be shown
9 v+ `0 J& `% R) m4 H    as its own first line.  Run the dll built from this code (nothing noticable
2 X: O( N- U1 H& x/ K7 ?8 y7 O+ O; m    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
0 n: {3 F! G- S. O# o    see this line near the bottom:, s- Z, U' i3 j) U3 G& H4 ^

) d, X* \: k, Z7 _1 ENX is shutting down - running ufusr_cleanup
& d/ u+ ?, v" T, V0 ]1 k, K) \$ L; U. ?
*/
8 l6 w  {' Q8 D3 F! C3 d8 H1 g0 R#include <stdio.h>
! T/ T( m9 r4 {  x2 H% W#include <string.h>
5 P6 ?) ^- y! _- S" ~% s. s; H#include <uf.h>
  b* C3 a6 h  b1 M3 G! S#include <uf_ui.h>4 i: l- i. E2 S- H/ z! e) {
#include <uf_exit.h>
5 ?$ r. e4 R4 f$ P7 b% l6 P9 X6 s! _. X
#include <stdarg.h>
0 s  S* A* M1 }  i% \: u4 s9 {* R* C0 {. L! _  b- ~, g% F
static void ECHO(char *format, ...)
+ X: s1 F; a& E; @) ]  s{6 x/ n1 @  `; o6 r- A+ j
    char msg[UF_UI_MAX_STRING_LEN+1];
: b. y8 i9 x* Z, m    va_list args;5 f+ ^9 l2 W  o' t2 H
    va_start(args, format);8 ?# B, G' \+ y5 @" K
    vsprintf(msg, format, args);! Y4 B; v9 h( T7 |4 H7 v
    va_end(args);" {9 [3 ?- ^  s) j& T4 L# l2 c6 I: X) \
    UF_UI_open_listing_window();2 p: q) l) e! I3 |. J  U
    UF_UI_write_listing_window(msg);
* a, X8 T3 \% P4 x. r3 l  U    UF_print_syslog(msg, FALSE);
  U& D7 _: F) b: M% s}
4 o( h3 p0 `. y; h0 l% I  U$ {. t: f/ {9 K1 b+ }
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))3 T! n8 ]3 p& I

. Q. ]4 k9 w: O) vstatic int report_error( char *file, int line, char *call, int irc)  U0 H4 D! q4 c$ _' ~6 w! _
{
8 U( z# h" O, l2 r    if (irc)/ J5 b. e5 A  E* h3 y
    {
, s, \1 u" K+ |% i5 }& L        char err[133];; d1 b4 i' i+ Y" w+ [! G' e
( \' a. I5 G4 j0 S1 v
        UF_get_fail_message(irc, err);5 n) ^8 h$ i. i% @  N* }
        ECHO("*** ERROR code %d at line %d in %s:\n",
  t3 c* Q7 U: F            irc, line, file);: H1 K6 |* l0 c: A
        ECHO("+++ %s\n", err);. R, A3 U+ t! L( z: S
        ECHO("%s;\n", call);
- {  l/ ^' S/ A$ X4 ^$ c8 z4 \    }
. ?& O' F) a$ W
2 `# c  M$ I. ]* X    return(irc);
  x+ Y, q3 V: [/ H: @}
! i7 b5 I: u7 M) _+ |( M
& h7 l* R/ r6 L/*ARGSUSED*/
9 M% G4 C' R+ t' |9 Avoid ufusr(char *param, int *reTCode, int paramLen)4 t6 z* O7 X5 [3 T" U
{
  p5 H& t4 @: p" O# l}( |: y! k- J$ }9 l

! Q' V) r* ^# L( R- u( _/*ARGSUSED*/) `9 s% ]$ E; w; m
void ufsta(char *param, int *retcode, int paramLen)
6 S0 ~4 I0 _, N0 w* ~2 S{
; q( G# t1 W4 O: A2 c}5 K' m8 |0 ^6 L4 g0 j

9 l# q+ q9 ?: ^3 h0 iint ufusr_ask_unload(void)
6 ]/ b/ Y+ j3 R5 D: \{
. G9 |8 i! p& b2 j5 Y- D    return (UF_UNLOAD_UG_TERMINATE);
+ a1 }. S. l& y# H}
  q) v& w1 _3 P1 B4 i
* s# ?7 p4 P2 i. T# d6 i) dvoid ufusr_cleanup(void)
1 a* h2 l. v! Z$ T  {$ j% i4 R{
6 s1 R7 A2 R1 e& D7 U7 p3 |1 u4 s    ECHO("NX is shutting down - running ufusr_cleanup\n");1 D; `9 w+ D9 H% ~
0 N/ H. y" P  q9 B& g
    /* put your code here */
; P0 H0 W( b( ]$ T}[/mw_shl_code]
+ B* a6 o( N7 g: S/ g- Z$ R! f
上海点团信息科技有限公司,承接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 e7 ^$ x& W6 X( n3 l; R0 N- u; l请问这个函数是怎么用的?有什么用?
% K1 ?  Z' ?! X; U; ]
入口函数 改成 ufusr_cleanup
. D6 `* Y( U( c+ ~% o4 y
% J1 }- u6 Q  _  y$ 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二次开发专题模块培训报名开始啦

    我知道了