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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x

9 ?4 x6 t# z. T0 @! sNX二次开发源码分享】关闭NX后,做点儿事6 s- w- n( v0 ?- d8 H7 O
9 ^8 U4 {* J' B+ [
[mw_shl_code=c,true]/*3 a8 w- D* o7 t2 X1 ~( X# \: N
% |4 [  s- b6 ]# u
    ufusr_ask_unload is invoked immediately following the completion of ufusr
0 C/ s/ s- L$ o4 ]' N    (or ufsta when the dll is run from a startup folder) to find out when you- K: O! G3 X% T" P
    want the dll to be unloaded.  If ufusr_ask_unload returns& b* x2 i3 K# c3 I3 j$ e
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is' e9 s' I( ^" C! }6 K3 F9 c
    unload when NX is terminating.  To prove to yourself that this works, set
; H3 v" P( R& E; }+ ?' F    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not
/ m& X$ b  s' @$ j- q7 l    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX  {0 D$ W9 m3 F& S; ]) j9 k; F/ M
    Log File and make a note of the full path to the syslog which will be shown
  t0 ], \1 x/ C6 e5 I    as its own first line.  Run the dll built from this code (nothing noticable
& M$ _4 c" w# l    will happen.)  Exit NX.  Find the syslog and open it in any text editor to2 r$ S& B) G8 q) \; x# L* O
    see this line near the bottom:
. L' Z) \- f; H3 s7 f" c  q$ A% u% k! M% H; c7 @# v4 ?& X
NX is shutting down - running ufusr_cleanup  \2 e# O) M! i, G7 z

! S! Z! P0 Y, T5 [  Q5 H6 v*/
& w  X  I# i- s( u#include <stdio.h>4 o6 R9 X. l$ s. G4 m0 }( c7 P0 I
#include <string.h>
1 G3 g/ t5 W0 x: D# r3 T#include <uf.h>
8 L' B2 W5 G5 l9 W$ X- Y#include <uf_ui.h>5 U! Q6 ^* m# V: G2 L  j( _
#include <uf_exit.h>
" y# p9 O% {( V: ]2 r3 G) a$ _3 k' n8 c7 O0 o
#include <stdarg.h>
4 m3 c% C# O: _$ ]) j$ U1 u! D2 n
, A/ y3 v# E# w+ V: L. A$ ?0 Ustatic void ECHO(char *format, ...)8 N. t% d8 R3 L/ E7 g- c8 }8 p& o
{
: b/ d# B7 p& n4 t( [, V& R    char msg[UF_UI_MAX_STRING_LEN+1];  d" A( i( l/ f2 A" H
    va_list args;2 X: F3 i& i  I1 a9 s+ E% X) ]
    va_start(args, format);
7 H, R# Z% v& |+ k2 B' s    vsprintf(msg, format, args);3 l% Y3 @9 q3 T! q) C+ `- H$ k) W" T
    va_end(args);6 t% {# \; P2 ]  C& X
    UF_UI_open_listing_window();
5 z$ v. I: \0 G& U* M    UF_UI_write_listing_window(msg);5 W" K1 N( c! S9 \- t
    UF_print_syslog(msg, FALSE);
9 s5 _* F. S& F, c}
/ l; x3 I% \- ?6 {7 u1 J7 a& x6 P% ~. G+ K2 S/ A. |3 B7 r! G
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))/ w3 C& Z" Y1 }) _. y

1 r3 @- \: d. I( wstatic int report_error( char *file, int line, char *call, int irc)& u. W; L! p9 O
{5 t6 w+ T2 J6 m$ _
    if (irc)+ E& t- G! a5 E) T2 d8 c% a
    {
, l) I' f: ]9 [- H        char err[133];
( r/ ~" o- I, A+ n! Q
, _  M/ R6 _; J2 `- |        UF_get_fail_message(irc, err);5 m! D$ k5 y6 x9 h. Z3 g; _
        ECHO("*** ERROR code %d at line %d in %s:\n",
& N, Q8 B: m5 C. M5 q. r) Y            irc, line, file);/ N3 N- ?& D$ V1 t! h! W
        ECHO("+++ %s\n", err);8 n# p% a, \! H# T; ~; S
        ECHO("%s;\n", call);
8 F* \3 |4 b4 r: Z    }2 r4 Z  W8 w" F% s1 x6 D" [
# v0 i6 q% h# n3 F6 b
    return(irc);% t8 m7 @+ [0 [( Q
}- d, u$ M9 b' r2 f5 U( u) U

: W, X' x: n. ~( S/*ARGSUSED*/9 T" X+ R. G' v3 t6 y
void ufusr(char *param, int *reTCode, int paramLen)( S( i5 a5 {, e: \  u6 b
{3 Q" L  Q# M5 k  [( ]5 J' P2 R- }
}/ Y. s) {! E8 n& t+ I6 P* M
, |$ U, w4 j$ y8 x. ^5 r. x
/*ARGSUSED*/
' Y5 r( E+ L. Ivoid ufsta(char *param, int *retcode, int paramLen)
7 R# d/ F/ p: j5 U{
! K* F  ]- u+ x( N6 q/ F# H. c}1 \  Q+ n5 `+ f
- f. v7 @5 y* m8 d9 u
int ufusr_ask_unload(void)/ {" O9 r: K; d2 [& F
{2 {, X' R* S8 o& W
    return (UF_UNLOAD_UG_TERMINATE);
* ]2 E) S* T2 R" H. H# F0 J7 E}
7 ~, }+ q% j( v* m$ j2 {. @9 i$ r7 {
void ufusr_cleanup(void)/ N2 w* K4 h; [0 f# w  h# s* A
{
! c$ E+ Y8 v4 L% \( P    ECHO("NX is shutting down - running ufusr_cleanup\n");
- V4 V& s- D3 p# z$ e+ d. n3 ^
    /* put your code here */
5 V' B# N  O5 R$ w  F5 h9 H! C}[/mw_shl_code]
* i8 `" n: c# v8 R6 M2 t0 P: I
上海点团信息科技有限公司,承接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
5 o( g2 O; F6 Y. _请问这个函数是怎么用的?有什么用?
3 z4 R- q5 p1 a7 n9 r3 M
入口函数 改成 ufusr_cleanup
+ L  i- F7 S4 ^+ r
% {; l5 V! P* P; Q5 Z- \) F意思是 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二次开发专题模块培训报名开始啦

    我知道了