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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x
- i  q4 L% H& }6 m
NX二次开发源码分享】关闭NX后,做点儿事
3 w2 s6 A; U- n% A
7 g5 [6 ], d. j4 V4 d- T[mw_shl_code=c,true]/*3 W. |  U2 F6 d; K+ g8 H6 N
6 L/ |- O# }2 J3 V5 c. v* `
    ufusr_ask_unload is invoked immediately following the completion of ufusr$ e8 ^) D! R, Q
    (or ufsta when the dll is run from a startup folder) to find out when you
: d: P# J- [! m$ u    want the dll to be unloaded.  If ufusr_ask_unload returns
( @; V/ ^$ E. X: s: F" c  b- s3 I! l    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
, h% w+ f8 H! R. |6 H+ U    unload when NX is terminating.  To prove to yourself that this works, set
: @5 `+ w1 q- t% s+ H- p  A7 ^    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not1 r: Z- j+ r3 R' V
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX  y+ A2 k2 j/ l8 Z* Y1 y7 B
    Log File and make a note of the full path to the syslog which will be shown
2 C% S0 p- w7 g    as its own first line.  Run the dll built from this code (nothing noticable
% F9 J* a2 W  }6 e  f' O8 Y! s    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
- i7 U$ W& \0 y    see this line near the bottom:- s6 D6 f. ~" @4 v

/ f( b: f; n4 z1 [NX is shutting down - running ufusr_cleanup% o7 X) `1 j' s3 w. i
' I* ^3 D& l. |; ^7 L( ~
*/
5 A" w/ H9 G4 D0 W8 n#include <stdio.h>
/ V3 z, j4 x+ B& J4 x( j#include <string.h>
' D& x$ m) X& ~6 [#include <uf.h>' o" u' B9 Q7 U  H
#include <uf_ui.h>
4 _3 Y& ^) \7 \, I/ c  I#include <uf_exit.h>4 H& q8 q% I9 r
; [) y/ v6 n5 a. c0 X6 L7 j
#include <stdarg.h>
$ P  T( W9 q3 Y' T1 r
* K6 A2 o" {" v5 Istatic void ECHO(char *format, ...)
1 [. o# [# `- M4 \3 K7 n8 y7 r{
' \) y6 L# ^% v8 K6 R/ Y    char msg[UF_UI_MAX_STRING_LEN+1];
# l" E& y. P7 l; H* j/ G    va_list args;6 t% f; J% r8 v5 h
    va_start(args, format);
/ l0 D+ h  e" F% Q7 P$ _8 f    vsprintf(msg, format, args);# ~$ e% j& i. ]* C" F) V, x: D
    va_end(args);$ h$ P- g: d5 @- D4 A
    UF_UI_open_listing_window();
! e+ V( l! Q2 O/ N    UF_UI_write_listing_window(msg);
0 H, i4 K2 M) c    UF_print_syslog(msg, FALSE);3 {- \& C8 x& S+ \" @) m' j% e
}  I! U) f7 P* G7 v; y2 T+ M
4 C. _& I" c+ G" T
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))  l! m5 v6 m# m* L4 _( U: x% n
' Z: I' R! a- _2 _
static int report_error( char *file, int line, char *call, int irc)3 c: E2 N; Z3 n
{) m6 S7 c! I: {/ ~3 n: `
    if (irc)
+ A: I) l; I, t    {! _/ J& ~  m) c" b" S- ?' C
        char err[133];
/ s0 O" ?. y* Z2 m" r
, w, K4 J( B# Q        UF_get_fail_message(irc, err);
0 i* ~" d+ B, f4 s6 c& f2 {        ECHO("*** ERROR code %d at line %d in %s:\n",
) y. X8 K0 k: X2 ~/ ?- p  n% g            irc, line, file);
- `2 c# l* j% {7 p5 C; c        ECHO("+++ %s\n", err);
+ X+ D6 s: ?  L. D3 U1 ^/ T6 V        ECHO("%s;\n", call);; ^/ f$ n. [! N6 D. q4 b
    }# r( e8 J# D) {3 m5 j0 k
! h* ?* H' o, p* G+ F2 c
    return(irc);& a0 ^  N( i  s. E, J  @
}2 t3 h( [6 d8 }* \" F

4 j3 X# W: W* L8 M2 S+ e- w2 y/*ARGSUSED*/
2 @) w' H! W: n* Z7 _. u" Uvoid ufusr(char *param, int *reTCode, int paramLen)
: e/ u8 ^* J1 [; F* b0 M  z% @0 }{/ `5 \( |$ n2 N; {9 f. U8 t$ A
}, X/ F! ?5 k2 Z9 b( f- j( y6 K1 g
7 m& }" z% V5 X6 F! M% D3 G
/*ARGSUSED*/
: o5 v1 V& L; K3 H) V7 ivoid ufsta(char *param, int *retcode, int paramLen)
: M' h: M& I$ v3 g) I$ F' L{0 _1 Q1 w; K! D8 }+ X& L: Y
}
0 T0 b* y2 F/ t/ d" N$ j" q' p$ R
int ufusr_ask_unload(void); R1 j, i, l* @  n4 L0 m( j
{$ y% t0 i' A" N" `$ m$ S$ Y4 `( B
    return (UF_UNLOAD_UG_TERMINATE);
5 ^/ x& e7 v- U1 }0 m}
7 U4 c* p5 m0 T$ V$ a8 v* x
  p$ ^, C: p, bvoid ufusr_cleanup(void)
/ v9 B1 u8 w! ~  E{$ g& Y; S" [+ M
    ECHO("NX is shutting down - running ufusr_cleanup\n");, g4 B# J- ]. s* k& z

' B5 P  m; `* B9 c1 N2 N! {5 Y    /* put your code here */
9 Y7 T- M2 @$ ]# m) ]}[/mw_shl_code]" u3 \3 o4 J: 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) x! Q. u7 e4 C, z( {9 |' z
请问这个函数是怎么用的?有什么用?

7 C5 K( X; P; e) i7 U& i4 I  g+ q入口函数 改成 ufusr_cleanup
( H" D& l' G% P) n! [& g
' ]8 o0 {& |, y' F# ^7 n. D8 x意思是 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二次开发专题模块培训报名开始啦

    我知道了