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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x
7 w- z% w" [+ U: _8 Z
NX二次开发源码分享】关闭NX后,做点儿事
# S" }7 }% R2 y/ `4 W' ]6 S' }% F/ z2 G- T. e
[mw_shl_code=c,true]/*5 X7 K& K# X) ]) z$ Y/ x

6 W' F' |, g. k5 z    ufusr_ask_unload is invoked immediately following the completion of ufusr5 ^. m+ G0 J" u# N
    (or ufsta when the dll is run from a startup folder) to find out when you2 E3 s4 L- q) M
    want the dll to be unloaded.  If ufusr_ask_unload returns
6 Y: t- V. m) M0 u    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
" e8 S: \; h2 @% z0 O9 Q    unload when NX is terminating.  To prove to yourself that this works, set3 u; z6 C. \1 Y, n
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not, L7 f4 c* D1 }( ^# l# ^$ \/ @
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX
0 n. N7 Y4 v% O2 v$ \7 z2 y  r    Log File and make a note of the full path to the syslog which will be shown
& v3 \! p7 z9 _; s, j* H/ ]- \    as its own first line.  Run the dll built from this code (nothing noticable
+ w# Q7 U; H8 z) h    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
; U" A5 g% Q& m7 ^2 U    see this line near the bottom:
+ Y4 z3 `* T' i5 d$ d! j1 C: m" U0 U. |
NX is shutting down - running ufusr_cleanup
# P8 g0 W2 m# [6 H0 [' y( A" X3 ~$ u( h: p
*/
5 l7 Q6 _2 z  v; \0 U% B/ j$ K#include <stdio.h>
# v5 [& c2 }/ o2 k#include <string.h>6 V; Q7 Y, o) V. ]0 @
#include <uf.h>
# \4 j4 B0 A% w$ C6 q5 E3 v#include <uf_ui.h>2 g% z7 k" j, g" i
#include <uf_exit.h>1 O# u; T8 \3 i( x9 g  Y

% _1 z( Y8 |- i+ p- q" Z% @$ T#include <stdarg.h>0 K9 b! S: g. R  s+ ?
, V! Q/ {7 x& Q
static void ECHO(char *format, ...). p% J0 w9 `& H& F( m3 k
{2 }) d9 A  s" g+ l7 ?, J
    char msg[UF_UI_MAX_STRING_LEN+1];% z+ Q$ Y/ k1 i, }
    va_list args;
6 ^" c& G* A; V+ a$ R( h    va_start(args, format);
+ l$ I+ ?5 L/ F    vsprintf(msg, format, args);9 Z3 l3 R9 c6 M5 x+ b# P6 K5 G
    va_end(args);
# O* O$ z' g) x- b, y- ~    UF_UI_open_listing_window();& }# S7 ~0 f" x; d
    UF_UI_write_listing_window(msg);
5 l- b6 i$ z1 V8 O: F: o' {    UF_print_syslog(msg, FALSE);
$ P7 [( @- j& @3 _0 [3 `; s}
+ B/ _5 q' ]- [- y; {4 D2 |2 o# @4 F- v: Z7 Z  Z6 P, T
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X))); Y/ |7 b5 r% y2 O& y' f9 A& I

2 T; E% a/ T$ z6 b  a' pstatic int report_error( char *file, int line, char *call, int irc)2 {- Z8 _  T2 v6 W
{7 C4 v" ~4 x( j* M  D  V
    if (irc). K- [2 i) g! p* e
    {' m4 d  B! c% X" D- `! H5 b
        char err[133];1 ~6 M' q, i- V. y. g) e
  z8 }. T0 V: Q8 |" T1 u
        UF_get_fail_message(irc, err);3 O: F- \+ z* M  v5 S5 a  z( w
        ECHO("*** ERROR code %d at line %d in %s:\n",9 \% Q. p1 C8 ]" {( L
            irc, line, file);
* b( K6 V" Q+ w" N        ECHO("+++ %s\n", err);9 z( s+ l: Y; V2 n1 e
        ECHO("%s;\n", call);
2 L- q) W, g$ B( P    }9 f4 z8 ~5 j0 {4 s& G

9 {4 c. P6 P. D, b% B  z    return(irc);2 s* b5 l% v/ w6 t- H
}
$ B* U/ N' K( g/ t( ~8 g& M, D) V1 X1 Z4 t, [' s% r) r8 M
/*ARGSUSED*/* N" X: D/ u- R6 Q3 J
void ufusr(char *param, int *reTCode, int paramLen)
! c% q+ B8 H, `' }$ ~  S9 ], j8 U{8 A0 q. r& J2 f7 `$ T7 ^4 m1 O. `
}/ I  s' r7 ~% S
% l5 M3 N% e2 h/ l( r2 h
/*ARGSUSED*/1 A3 _- ]/ ~$ ~6 J9 `6 p
void ufsta(char *param, int *retcode, int paramLen)& T8 |4 m' O- E+ b6 A
{- u$ i5 ^8 W% Y/ V. n
}
/ ^4 q1 W  r) f5 x6 i& Q7 U! p8 _0 ~5 w0 p: u
int ufusr_ask_unload(void)
7 b4 w9 q* m! R0 @% n$ y9 |! S{
4 Z# B. k6 V# H6 R; ]# w    return (UF_UNLOAD_UG_TERMINATE);
4 p! {" q. l: B0 m7 W( j}
3 w9 Y( I2 O% X4 V, f9 W9 t1 Q' ]. Z9 T3 f& \# \
void ufusr_cleanup(void)9 C  C# ~: C+ I. ]$ v9 P. g4 T
{. Z$ h9 i3 s+ G- M% k
    ECHO("NX is shutting down - running ufusr_cleanup\n");
5 {; f0 R6 A0 V$ Y6 P) ?. O$ z) t! l
    /* put your code here */2 b/ l& \5 o) O! o$ f+ T
}[/mw_shl_code]5 ]: \$ {! V9 V0 ?. n
上海点团信息科技有限公司,承接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$ m: e7 S6 L4 f% S
请问这个函数是怎么用的?有什么用?
' w3 Z8 H6 e& [: ^: n4 X
入口函数 改成 ufusr_cleanup
, L4 _0 p7 K% v  V1 I2 O. O' M4 L: {: m5 [8 _' W9 d
意思是 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二次开发专题模块培训报名开始啦

    我知道了