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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x
3 I- ~! B- X0 f/ z. f. l) q, ?
NX二次开发源码分享】关闭NX后,做点儿事' d/ m6 }1 {, _, s

+ v, i+ p/ @6 A- F9 C9 @& C7 q8 L[mw_shl_code=c,true]/*8 b, k9 I2 f" T, o8 e: W" Z

3 S. g  F. {4 y% |) j    ufusr_ask_unload is invoked immediately following the completion of ufusr
, h6 D% Z( N9 E2 A, T    (or ufsta when the dll is run from a startup folder) to find out when you
5 N: H3 l% l9 p" K" j# g    want the dll to be unloaded.  If ufusr_ask_unload returns
. A. ~, \0 H; @    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
2 d: r4 ^1 g/ w* i% H2 X+ [    unload when NX is terminating.  To prove to yourself that this works, set' W9 F6 Z, t" |4 G
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not
; a6 z( o8 Z  e$ X) J% g    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX2 j. W, D( [3 W0 l3 L- T) P# Z  _
    Log File and make a note of the full path to the syslog which will be shown( A9 w! D$ l& m  S% ]/ z9 U- E
    as its own first line.  Run the dll built from this code (nothing noticable7 m) D- k) M. _4 j' d, T% l
    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
8 H% c$ f7 J9 p" Q6 U) A$ Y9 |5 d. v    see this line near the bottom:1 N+ j. y5 \( y; M

7 l4 E* L* A. j) d4 P+ P2 H* |8 cNX is shutting down - running ufusr_cleanup
2 G, g6 ~- A  F" K6 R: \2 }4 N0 Q/ Y+ d9 f* n  B( V
*/7 N6 W( ]$ o9 d+ |. T
#include <stdio.h>/ o8 l9 t( a8 y5 x5 J& h2 k
#include <string.h>7 ^$ Z. c+ @( \: a
#include <uf.h>
7 e/ r1 Z2 l# D& W0 |  @& N( u: I& v- P#include <uf_ui.h>
5 N9 ^7 f5 \& s0 H8 E0 W#include <uf_exit.h>
. X$ Z* i, O$ X1 f1 L4 l+ ]
+ |) Y. P! c7 `( S$ a' {/ \#include <stdarg.h>
% V9 K( k. m9 `6 k8 w1 B5 [
3 F4 X! F9 ~9 X. n" q; Y* kstatic void ECHO(char *format, ...); A1 o) S* B5 }/ S
{
2 d" A3 Z  h) M/ p% O5 k7 r& V    char msg[UF_UI_MAX_STRING_LEN+1];
, P! v3 o" J7 R# k% y    va_list args;8 Z5 m) N8 H+ T: Z0 @( ~
    va_start(args, format);6 e, S, S: S  q* P$ [
    vsprintf(msg, format, args);6 ]' x) _" ~  {7 `+ c4 Z
    va_end(args);0 h  j1 u, I+ j' F8 q
    UF_UI_open_listing_window();* q/ ]/ \; o( t) M! F: ~
    UF_UI_write_listing_window(msg);8 V& a( [) @+ r. G' r2 @1 `
    UF_print_syslog(msg, FALSE);
: ~9 |1 ?# v' W9 T% c}4 T" _) b% R( m  B# G( c
$ Q, ?. h# E* ~" j) Z
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X))). w2 G& U5 @/ ]2 k, L& x9 c

% @% ]( \+ k: zstatic int report_error( char *file, int line, char *call, int irc)
" _0 }3 q1 n/ ]/ V{
  T- A( K  w- e7 @% j    if (irc)
6 Q( m# D; ?) S7 B7 i* S    {6 k: E% {0 x7 i; Q
        char err[133];
( G. ^( ?* T! M: m$ w) u; `1 e& I, p  M5 C) b! c
        UF_get_fail_message(irc, err);7 Z. F& q7 u# g0 |
        ECHO("*** ERROR code %d at line %d in %s:\n",
. r6 p  H) R# A3 R$ `1 F* }            irc, line, file);% p' p& s3 T# E, \3 y6 I
        ECHO("+++ %s\n", err);( C  F7 I. E! p
        ECHO("%s;\n", call);0 T/ G3 b/ m3 O( [' E. M. L4 w3 x. i
    }, C3 K) g# A. A* b) \
1 y  ~; F  X+ M. t  h2 ]3 n
    return(irc);% r0 g5 T: ?9 h# A' A( s
}
  G) q4 p& w6 ~" ~/ @% v& ~) ]9 m0 `# ^
/*ARGSUSED*/
- C5 G) G" K3 }- pvoid ufusr(char *param, int *reTCode, int paramLen). c+ }9 u$ ]4 c& x
{
" b+ Y7 N* t( Z0 G. ^9 L) ?$ I}
5 z8 h; }9 Y& C% e7 B: n3 b1 j3 R4 ?7 q  J; N- [
/*ARGSUSED*/2 \1 \9 T$ l* {
void ufsta(char *param, int *retcode, int paramLen)( P. O' Z- }7 e" {' |
{1 l8 U& w9 _+ {8 c
}0 _) ^2 w# |1 |
' L. Y+ x2 B+ I) ~
int ufusr_ask_unload(void)
- S7 S" w; |( }9 m% B( U{
( w3 @  s' }, c5 h3 u( D8 u    return (UF_UNLOAD_UG_TERMINATE);+ u% D6 a& E/ Q
}
) f' N! a: @9 P; u9 Z
! r& h5 G; I' I5 z8 P) fvoid ufusr_cleanup(void)1 O. E6 I9 b& b5 b9 P: E* W
{" y/ Q+ E! M! ^; d- f
    ECHO("NX is shutting down - running ufusr_cleanup\n");# F; O* }$ Z+ O8 P2 Y% L; s

2 A( _* |4 y/ N3 T( [    /* put your code here */) p/ C8 J4 @% l5 |' _
}[/mw_shl_code]
2 i( I. l/ y! Z6 q
上海点团信息科技有限公司,承接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
' [! d* f4 t  s! I$ F3 ^) `& [请问这个函数是怎么用的?有什么用?

) z) @9 ?. L6 f入口函数 改成 ufusr_cleanup 0 m1 r: t* R8 ~% G( E6 u

& r+ s! M" ~8 J! b, z+ W) n. Z意思是 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二次开发专题模块培训报名开始啦

    我知道了