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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x

" X2 N7 w% k& h8 o( UNX二次开发源码分享】关闭NX后,做点儿事0 U1 M. i  n4 [% k9 S6 m/ U

' Q7 y; \3 T. C* [# z, C7 T. K( k[mw_shl_code=c,true]/*
, H0 W- [6 h1 y, c9 N" G4 k3 P; [( n- X  V+ H
    ufusr_ask_unload is invoked immediately following the completion of ufusr7 @) |' _" p$ l8 A$ m
    (or ufsta when the dll is run from a startup folder) to find out when you
9 [/ O  D8 o' S    want the dll to be unloaded.  If ufusr_ask_unload returns6 q2 ?- R" l3 |& O/ |' ^& L+ h
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is3 f  ]; [1 \' ?2 L+ U* P, x
    unload when NX is terminating.  To prove to yourself that this works, set' x& _, _$ K$ J. {0 L4 @# z. O* {2 }
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not; B. g6 B  N6 q, f
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX
0 a- G8 }+ z, H- k# |) X8 K/ s* {7 S    Log File and make a note of the full path to the syslog which will be shown
% v, M4 R6 }( A$ h    as its own first line.  Run the dll built from this code (nothing noticable5 C  [3 J! i' G0 Y, E
    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
/ n2 [; I5 ]5 U    see this line near the bottom:, Q( I. z: [' |) ?9 `7 o" {: m9 d
; b: o8 V2 @5 L  u3 L: ^
NX is shutting down - running ufusr_cleanup, a! K4 C* N# k. T- e

# |! l+ X; _- g*/' f- `$ f1 r8 R  T5 M: j# c" m
#include <stdio.h>0 p7 g) i) N/ [
#include <string.h>" k+ X' A) f9 w! ]; v1 {1 N
#include <uf.h>
) f7 G% b2 b. }3 T#include <uf_ui.h>
% H7 o% e/ x6 T  t#include <uf_exit.h>
) k! D2 b: J' U$ ]" a' G) c
1 P( Z" K1 [: [# @, b; |#include <stdarg.h>" w8 l5 k  D$ a1 G0 O
, M7 q) d; R0 r6 {9 q
static void ECHO(char *format, ...)
7 l+ V; j/ T1 l" R{
6 P3 m( b0 q0 v; u1 y$ A    char msg[UF_UI_MAX_STRING_LEN+1];  y6 z/ ~- L# ?$ \; r
    va_list args;
1 B8 {5 M2 j9 O6 H7 I9 y    va_start(args, format);3 ^1 k: h: w0 T" E  I
    vsprintf(msg, format, args);6 d* i4 M: B. D$ @5 }& b+ n" H8 ^
    va_end(args);
- o2 Y  k+ T7 R) S; M9 x    UF_UI_open_listing_window();
4 J. v1 y3 Y. ~5 P    UF_UI_write_listing_window(msg);2 a! ^+ }/ H6 d, [: b7 R( U* p3 x
    UF_print_syslog(msg, FALSE);" l; K" d( S& t# n( U
}: h; V( H$ k7 W3 @) h1 U! Q. e( ~
' U+ M4 [( _- ]+ J. U7 `6 \
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X))): M( |1 i/ U, Z1 z$ m
4 [0 H/ f& H2 ~
static int report_error( char *file, int line, char *call, int irc)+ P) f" w" _, Y6 y# N6 O! P
{
& G% u- {0 ~7 b, |0 Q: Q8 Y    if (irc)
: P4 l" w9 {& k. y. U9 o* @    {# O# N1 y+ ]# u; O' C, \" M
        char err[133];
* X8 e3 ?+ t! a8 n0 |2 x, Y+ `
        UF_get_fail_message(irc, err);+ X% P& b# [$ [! f5 x0 I. P* d
        ECHO("*** ERROR code %d at line %d in %s:\n",& `1 Q1 e2 W3 h6 |
            irc, line, file);. C+ ]6 e% P2 B. z7 B( z
        ECHO("+++ %s\n", err);% Q; d$ N/ t/ k' u' y: u- R
        ECHO("%s;\n", call);5 Y3 G. f" y7 T0 r( F0 j2 @. |
    }: r8 x4 f/ [3 d$ y7 H0 ]! a+ G

7 z! k3 q$ b7 O0 @    return(irc);
6 F) o4 p' u% e; b0 Y: J$ N4 R! N}
% p, ?9 I4 n. Q7 W/ z& b
4 P0 k, y7 }3 N; t) t$ {/*ARGSUSED*/
0 Q2 c0 ]) x% P7 N( }) f) O1 P4 E) kvoid ufusr(char *param, int *reTCode, int paramLen)' F4 W& p% M6 N1 U. d2 ^( ?
{4 t: Q( s" D) Q8 K3 X
}3 i" F/ f6 ]. e$ y

7 U1 z( j9 F0 g) `* q; x$ [3 \/*ARGSUSED*/# }2 a6 \  E$ W9 R: A& [/ V
void ufsta(char *param, int *retcode, int paramLen)
( d4 m# M; s9 q+ v* C{2 \& G3 |& D- a; ]8 u- F) _3 m
}
0 h( h8 n/ L8 b$ s8 g) ^' @9 C# ?# R' `$ [9 c$ w* x
int ufusr_ask_unload(void)
" i9 a3 w( Q/ g% O) t{0 f5 e2 R9 Z4 n2 Q* G+ {
    return (UF_UNLOAD_UG_TERMINATE);, d6 n5 U$ Y, `# \6 T$ F
}5 S, |  ~, P  K1 m

' c8 p& D* U0 n7 Kvoid ufusr_cleanup(void)0 D. z/ J! j9 D/ d+ a! M  Q  }
{9 l/ [5 s5 Z' w7 p
    ECHO("NX is shutting down - running ufusr_cleanup\n");
" X3 |! O8 M5 N5 ?5 t9 ]" Z  \# Q9 \$ C9 Q$ _, C
    /* put your code here */1 p% \0 J9 J! a- Q1 t: O/ M* z
}[/mw_shl_code]
1 [& g. i0 S. p1 E5 B
上海点团信息科技有限公司,承接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% F8 q3 c/ l# ^5 C% m
请问这个函数是怎么用的?有什么用?

( x4 E$ d% E/ ~. x9 }2 F入口函数 改成 ufusr_cleanup 8 c  d; p2 ^& h- Y$ Q# @- d9 T

: A2 X% n0 a7 p3 k7 G/ J0 o意思是 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二次开发专题模块培训报名开始啦

    我知道了