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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x

9 m- G. u3 j4 E6 t8 r1 q0 H" R# }6 DNX二次开发源码分享】关闭NX后,做点儿事: w' C7 l8 N+ j( u& P
8 y, I/ K% [: D. C( g
[mw_shl_code=c,true]/*
4 I( n) ]$ d% c5 m- c1 ^4 I8 E$ I% Y, x! _0 A1 c* |/ r0 T% T1 T
    ufusr_ask_unload is invoked immediately following the completion of ufusr8 A# ~/ Z1 `# M& [1 j7 {
    (or ufsta when the dll is run from a startup folder) to find out when you
  W' T. \0 u+ O1 ^    want the dll to be unloaded.  If ufusr_ask_unload returns
9 c, @( c+ S& w' D: c    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
  _% g, Y% e* \# u/ ^    unload when NX is terminating.  To prove to yourself that this works, set
( d/ y( X  ?0 @% u! L    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not
% a4 ~6 w; \+ |$ Y) ^2 n$ {    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX, b- q3 W: [) D# z1 v! ~* {
    Log File and make a note of the full path to the syslog which will be shown  l  S1 t4 q! W9 _) V8 D/ F
    as its own first line.  Run the dll built from this code (nothing noticable
9 l( ]& m% T; T# S* i    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
+ I$ {8 c$ `# ?; ]    see this line near the bottom:
+ Y+ i8 h, K/ M; |* k: H$ u( d  [  z2 D4 [' p3 i
NX is shutting down - running ufusr_cleanup
9 ?8 g& Q4 N% I3 {) l6 H  ~( z9 i$ F! t, h2 f% y
*/
/ ~, f2 f! b% K2 h4 A; i- f#include <stdio.h>: A. A# T1 j; X3 ~  M9 W
#include <string.h>- K4 f% ]* N* }* }
#include <uf.h>: ], W! N1 z' {
#include <uf_ui.h>; c& u  F4 o: f" T2 e& ]7 T6 I
#include <uf_exit.h>
$ b2 D+ F" L6 r0 ]$ g
& w: S* ~$ n9 B* }6 i1 H+ `5 }#include <stdarg.h>/ T! M3 @1 F+ N/ V% Q' r, g
+ G" Y2 V$ q' C- |4 k/ z
static void ECHO(char *format, ...)
% f4 |( m; P$ {{
5 n$ |/ R( m) J7 I    char msg[UF_UI_MAX_STRING_LEN+1];
2 E$ F6 O. a/ h( X; x7 [" S0 ]5 b% B    va_list args;
5 D! N* \" `8 k, x6 {2 V8 T    va_start(args, format);& v; q( P. E& `7 e
    vsprintf(msg, format, args);
2 `4 s% Q$ z* j/ B+ r    va_end(args);
& j; \5 j. }* _; B: l; y    UF_UI_open_listing_window();# F2 ]) v0 F1 c' i& u# ^) \) ?9 R
    UF_UI_write_listing_window(msg);
' G- t. a- {# Y$ M2 o' H% f    UF_print_syslog(msg, FALSE);
0 m. {" ?  f6 o$ f" Y6 `, X}
8 m$ A7 y, _6 ?" h- m2 _5 x
% k8 w) a1 W: F% a4 d#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))2 F' I- x. m- f( J

% H3 y" q& d3 }- a! D! astatic int report_error( char *file, int line, char *call, int irc)2 X* e/ K3 i8 C; M1 F! }
{8 R- I( i/ I% Y  b7 Y( _
    if (irc)
6 W# |- ?9 x& m7 `; Q9 T4 h    {/ c$ s* x+ S9 W- R1 h) h% f
        char err[133];% M4 E. n- r' I( z
# S8 m+ G& n+ ^) S7 w9 E' M
        UF_get_fail_message(irc, err);( U) ~* i. ~2 r
        ECHO("*** ERROR code %d at line %d in %s:\n",
9 t# I( [8 g5 o- R            irc, line, file);
9 t' T) A$ a$ N7 J        ECHO("+++ %s\n", err);
6 v! R  h8 P. d, c3 _: @$ t        ECHO("%s;\n", call);
* ]3 o4 {+ f& B    }
8 M! \( V6 J& |8 |6 d! S5 f3 E5 \' Q5 a4 q" ~  q
    return(irc);
6 o' O) y; F0 v4 \) S8 Q}
" ?" A( w6 m! Q1 e, Q* H* _! V2 _7 L9 Z: O
/*ARGSUSED*/% i, e7 b3 M- d, V7 Y9 ^/ x
void ufusr(char *param, int *reTCode, int paramLen)
& j: u& P8 B6 S/ v) E2 y{
" k  S# w! X( ]6 }5 ^. c2 R  E& j}
" ~# K' t1 M0 `3 u! w, M# P4 i& Y$ ?  `" J; K' @
/*ARGSUSED*/* p- @$ {. |. Z
void ufsta(char *param, int *retcode, int paramLen)7 n" }5 B( a  A1 I# i: I! U6 I0 z
{* X% L' `# \/ Z2 n
}
' B7 t/ |$ t! ?0 y% y0 R" j
0 D7 _$ g* J) m: |int ufusr_ask_unload(void)
- A5 k7 I; J7 Z( z! d{
2 @5 \# {' L) O$ w    return (UF_UNLOAD_UG_TERMINATE);* {. E0 ?& p5 q9 ?+ p
}
5 G: F% n5 e! H
+ Z! M' _: k4 ]- Y0 rvoid ufusr_cleanup(void)
8 l$ d, L+ R) n  U2 Q{0 e; w/ s, A4 O9 [' y' H
    ECHO("NX is shutting down - running ufusr_cleanup\n");% U( d  I9 I& s! Y9 U$ S% v
5 i3 A( J3 b( T8 g$ p
    /* put your code here */
) B7 `6 _4 D9 y6 Y$ e}[/mw_shl_code]
: @( D6 R4 _. S; w. M0 h
上海点团信息科技有限公司,承接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
! n9 @& B# K+ [; j/ q8 L请问这个函数是怎么用的?有什么用?
' i) x! O3 O1 q2 g
入口函数 改成 ufusr_cleanup
! _$ m4 D$ k# [9 y: P' y
0 M0 b6 m" A' L4 i$ u( |- Y6 l意思是 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二次开发专题模块培训报名开始啦

    我知道了