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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x
; k( N6 A- A" j
NX二次开发源码分享】关闭NX后,做点儿事
* i9 I+ k% O0 l7 N& ^/ F4 t$ }2 P- j0 L4 b+ Q. ^
[mw_shl_code=c,true]/*
6 c! R+ M2 Z2 D9 G$ m: I% }; Q5 j. ^1 l
    ufusr_ask_unload is invoked immediately following the completion of ufusr
! r! G( W1 n  `7 ^    (or ufsta when the dll is run from a startup folder) to find out when you+ u) O+ d: t$ {  }7 t* h7 _
    want the dll to be unloaded.  If ufusr_ask_unload returns& I5 I7 p1 i5 b1 w
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is9 A# n% V. @+ s1 O1 @+ L
    unload when NX is terminating.  To prove to yourself that this works, set; Z/ I6 Z8 w$ }) K
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not/ g. @  n7 K& d( G# _
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX
2 |; |5 z! l- ^# ?$ Z# d  J- V4 j    Log File and make a note of the full path to the syslog which will be shown  E+ R5 l4 m1 ?' a1 T
    as its own first line.  Run the dll built from this code (nothing noticable# N8 Y( ~+ Z0 F) w( _
    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
2 K/ Y$ C3 h2 s    see this line near the bottom:, e6 V7 [: d3 I
, ~( H- u" p9 i* s( T8 |
NX is shutting down - running ufusr_cleanup* F' u0 v) n. U5 T

" ^1 M+ c4 }7 L' S8 Y8 }6 a. D*/" S1 o$ h! L" R$ R
#include <stdio.h>6 K- e4 k% }, v' i1 Y
#include <string.h>
% r5 A4 E' ^, X# d- F4 s#include <uf.h># L& q6 K& l1 R$ g* @! @1 p( m" y7 z
#include <uf_ui.h>6 Y/ n1 _# r9 Z  F
#include <uf_exit.h>3 l+ P+ c- I- X
2 k6 o" a& I0 G4 F+ q
#include <stdarg.h>
" Q8 \" k6 ^6 X: n! W
6 G! C* r# k# R  W8 A1 @static void ECHO(char *format, ...)4 O, c# o6 T. ?3 ]/ `1 M, Z# H
{
" k2 ?7 q) Z& e, Y$ C' H5 Y    char msg[UF_UI_MAX_STRING_LEN+1];
2 {% ~( x: y, n% r8 t    va_list args;: n8 T3 l% ?, Y1 G! K
    va_start(args, format);
7 N$ u( U- D2 _! F) {' ?$ g' T    vsprintf(msg, format, args);, F5 E: m6 i- x: \& S* `$ z
    va_end(args);+ Q! p! [% _0 e6 K0 h6 k
    UF_UI_open_listing_window();
7 R( i, I2 _3 F    UF_UI_write_listing_window(msg);
) c$ v4 I5 Y1 d6 u, d, ?0 n    UF_print_syslog(msg, FALSE);
: s5 R/ F* \: M7 h5 r! K1 C  y. l}
0 x4 C; r5 F9 n; _0 H6 e
& B# w( C5 {# [, O% t+ }. s( b5 \#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
  f9 Y2 k. s- Y/ T
( @7 @  @. M( z  L9 f7 q) ^" E6 A9 k0 astatic int report_error( char *file, int line, char *call, int irc)  K. Z1 u2 w3 L% K, o; P9 C
{3 X2 C+ C; W2 a! w7 W; A
    if (irc)
' N& Y' C2 F6 g4 Y5 z2 k. U    {
5 s+ k. c7 V* g8 J        char err[133];
- a; [! h* J/ K& L# i/ J5 R% t& N  W2 B! k
        UF_get_fail_message(irc, err);
, c9 s' N2 m2 S; L& H( x9 T$ a        ECHO("*** ERROR code %d at line %d in %s:\n",
+ z  H4 g+ H5 H            irc, line, file);
7 V$ N4 @- H, i, \- j4 q        ECHO("+++ %s\n", err);( I) [5 L2 z) E6 i: E. M& g' x' i
        ECHO("%s;\n", call);
: `6 d- a3 [; z9 e. e& l3 x    }" Z! h% M1 D& K$ F

6 x3 J& |, [4 z+ A) p  }4 u& ?) f/ ^    return(irc);
7 \5 H! A! F% q}6 u* }* [/ O  P0 k# u/ |0 A
( v9 K* Y3 E. f# @  p+ O
/*ARGSUSED*/  y+ T) a/ D  m" {( |
void ufusr(char *param, int *reTCode, int paramLen)
+ O* D( i, G( q/ L- O6 h6 a{+ b% A. p& v+ v
}: q& v3 x" J2 a) I# U
' [4 _( V* x$ Z1 Q* s6 l9 @
/*ARGSUSED*/
/ q2 t1 H. U* E9 N) Xvoid ufsta(char *param, int *retcode, int paramLen)
1 e3 T) q1 Q2 F+ O/ @5 @# ]% v# M, J{
2 h* O" T' O* P" l; r! }# R}
+ D" b7 w) Y' h) _  `8 f2 ]% S7 x2 m" m$ _4 v
int ufusr_ask_unload(void)
6 ?, l* t- U, C6 m{
6 N* I7 f9 U, @" `2 S    return (UF_UNLOAD_UG_TERMINATE);8 j, {6 _% d$ \4 o  k
}6 L! Q, O9 `2 V$ |
& `- y/ I( E3 a! j& F) G/ j
void ufusr_cleanup(void)- R; b: L8 E1 x
{
4 z! t- O' y7 u0 v3 R7 n3 h7 j/ `    ECHO("NX is shutting down - running ufusr_cleanup\n");
/ C3 K- S/ M; J. j: Q5 v4 o
( g) o* i' e& N0 o% j    /* put your code here */
# B5 K( o+ J3 y2 z( j5 c0 K' J9 S3 w% k}[/mw_shl_code]% f7 j4 e6 |0 S* e
上海点团信息科技有限公司,承接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:492 y' L8 x: u6 n  r
请问这个函数是怎么用的?有什么用?
$ _; N$ k2 r& I) O
入口函数 改成 ufusr_cleanup
6 I; u/ X# s) p- R* k7 Y8 D# C- g6 q/ Z/ L2 G) S
意思是 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二次开发专题模块培训报名开始啦

    我知道了