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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x

% w" c6 b- e; ~+ ]NX二次开发源码分享】关闭NX后,做点儿事: I  c* ?% K" Z; a

) P0 l2 a8 o7 m9 b% `# r[mw_shl_code=c,true]/*" {2 F( Q7 I$ h3 i! v

! |) b* P3 }* b. c    ufusr_ask_unload is invoked immediately following the completion of ufusr4 Z4 j# M3 n! L
    (or ufsta when the dll is run from a startup folder) to find out when you
# b4 z& J7 p4 o( m7 i    want the dll to be unloaded.  If ufusr_ask_unload returns
( n& G- S# t- B" W; i    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is. p: _4 F: n/ E; s- u6 A3 r
    unload when NX is terminating.  To prove to yourself that this works, set+ L) m. h- G" C* o: o) e3 s
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not
" d/ Q  Q9 L9 U9 V    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX
( O  w% `9 q$ e4 x! L% C4 W+ {- G. |    Log File and make a note of the full path to the syslog which will be shown
( M5 _2 f  n1 J0 }% n7 c! r; j    as its own first line.  Run the dll built from this code (nothing noticable
& v& }4 A* o% l8 f# @6 Z1 [& P    will happen.)  Exit NX.  Find the syslog and open it in any text editor to& \; A$ C0 X  x! P0 i  a1 x! ~
    see this line near the bottom:/ W7 s; D. @& k. E, E( F+ Z7 h
% u$ H4 E9 D, `; \
NX is shutting down - running ufusr_cleanup. F8 p* K- i4 R  Y1 S5 `0 I

# w& t/ {( J! M2 A*/. K, s9 l5 V8 a
#include <stdio.h>
! v& _( D7 c# j7 P#include <string.h>' g. |8 b% T! q$ P8 G" X8 u
#include <uf.h>
$ a% L5 g9 }2 |' `#include <uf_ui.h>% l# d+ Y" p3 y' a
#include <uf_exit.h>
# ?/ F& J& w" R2 U% X9 x2 _" F, e7 ?. n
9 F4 x  B$ X" o' l0 A' \% d3 G8 k#include <stdarg.h>
& K8 O2 H8 {# d- ~5 ^
9 ]/ b) u4 d8 Ustatic void ECHO(char *format, ...)
3 U7 M; s% u% G  A: `{  ^% A- R3 l) k' L- J; ^* G4 X( c9 p
    char msg[UF_UI_MAX_STRING_LEN+1];- y. x: a% Y0 N& h  Z/ [* o
    va_list args;
' W5 W7 |( q5 t/ ^/ _  {    va_start(args, format);
) z/ B, F1 f9 z    vsprintf(msg, format, args);
1 p+ s! Q$ R* @! _: Y( K    va_end(args);0 {9 v2 o8 C; ?9 p+ p( k
    UF_UI_open_listing_window();
( M; V: }$ x. Q    UF_UI_write_listing_window(msg);/ u: V5 `4 |* Q
    UF_print_syslog(msg, FALSE);
) p7 }. y+ A5 D" b0 U! E}. g6 Q# ]  N! \5 g
0 y/ V  `- E/ V
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
$ ~; ~# m) o# \( \: a
/ b& p. l! g) K, P4 u1 [static int report_error( char *file, int line, char *call, int irc)
. f; X5 [8 L% M" |( {+ I% Y{9 W) _* V+ u% i! F2 U5 a- @
    if (irc)
( u; [. _+ D3 r7 m    {
6 g& O+ m# r; F9 ^. Z& a6 K        char err[133];: P* U# c0 i. ~
: W  c7 a: f' b2 l6 q
        UF_get_fail_message(irc, err);
/ x! j, G) |/ c$ \$ D+ Q6 g        ECHO("*** ERROR code %d at line %d in %s:\n",
) e- C8 [; R) y- @            irc, line, file);5 L. m$ Z3 a3 h6 m
        ECHO("+++ %s\n", err);
9 ~" c* N$ K  U( H        ECHO("%s;\n", call);& o* t% [' [0 v$ \$ F6 h
    }0 v7 g7 F: F+ u4 u
% E% n7 G: `1 u$ X
    return(irc);
2 y6 }; u+ h$ j2 B' p' s- {8 C}, J/ U9 j: M8 b% j* l8 p
( A5 d+ b, I  |+ J* {2 j% j
/*ARGSUSED*/
/ Z6 R6 }# k6 j: {1 r  vvoid ufusr(char *param, int *reTCode, int paramLen)+ O+ l; c4 T. b4 ]! S
{
, ^. i  U0 m+ A" P  h}/ {0 A9 \5 J7 h
) J& ^+ x; H* l- v2 w% Z
/*ARGSUSED*/$ o6 _4 e6 I5 n% d& S
void ufsta(char *param, int *retcode, int paramLen)
, d+ N$ g: }4 ?( k% \{  r# [2 J: k0 k) s9 w3 H9 o
}1 O4 ^  X- j' T, l3 B. {
) t- ^' z1 l, \3 d+ G* V( r( Z8 _
int ufusr_ask_unload(void)
2 V5 V0 b, _9 O{
% g( v+ r2 e8 D  I    return (UF_UNLOAD_UG_TERMINATE);6 \4 N( y4 c; Q+ V
}
' l2 c/ c# X4 V( ]. X8 _  ]2 o) d+ ]$ R) n
void ufusr_cleanup(void)% C" j  c3 `. o! ]$ P$ S9 `
{
; _- }$ y, e1 D# I; j/ }* v    ECHO("NX is shutting down - running ufusr_cleanup\n");+ Z( @  D. e  e7 x( v

7 L$ D; m# k$ b/ o    /* put your code here */5 F% Y* L+ \( ?# \8 {
}[/mw_shl_code]  W9 |. \/ s" ^( z
上海点团信息科技有限公司,承接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, a! K8 ^, b4 `* j8 i1 O3 X2 u
请问这个函数是怎么用的?有什么用?

6 I+ g& H) Y2 A3 @9 v入口函数 改成 ufusr_cleanup
9 n! R! P/ `8 T
0 J) X1 o/ ^; l; `! |  |意思是 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二次开发专题模块培训报名开始啦

    我知道了