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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x

4 @+ U! X" `. _; i1 x& GNX二次开发源码分享】关闭NX后,做点儿事! I8 C# \2 ?2 R  T- _7 W- l
; L: L0 F7 h; \3 q, I: N7 v
[mw_shl_code=c,true]/*
$ b3 U4 t* D; X6 H1 o1 G$ r) ]9 Q* |
    ufusr_ask_unload is invoked immediately following the completion of ufusr+ p$ d" z( ?3 W' S  Z- y  I0 J0 r4 V
    (or ufsta when the dll is run from a startup folder) to find out when you4 a  |) s- y8 ?' n3 i/ U4 t7 h4 }8 O$ F
    want the dll to be unloaded.  If ufusr_ask_unload returns
. ?; m3 C* I2 f0 M0 W0 k% H    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is( M, o5 Y1 W  ?& b7 B6 N  t
    unload when NX is terminating.  To prove to yourself that this works, set% [9 A; D$ ~# }+ W& r* e
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not- }/ i/ g* B# v* x
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX
, J% \  @) \! q    Log File and make a note of the full path to the syslog which will be shown
5 c+ y" L8 \# r, ?7 g    as its own first line.  Run the dll built from this code (nothing noticable
( U7 p9 ?+ X# h- A+ Z    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
: B5 d  E6 t/ R. V    see this line near the bottom:  H, z9 x. v. O; _( X

' X7 E6 x3 H! U( h/ X1 \NX is shutting down - running ufusr_cleanup! K/ R$ k* P) z
% L+ e+ T0 m- Q5 t+ H% q3 `+ R
*/, e+ q4 Q1 F+ N. q3 }8 b
#include <stdio.h>7 t% x. K! I* g% M
#include <string.h>
0 p& F! `: O( o5 m#include <uf.h>
2 D1 @9 C* ]! R1 C0 i  I2 S( }9 `$ E#include <uf_ui.h>
7 p+ z4 R- |9 J9 }  b& P2 |) e#include <uf_exit.h>* h- W8 S( @" A5 _2 ~  e
' `( |& `* X* t8 {( Y
#include <stdarg.h>7 d" ?3 I! X7 r7 [% Y' x
2 ~* G9 P/ b5 y& n; |
static void ECHO(char *format, ...): c- M: T. _9 u
{: C* h& y( V* V# i. P7 m1 x
    char msg[UF_UI_MAX_STRING_LEN+1];, q+ |. J. p9 b
    va_list args;* R3 r7 }7 t& B2 u* K8 @7 ?
    va_start(args, format);+ Q7 R) a1 r$ H  I" p$ s9 I4 `
    vsprintf(msg, format, args);
; N% I" ~& ^( U    va_end(args);
; g% u6 t5 m4 S2 k& W8 f    UF_UI_open_listing_window();
( P+ |9 @* {3 e1 ~    UF_UI_write_listing_window(msg);
. Z% V% L" E  o( ?, N0 y: @    UF_print_syslog(msg, FALSE);7 g4 E- @$ M1 c( F$ e7 D
}
8 G' T; W( F$ x/ y2 w" ?, d+ s3 s% h& x8 \/ H+ E
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))- A2 N* @9 b% V- _% T* z

1 |" ?; c6 c; G3 E1 R+ j/ \! s+ \static int report_error( char *file, int line, char *call, int irc)# w% |% |7 G& O+ c. W
{9 m  M+ _  F1 r4 s+ T
    if (irc)4 W5 D$ n0 [5 s, U
    {# \0 P7 N  Z0 a7 o  W
        char err[133];5 j. q) S% T% J/ |. \/ B! a
7 M1 v3 }8 D5 |0 C- X
        UF_get_fail_message(irc, err);7 i. a, X% {3 b4 m. v2 M& R* p; k
        ECHO("*** ERROR code %d at line %d in %s:\n",
3 X7 c# D$ L* ]' z. C            irc, line, file);2 b$ d" G# w, j$ b$ |% W5 y# ?
        ECHO("+++ %s\n", err);
' H9 D0 E' Y3 l( W        ECHO("%s;\n", call);
. |: V/ S: @  v, M  n4 y) R4 h    }& `5 R; U- S: O5 g

: E" d1 n1 w% A    return(irc);
/ c# e& n& w; s}
: f+ u2 z' I8 o  I1 i* [3 p5 D/ |
/*ARGSUSED*/4 w) g* ^/ H$ h5 n& Y9 u, Y
void ufusr(char *param, int *reTCode, int paramLen)
2 S) z0 E# o6 n- \  V{, i4 z& d3 t' X7 W
}
8 W/ S" a9 m% _: B3 u% m  ]' p" q4 M
/*ARGSUSED*/* M& Y' @& O) i; S. L
void ufsta(char *param, int *retcode, int paramLen)
& l2 L. Y6 ~' ~8 v$ Q{
* I/ n0 g% ^; s0 P- d. X}
/ _* y1 v0 z0 X8 D: b$ b
- u# {& S) O& t' H. \8 F6 Kint ufusr_ask_unload(void)% ]% R! _: a/ B& _9 ^: m2 D3 o
{
" R" Q, B/ i: Z9 ~    return (UF_UNLOAD_UG_TERMINATE);
6 C0 y$ e8 N* R) r7 j}) p4 N9 x* g* M: {3 A) q

+ d, ~- y* s+ h& k: Xvoid ufusr_cleanup(void)2 N' r# ^% U) Q5 Y  U. z) v5 i8 m/ R
{9 X+ O+ X) |, D- D2 u( h* m7 h9 K
    ECHO("NX is shutting down - running ufusr_cleanup\n");2 q( ?. F& J- R! J& X
# U" l" B* f6 z
    /* put your code here */
1 O1 ^3 s& D% y+ F: l}[/mw_shl_code]* x: x5 ?# {7 G* ~' p  l0 ?
上海点团信息科技有限公司,承接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:491 A& t( n9 j$ ~9 `" ]
请问这个函数是怎么用的?有什么用?
4 k. Z# b# y4 j* K0 f$ s7 E6 z1 h
入口函数 改成 ufusr_cleanup
6 r2 _3 F; v0 _* H' o* f# M+ ]( G  k7 ?7 Z, ]' ~' C' F9 g9 `
意思是 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二次开发专题模块培训报名开始啦

    我知道了