PLM之家PLMHome-工业软件与AI结合践行者

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x
6 O- N: Y" W' s% {$ H
NX二次开发源码分享】关闭NX后,做点儿事
' b; {* f6 G1 \" W) a6 D4 s8 j9 w7 M4 Z+ h: @2 E
[mw_shl_code=c,true]/*
, m, y4 E" j5 B. s
! \/ ]' V* v( d1 H3 q    ufusr_ask_unload is invoked immediately following the completion of ufusr; F8 @5 B& w. [+ t
    (or ufsta when the dll is run from a startup folder) to find out when you: O! T' x  U3 C0 s
    want the dll to be unloaded.  If ufusr_ask_unload returns
: Q! o- a1 k3 x7 J- @% U    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
* {, }) S% j; {    unload when NX is terminating.  To prove to yourself that this works, set
* x" L& T9 o% \6 x    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not) t- ]; Z) Y: o
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX
2 F# j/ D, c3 ]+ {5 B5 Z3 I, b    Log File and make a note of the full path to the syslog which will be shown0 y( K3 G0 ~2 |$ G( A5 w8 o0 q6 ?. h
    as its own first line.  Run the dll built from this code (nothing noticable
- Q$ L( J9 ]  c9 ~0 y    will happen.)  Exit NX.  Find the syslog and open it in any text editor to" D1 G; f) ^7 h/ N7 ~, L
    see this line near the bottom:
) `  z- [9 b; R- _4 }* t7 N& c2 B% d3 ^! r
NX is shutting down - running ufusr_cleanup
) p6 W. K" e+ u+ O
' e; o. N# r/ z, V4 m6 G. X5 h*/
! m0 P0 [: c& j8 Z0 C#include <stdio.h>
* u( V0 o8 C' V  ~#include <string.h>
, S  V; Y9 p" ^* y9 v#include <uf.h>
3 w0 w# S! Y0 L3 O8 I$ o1 M0 M#include <uf_ui.h>
1 v( p) v6 S& Q9 {#include <uf_exit.h>& z# V4 D: m& @0 u% F& n% W. L
- }$ q4 S! h6 f% i+ P( p+ ?/ C
#include <stdarg.h>
" ]1 `: s. u3 R0 E+ x( K, d, [* R" p0 E
- F- T/ @; g: W; J0 Nstatic void ECHO(char *format, ...)6 N3 y0 P. i  N0 K; B$ ~
{
9 J6 X, a3 t! S0 T    char msg[UF_UI_MAX_STRING_LEN+1];4 Y# i" I0 ^! M# R" D2 Z/ V
    va_list args;
" A6 |. q0 G2 i: t8 W5 G; d: ?    va_start(args, format);
9 I; v9 J" [4 v' H    vsprintf(msg, format, args);
+ H2 n, T  N) H  c. V# Z    va_end(args);+ g" _2 ~* [& W* q$ b
    UF_UI_open_listing_window();
, A" F1 D( n+ D; s5 Q0 t    UF_UI_write_listing_window(msg);
6 Y# z! t4 k; B    UF_print_syslog(msg, FALSE);
) l5 U5 o- k' M9 X+ {, i}
$ w: y, y; ~* s4 M  m( B6 W& t- n+ s
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
- D8 h! c' r1 h5 {4 |+ }  O% M+ t- `& W
static int report_error( char *file, int line, char *call, int irc)( a  B  Q0 M3 `) O3 _
{
* H5 h% _0 e" }" s    if (irc)
1 r' `5 e8 l; H0 L    {- ?$ k# }# S- k8 k. Y6 o/ Z
        char err[133];
, A/ U! P8 j" i$ D0 y4 ~& Y0 p& W4 P+ G& O: s
        UF_get_fail_message(irc, err);
& h3 w+ u4 I) K( |' u        ECHO("*** ERROR code %d at line %d in %s:\n",
0 y* y+ f! F* A4 q9 j# I2 Q            irc, line, file);
' B5 x9 t' B3 ^2 P& o+ C# z. F+ s0 J" T        ECHO("+++ %s\n", err);
" M$ Z; e& R$ ?) }* [; S0 O        ECHO("%s;\n", call);
$ U7 z) d! b  ?" _# r/ Y    }
# _  @: G7 e6 j5 v- ]) _; l% {; N7 h/ G9 a  P2 Q; b
    return(irc);  R$ U' S$ Q8 F5 \# e: I. I
}) }, ^5 X. T' Z

4 P2 Q/ k9 P8 M8 f; O/*ARGSUSED*/
3 R6 l. Y- h; b# h# c4 fvoid ufusr(char *param, int *reTCode, int paramLen)
2 j7 R1 I, |  m. `# d{! Z1 ]. ^  k1 ]8 L+ r! v% f
}
8 a5 O- }8 r" t7 h$ r
4 ^, T, @) l$ u$ {, E2 S/*ARGSUSED*/
; U/ B; u2 S- i9 m' t* S" w  cvoid ufsta(char *param, int *retcode, int paramLen)
1 z" i* {8 X! Z{& L* ?, P+ s- T% A5 h% t* J
}
+ J2 f) ~' D3 }
# d, e7 ?8 D( A# z) C# Yint ufusr_ask_unload(void)7 p* b5 A' e( E+ V3 C" k
{
8 O7 l9 e. W) P    return (UF_UNLOAD_UG_TERMINATE);% N! u4 }' a$ d: E1 D- w! X: N* B
}
. S3 u8 b# J; k& M  w8 z3 o
5 S* M: s, p  g  \" Gvoid ufusr_cleanup(void)
/ Z0 ^1 P# i% m5 L" j- n{, V3 h. `+ @% C* G3 F8 m5 R( k
    ECHO("NX is shutting down - running ufusr_cleanup\n");
! v, ]8 h* M* h# C2 v
0 u# E4 ]' G% k    /* put your code here */
* h9 V: T; Y' M3 w* Z}[/mw_shl_code]! O+ p$ z6 a4 e! S" x
上海点团信息科技有限公司,承接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:496 O3 ?& o+ }1 ?% p) V' N" w
请问这个函数是怎么用的?有什么用?
5 w  f3 O' v, {- y$ Y( [
入口函数 改成 ufusr_cleanup
: X. w: ^4 K* B" m) S6 [* C& s" {: E9 v
意思是 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二次开发专题模块培训报名开始啦

    我知道了