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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x
0 U7 {2 `4 i1 z* V
NX二次开发源码分享】关闭NX后,做点儿事" E1 }+ P6 ^8 H3 h" }; U
; N7 ]/ x1 l" _9 K
[mw_shl_code=c,true]/*
( j  |2 U+ y. `+ L, h* C
- ?" \( }  {# f    ufusr_ask_unload is invoked immediately following the completion of ufusr4 O+ W3 J% W0 f7 T5 P
    (or ufsta when the dll is run from a startup folder) to find out when you7 e; a/ I) l' D% [* d/ P
    want the dll to be unloaded.  If ufusr_ask_unload returns3 [& j1 H. O4 |4 ~6 m4 _
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is' w" l3 W+ A' ]* a
    unload when NX is terminating.  To prove to yourself that this works, set
6 n/ Y' F) Q9 L' s2 h, ^# j    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not) s# i8 \2 v: P% }
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX: d: W2 ]8 h2 r. K
    Log File and make a note of the full path to the syslog which will be shown! V& _  W& M* z* q
    as its own first line.  Run the dll built from this code (nothing noticable
4 r4 o- c" V* j- Q/ A    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
3 ]+ l6 ?0 \/ Y+ t) |  A/ i    see this line near the bottom:0 C% s7 W0 \- B0 O7 x* P

; U& T" r6 k0 V/ PNX is shutting down - running ufusr_cleanup
% B( r# {- g2 ^6 P3 M/ V! q; A; g, g$ H
*/
. Q7 l9 ~! s8 J7 {2 v' b# q6 `#include <stdio.h>
* B" K: d+ m+ [0 e, D#include <string.h>, W) J6 e9 y- G) O* Q1 {9 f/ ~
#include <uf.h>
" @" ?9 H" H  K2 c7 N6 D1 l#include <uf_ui.h>
9 u1 m, D8 @- x" z& f8 U0 f9 G#include <uf_exit.h>: ]6 L; e! |/ k7 P0 O: f
( C$ p+ J9 o. v% x+ F& Z
#include <stdarg.h>5 _: }! f6 R3 G( W2 G, y. b- N

1 n3 W0 F' T: [, rstatic void ECHO(char *format, ...)
. o! @9 e* Z: e{2 l0 O; i* ~; I4 m' h2 Z9 C
    char msg[UF_UI_MAX_STRING_LEN+1];5 ?7 `% D  ?; P5 b$ |
    va_list args;, ]% p* q1 _  x! {* }+ i
    va_start(args, format);9 g( g  {3 v: h3 U( H
    vsprintf(msg, format, args);
4 M& p0 ~( ?/ q7 J  _0 O9 G    va_end(args);
8 P* F1 A' ^4 O! z/ F8 y- }5 T5 `    UF_UI_open_listing_window();
3 Q6 l1 z5 K5 l2 b9 O  K, Z, E2 ~    UF_UI_write_listing_window(msg);
! y. p" P* a' @  g3 T) W    UF_print_syslog(msg, FALSE);
" G, S- J' `$ e1 o: s+ K" x}" Z4 a  I! k- A9 [8 g

  v' N/ c( f2 V" ^7 a, s. o6 V#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
" R9 N! X% Z* F* `) J) l4 w+ F' q4 b' s$ L) I; V6 N5 x0 z) H
static int report_error( char *file, int line, char *call, int irc)
7 r7 [5 Z8 j7 g+ z+ L2 Z* \/ i9 w{
) `/ T4 G0 c2 c* m# L' c    if (irc)
. q. h! c% a' ?4 m  X; g    {
& Z8 n+ e* {# v% Z        char err[133];
6 l- u  c, ?8 q9 n) `1 N5 Q5 w) o7 C% e; S' B. u! d1 a. N( C
        UF_get_fail_message(irc, err);+ T, R4 z7 C4 E) f/ b& w- V
        ECHO("*** ERROR code %d at line %d in %s:\n",; J1 _0 T! o4 w' ~! @
            irc, line, file);9 I' v6 L0 A# z& S1 N* e/ g
        ECHO("+++ %s\n", err);
# e6 m# ?! [6 ?! y" p! a  @% C& |        ECHO("%s;\n", call);
1 d' u8 o- h+ D' Y; `8 w9 h    }; Z5 Z2 s" |8 ?2 w" {7 T$ ^

* M1 q# w3 q; i' l+ o% z    return(irc);
. u: I9 x5 [, A7 q) I  h}" w6 _- h& W* ^2 J" ?1 w4 f

& k% T/ }7 q! E4 P% ^/*ARGSUSED*/
7 d5 E+ S/ V1 F6 c# A7 P; jvoid ufusr(char *param, int *reTCode, int paramLen)" A' _, a0 C6 q" R$ Z- ?
{
1 N5 i" y$ E) O0 L4 d}* [9 W  H* J" c) Z6 s+ k1 J

5 i0 r; X$ b3 K( S$ c; `; x! v4 c) e/*ARGSUSED*/
7 p9 u; l9 f3 ~void ufsta(char *param, int *retcode, int paramLen)
: m  c2 L( H5 |{: T2 r/ x  z# g; r; V) h# `
}
. [: X5 K5 c7 [# i0 q+ k. J& G6 M" B+ j! i  I
int ufusr_ask_unload(void)) c% @5 U7 `: l( d# i
{9 Z- i/ h6 t% w0 x/ x# e* \
    return (UF_UNLOAD_UG_TERMINATE);
& }/ G* E$ X$ p& j' |}
( \9 S/ |. E4 W* ~- O& g+ d. y6 m& o
void ufusr_cleanup(void)- B* B3 ^; `+ ?2 Y
{2 }9 q( _$ a/ }+ u# q* l" ~
    ECHO("NX is shutting down - running ufusr_cleanup\n");7 P) K/ ^8 [1 e+ ^* i" d! `# q# n
( v: q3 m5 s- F
    /* put your code here */
3 V' R) K7 |5 O+ \0 l}[/mw_shl_code]5 q6 S, }$ Q. d8 X* J0 K+ ?
上海点团信息科技有限公司,承接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
9 F  S: b% q1 o' A, }! E6 M) @请问这个函数是怎么用的?有什么用?

/ X: g+ k5 r5 a入口函数 改成 ufusr_cleanup 2 |5 y7 P* V  }1 E7 V  O$ \: I" Q
5 f, S% B! e: q0 O1 ^: j; J' S6 s
意思是 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二次开发专题模块培训报名开始啦

    我知道了