PLM之家PLMHome-国产软件践行者

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x
' {! M& _/ }; I1 r) W# V
NX二次开发源码分享】关闭NX后,做点儿事7 B: ~) O  [/ J$ Y9 l8 \( t

1 ^, C7 n; Z6 B0 r; B" V9 ~[mw_shl_code=c,true]/*7 H2 U# u" T$ ^
! c2 L+ E1 B* g5 ~+ }; @+ c* ?
    ufusr_ask_unload is invoked immediately following the completion of ufusr
* ^/ V! d) V7 m6 C* V5 d- _% t    (or ufsta when the dll is run from a startup folder) to find out when you
% L  \" I5 C) k/ H! T    want the dll to be unloaded.  If ufusr_ask_unload returns
2 Y7 t! X" k8 X6 u* r    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is, H4 b  v" S7 q  Q- [: d; Q2 P
    unload when NX is terminating.  To prove to yourself that this works, set. I9 k8 @! b/ `& n! l
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not9 s5 Y; L% p0 Q% n  O- y* {; @
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX
# U) v1 i1 ]  u4 w4 i/ B    Log File and make a note of the full path to the syslog which will be shown0 k8 r$ S: \& Q5 d8 `" A! \
    as its own first line.  Run the dll built from this code (nothing noticable
. x" [, m3 p: [0 b  `    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
7 Y2 u7 S6 k0 k7 e    see this line near the bottom:7 R: p) C. ], G. L% S) {9 w! l/ f% T1 A

* R& @1 u, {$ t% s  X& hNX is shutting down - running ufusr_cleanup
8 g4 B2 Y' u7 [$ x+ j' x! ^" c* r% X$ q
*/
0 r! L5 R& f' @& K2 e#include <stdio.h>
, k/ G3 A$ U8 `) H2 n#include <string.h>
7 W5 {2 I  z6 ^$ K/ P; Q. S3 G#include <uf.h>/ ?! }( U" S4 G" _" Q+ R
#include <uf_ui.h>) v+ V, C0 {4 m, m
#include <uf_exit.h>( A, ^! x  z# W' Q

) f$ F5 [1 D8 {& a) u+ P4 ?#include <stdarg.h>9 U! R0 F4 z* [) y

! ~" z5 \, F# z5 {# ]! Y& ~static void ECHO(char *format, ...)5 V6 e# y4 g. B8 [
{
# ?  _- a! |6 @# g2 M' U3 x# w    char msg[UF_UI_MAX_STRING_LEN+1];
0 V( s& z  j; [- r+ l    va_list args;
# }2 b: r8 x0 v$ ^+ z! j' u6 @    va_start(args, format);
$ `" z; t4 [- P    vsprintf(msg, format, args);& P$ z. S; O, l4 P! ?  {4 X5 X
    va_end(args);
' c- ]+ u7 ]. D$ k    UF_UI_open_listing_window();
# D8 E9 O2 M8 b. Y# y! r" ~- v    UF_UI_write_listing_window(msg);: k& I4 Z3 t5 I! t, f  ?/ ^
    UF_print_syslog(msg, FALSE);$ ~5 V" H5 P* V! Y( X6 _9 P: x! @" V
}
7 P2 y9 Y! Z9 L( d0 c1 ~
1 R$ j3 {" N8 d9 ]. n#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X))): ]/ C; S+ t. I1 K3 z( g( {, d
. G+ B4 B- i5 P( ^' }3 D
static int report_error( char *file, int line, char *call, int irc)7 \0 g0 }5 W( y$ j" G
{
9 A" M2 }# |# s5 }. R4 s    if (irc). ^+ ^6 \2 U: j: F  y/ W( p
    {/ v% l  _6 `) v* A. k
        char err[133];1 }" J4 \5 q9 c

2 @. f1 ?# l) M, L2 y        UF_get_fail_message(irc, err);
* X" @  U# z* g1 `0 Q3 W( l        ECHO("*** ERROR code %d at line %d in %s:\n",
& O, D. \6 T( Q            irc, line, file);! r5 A/ e; W5 F5 A$ O/ l
        ECHO("+++ %s\n", err);
3 M" k" |6 p9 [8 K        ECHO("%s;\n", call);5 d! _0 V; ?( d1 L
    }
  P1 u/ K, t7 A9 s$ z: q" n: T& i% E3 d; s
    return(irc);" O- v1 C, I% {
}6 t: ~2 `; P" W; E* k

6 f4 E5 s# O& H3 {) C2 W/*ARGSUSED*/7 i' X8 y; c* [- H
void ufusr(char *param, int *reTCode, int paramLen)3 W, [( ?; @7 m# A/ ~/ }
{
  u) w0 u' P3 {# D7 f}
; O+ Q9 O* b4 H" W* ?
! R8 i# U! G$ b; {$ L/*ARGSUSED*/, h- Y) t* x+ a
void ufsta(char *param, int *retcode, int paramLen)/ Q* T5 t; n$ ]
{& _# h% J5 P! `0 X0 I5 C
}
. r# `! q8 B; k; L' ^, r
2 k5 B' U9 E0 E  [5 vint ufusr_ask_unload(void); L% C# W2 q  p# W' L- J! r, X
{2 o6 x( U2 ~) D' @
    return (UF_UNLOAD_UG_TERMINATE);
0 {# |$ g2 D& B+ M6 n% F9 H}; P2 U" ~* g0 ~0 t4 z% F

, F3 W$ j& a2 ^6 D+ b7 Q! s; Y) }* Rvoid ufusr_cleanup(void)8 q, T5 K1 W6 S: p' b+ b
{
4 m0 d" h- h% v7 ^, I' b7 J    ECHO("NX is shutting down - running ufusr_cleanup\n");) c" r- [8 L2 D4 x! A
+ ~9 \7 p# _9 q8 _8 B  o, G5 T6 p
    /* put your code here */
0 N' o; M- `2 C9 ?1 t9 j5 u}[/mw_shl_code]$ n, _. _6 P6 O2 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
. f' e/ Z* d( ~- i: `4 j2 ~& c  o请问这个函数是怎么用的?有什么用?

# T  \: U- I' Z9 x% t入口函数 改成 ufusr_cleanup / i% p) l" v% k+ m
# O9 _" c$ v* S7 C8 d% F
意思是 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二次开发专题模块培训报名开始啦

    我知道了