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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x
' ]7 |4 F! c  b' Q# {( I' m
NX二次开发源码分享】关闭NX后,做点儿事
( d. L: a! N# `" T; s9 g  |$ M) I6 k, a; |
[mw_shl_code=c,true]/*
% z( |* _6 k" @
3 ?8 ~" z3 s) ~0 Q; I" f( c; t# I2 l    ufusr_ask_unload is invoked immediately following the completion of ufusr0 y' O% \1 H2 _0 c2 _9 z. {  m( I( s) W
    (or ufsta when the dll is run from a startup folder) to find out when you3 r/ G; N# k" x
    want the dll to be unloaded.  If ufusr_ask_unload returns" t# P5 i; L% Y! \  ^8 |( o
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
6 }8 P% R# p, {. \3 E5 R: ^1 X    unload when NX is terminating.  To prove to yourself that this works, set8 }9 W7 y  y+ P
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not
5 m, K- I/ @8 v6 y0 j  h  T    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX" |9 w( O0 F+ d1 c5 B8 f
    Log File and make a note of the full path to the syslog which will be shown
" E9 Z! P! `4 c2 D0 n7 ^! {    as its own first line.  Run the dll built from this code (nothing noticable2 q0 J" t, o. R: m2 v4 W% _" S9 N
    will happen.)  Exit NX.  Find the syslog and open it in any text editor to2 ~1 d$ _* {3 H4 n4 v$ E3 }9 s: E
    see this line near the bottom:( v. p  r" t1 w) X  P

* b+ I0 M, W. c! o) }NX is shutting down - running ufusr_cleanup& g8 Y, K6 n2 f1 \+ O2 r9 x: k
/ }8 w8 R  h/ Q# S" b5 G" w
*/
1 v" a, z2 d& j7 P# O3 O# P#include <stdio.h>; k7 J; h. v  o
#include <string.h>
, f2 D5 B" E& K8 ]#include <uf.h>
3 U, l  K6 ?) U: ~/ M/ w& J; ?#include <uf_ui.h>* D% \# ~9 J3 Z! N1 I. ?
#include <uf_exit.h>
* v/ q7 B& W- _. ?, B4 v" o3 W. B2 H6 _( m, s+ i: m  {  ~: [
#include <stdarg.h>
' |2 X9 Y. S$ }8 H8 B# ?$ N- x& u' w
static void ECHO(char *format, ...)
, I9 j! _. C2 T{7 f9 ]9 b. N4 ^: @' `
    char msg[UF_UI_MAX_STRING_LEN+1];* Y$ N, I9 J7 e3 v- a4 f6 r: O
    va_list args;
7 W/ b  f7 }$ `6 d4 A2 D* F: U! K$ O    va_start(args, format);& z0 i' C8 ?, e4 @% k7 M
    vsprintf(msg, format, args);2 ?" ^9 k( |! o$ z
    va_end(args);7 g+ k* P) u+ r+ R( i  o% K" w7 [
    UF_UI_open_listing_window();
( l- Z5 K: e4 p+ p! y8 U    UF_UI_write_listing_window(msg);" H5 z5 V$ a1 r- l; }
    UF_print_syslog(msg, FALSE);
6 f' e3 `: X6 J1 T& f% I}- s2 Z6 S6 c% `4 e

6 X$ \: {" v7 N1 n+ C#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
* {, f. g8 r+ F3 q2 \) N0 X4 U) ^& K5 u
static int report_error( char *file, int line, char *call, int irc)- l  v0 ]- V2 A0 b; `
{; q( W# M& g% N) }- ^6 Y" H
    if (irc)
9 J4 u+ y$ \5 d    {
' i- M$ ~1 {2 n  ~5 A' j        char err[133];
$ u8 S) t& S5 G4 g. O0 C$ d- K, }6 k' Y, B
        UF_get_fail_message(irc, err);% v6 ^' {0 S; l9 f+ z: L- P
        ECHO("*** ERROR code %d at line %d in %s:\n",
$ F1 h: e3 d& I$ y            irc, line, file);8 i& S, _+ k( Z* }- \, H$ D
        ECHO("+++ %s\n", err);
2 Z% x6 d2 l% [" i( L$ Z( ~        ECHO("%s;\n", call);" p# R+ C9 _( c# i, z9 n" \
    }
. F0 |1 Q) X+ H. n8 ]' `
7 y" a1 z. K5 y* }, I% y1 G; ?& ~    return(irc);0 F# g1 N0 x4 a6 ?1 B" X
}6 u6 r; Z3 d9 u% J0 p
7 ^. C9 k# J9 X3 A4 e9 k! N* j
/*ARGSUSED*/
- i0 O5 G; K/ qvoid ufusr(char *param, int *reTCode, int paramLen); |3 e5 p) O& Y' _
{* T1 g* J) Z& X+ y( N
}$ r9 b4 Y- _$ b+ Q/ \

+ j! N4 {: Q( x# D/*ARGSUSED*/
' p0 E, B7 ^9 E& s3 L# E  ovoid ufsta(char *param, int *retcode, int paramLen)
* _; U+ v0 H) }$ k5 @8 ~. V& C1 [  s{
1 C1 ^! e/ K  L" s/ M! c}/ p5 C  A) {5 q0 Z) z
3 O8 j& U( U3 C0 h$ O7 `- J2 V1 _
int ufusr_ask_unload(void)
6 i8 q  J9 _2 M* J{
+ `4 @6 _' v* o8 S. }( B) K, F    return (UF_UNLOAD_UG_TERMINATE);1 F9 v+ |3 ^& V: m: Q
}
) s: j& H# U3 f; p/ [# L5 y# G6 C) ~0 @. H  @9 U1 @
void ufusr_cleanup(void)
3 D3 A# H9 Y) Z; H1 b. {/ C{
* h8 ]" L- m) O, l( I0 q    ECHO("NX is shutting down - running ufusr_cleanup\n");
" e# s3 Z# b9 [: F$ h0 O
4 b1 I9 |" b+ |# A2 p+ b& `    /* put your code here */
% H/ C* V1 Q* \" `}[/mw_shl_code]
2 L7 S8 c3 B; K2 T8 w1 f4 N# K) w' 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! T2 s1 X5 P0 c) G- ^
请问这个函数是怎么用的?有什么用?
& @# W4 r8 y+ I4 G" D) b
入口函数 改成 ufusr_cleanup 2 `" q1 ~% _  R' q3 p8 |& i

* P! l6 f  y( i7 z$ J0 s6 i4 \意思是 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二次开发专题模块培训报名开始啦

    我知道了