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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x

5 w% p- V" r1 f" t9 z0 i. a+ Z4 HNX二次开发源码分享】关闭NX后,做点儿事
/ R) E' V4 s( R. J: _; v
* x5 Y: ^( g- P9 K' f+ ]& Y. |[mw_shl_code=c,true]/*% w* U; [% o  w6 N4 E

1 A" d! ]/ g( [) C3 T    ufusr_ask_unload is invoked immediately following the completion of ufusr
( m4 r2 @# C2 u    (or ufsta when the dll is run from a startup folder) to find out when you; D. [0 O$ G5 Z' B! n. l# M; M
    want the dll to be unloaded.  If ufusr_ask_unload returns
6 e, c: J7 m5 h1 X; m    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is# H% ?% z& _5 j& {0 l( t
    unload when NX is terminating.  To prove to yourself that this works, set& n9 T) M$ A; u# k& J& i8 g
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not5 n) m: X6 N$ ?8 S# x8 x; _9 ^, C
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX8 N5 ^3 Z+ f9 C2 G9 I- ^; z) o
    Log File and make a note of the full path to the syslog which will be shown2 K' |( F& x: Y
    as its own first line.  Run the dll built from this code (nothing noticable
0 O: }/ z; l$ h" `* o! _    will happen.)  Exit NX.  Find the syslog and open it in any text editor to9 Z$ T+ S0 Y4 H  o2 z* f+ k
    see this line near the bottom:
! p7 ~" Q, o9 g* Z# n
; y6 m2 e! f; S3 O* ~) f) Y  [NX is shutting down - running ufusr_cleanup
4 ?8 M9 b  \$ ~- f4 z# k
' {' n0 n  a4 H" x5 P* N! n*/
, y  |& @2 {& }#include <stdio.h>3 o- S, q$ j9 Y" X. H' e
#include <string.h>
! p7 y% `: L" v( f- Q* d# I#include <uf.h>
2 t1 ?- c9 x+ O#include <uf_ui.h>; N, p/ O5 \: n' u8 {$ R
#include <uf_exit.h>
. V8 w. U( I6 ?4 O+ w. H& V: l, S4 u9 G. V+ D3 \. G+ C$ I
#include <stdarg.h>
3 I1 T8 h& u( L& _& p; N+ v. b# m  C& {1 I2 P* ~! G
static void ECHO(char *format, ...)' ^* F- }  Z# ^3 F8 G, X+ r. |
{9 ^9 c3 a5 U& C1 ^% N/ D
    char msg[UF_UI_MAX_STRING_LEN+1];' T! r' a0 {; w' [9 `. ^
    va_list args;
! x2 A  |( z# ?% r, e2 _. l    va_start(args, format);
, U1 b) O. a" v- G; ]6 o% M    vsprintf(msg, format, args);' C5 p) m) K/ H+ \% C7 z/ e/ a. q  |9 V
    va_end(args);) E% X/ x) O% G7 Q5 b
    UF_UI_open_listing_window();) P: h9 S( v6 }5 f7 r
    UF_UI_write_listing_window(msg);+ V: x/ \# {4 s7 M( w
    UF_print_syslog(msg, FALSE);
% m& c% J6 D; K}
: f2 R, ]2 {) H2 b* k
8 O1 y& Q+ l4 }% `0 H8 I1 \* X#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X))), [- p) ]5 g/ O5 O
, ?* }6 V$ L& U3 Q# j, v' J
static int report_error( char *file, int line, char *call, int irc)' t# V5 ]/ V! {3 g5 w2 ~7 T
{
' H! v1 ~. l5 [. r1 E1 {0 t7 X, W    if (irc)
6 g: \) L5 Y! U' r" k5 a$ N% T    {
, x0 _8 G) f1 t6 I        char err[133];
8 j! o( _- v8 F9 \) t
: q3 N0 E: N+ e) b7 @9 d! ~2 O( ]        UF_get_fail_message(irc, err);6 _2 R+ _8 D9 j- M7 N5 w
        ECHO("*** ERROR code %d at line %d in %s:\n",
, g4 e$ k4 Q9 u) w0 h/ l            irc, line, file);# \1 c* K$ P* L5 V
        ECHO("+++ %s\n", err);
7 r) _- Z6 s. z4 v& C' [# C        ECHO("%s;\n", call);
$ Y& b# N% m) m& I7 L+ `) r$ A    }: w! e1 K$ A' ~" L$ q  r
* c! l; G+ g% }2 s4 Z1 _
    return(irc);
8 `! A+ X$ g( f# x. l  [}6 j% `7 z$ A: }

) |8 o% d7 y1 W7 g/*ARGSUSED*/1 h$ [5 t5 W/ v$ K7 `  I6 Y
void ufusr(char *param, int *reTCode, int paramLen)
9 \/ {$ t( T1 z8 {6 R- U{
0 c! Q( X. u& F% _; o" U5 M}
. N7 _3 j  [; k- W" p5 n8 d5 Q
1 V5 m  d8 f) J/*ARGSUSED*// ?0 ]$ @; T; i$ U; }2 _
void ufsta(char *param, int *retcode, int paramLen)+ p' P6 A$ r6 y2 Z1 p) f' R
{
) p' o( S$ F6 I/ X/ ]: D+ v}7 V  P' u- ?9 F! O' Z& j( S
: x0 S$ L$ v' t+ H3 L* V/ o
int ufusr_ask_unload(void)" L5 \( V" R! o; t
{; G2 o4 `. V: ]  u
    return (UF_UNLOAD_UG_TERMINATE);
& w& K3 I/ U; e4 G}
5 r' `# r& }1 C( k3 w
6 E! D- B# ]4 u1 u; v* i& tvoid ufusr_cleanup(void)
6 _% P" z1 w, H/ ~, y: x{0 r7 [* p1 ]1 B# m
    ECHO("NX is shutting down - running ufusr_cleanup\n");2 t$ C5 K9 Q8 |% X2 _  ?

; D! G2 x6 a% G( I5 {' V) F    /* put your code here */
7 f! D" t1 @; }0 n}[/mw_shl_code]
1 r- o# I7 p$ _3 j+ Y( I/ N, 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! T% H; L& U. a6 z: p
请问这个函数是怎么用的?有什么用?

3 l! U% |3 D4 U入口函数 改成 ufusr_cleanup
5 N* }5 x3 B, f$ [1 A1 M' a: L$ I+ k% N/ [6 l$ D1 H
意思是 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二次开发专题模块培训报名开始啦

    我知道了