PLM之家PLMHome-工业软件践行者

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x
, I! \' C( H/ A! P! K  y
NX二次开发源码分享】关闭NX后,做点儿事
& @9 [; K9 o. G+ V4 g7 z. }. P8 E% |8 Z4 {, F8 U' h( q6 L
[mw_shl_code=c,true]/*
7 N/ E$ y0 S2 C$ p1 z
. E* d9 ~" I3 k( t8 P    ufusr_ask_unload is invoked immediately following the completion of ufusr
' b$ N1 x$ n8 {    (or ufsta when the dll is run from a startup folder) to find out when you
" ^8 j$ N; `" W% F2 y    want the dll to be unloaded.  If ufusr_ask_unload returns8 g9 l0 i; z+ p0 Z% u/ ~! _3 [
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is- i, P6 F% W- Z& I+ \! M
    unload when NX is terminating.  To prove to yourself that this works, set
, `! t+ c5 W, o  t    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not: C* P+ @# Z/ o& w
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX- V- h- P) n5 t# Y
    Log File and make a note of the full path to the syslog which will be shown1 k; ^+ j% S) o" H( C
    as its own first line.  Run the dll built from this code (nothing noticable
- _9 k9 X* e" v  J2 i; n+ W' M    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
/ a2 Q0 ]# |5 D9 S( P1 g    see this line near the bottom:
; Z1 e$ N' N: t  _4 H
" H4 I! P% c# s  u5 P8 L1 f% yNX is shutting down - running ufusr_cleanup
8 f; R) v7 Z6 o; s6 n) }# L8 A6 ^% w/ q0 j* Q4 f! h* u
*/% |6 V6 V' T8 k7 j" D
#include <stdio.h>
; J9 p  _4 X- T: k# A2 l: J% c#include <string.h>/ u* `6 R0 a9 I+ S0 x$ ?5 C8 S
#include <uf.h>! Y9 E3 B8 ?; Z( J6 O
#include <uf_ui.h>
+ q, ?# ^4 L3 n2 U! S#include <uf_exit.h>
' z+ ^, c" G0 E, V; [* z: Y
( w( K: ^9 U, ]) l& P5 [3 T#include <stdarg.h>3 A2 E. Q% H: D  p. M; h$ e! X' h

7 S: f: f/ @0 `* Dstatic void ECHO(char *format, ...): ~& a4 U3 h3 p& c7 G
{$ B; f: [8 U; M6 ?3 l
    char msg[UF_UI_MAX_STRING_LEN+1];
" `0 C1 w/ D2 t' Q1 H- |    va_list args;) T* ~4 `  s8 n; y) Q
    va_start(args, format);* Y) c- S$ k) \1 |. H$ D( V9 a
    vsprintf(msg, format, args);. C  j, h) H" q) L* Z" C8 N
    va_end(args);
, Y  L5 w/ Q. d+ y    UF_UI_open_listing_window();
, D9 K1 B2 b9 f7 u& a- j6 W0 v    UF_UI_write_listing_window(msg);% l' \4 v' ~7 v/ w
    UF_print_syslog(msg, FALSE);
4 M* n) W! G' Q4 \5 C+ R1 I; d$ s# n4 `}
% k2 d* N# P  ?, S
* F0 o3 U9 z5 W  p1 G" T#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
2 `! S8 S2 g" d' j1 U' y
/ X8 f# q4 k; T" \static int report_error( char *file, int line, char *call, int irc): S, L+ b4 Z; {+ ?0 d
{
$ \) P7 x& d5 V: E1 t$ E$ y+ @  g    if (irc)0 R# A- _$ f3 P1 l
    {2 r, p. E, [( {5 K( L
        char err[133];: Z* W8 R  u: w3 R( T

) p' p6 t' J. G$ p9 U        UF_get_fail_message(irc, err);' s8 O" T( f: b! {
        ECHO("*** ERROR code %d at line %d in %s:\n",
: P. U* N" k+ d            irc, line, file);0 k+ ~7 c' f( o) _; ]. I. ^! F
        ECHO("+++ %s\n", err);
7 E) q1 @& B/ L$ \        ECHO("%s;\n", call);" q) W, g8 P, X( C8 j
    }3 z4 @2 l! S2 T- c! U
# N; x+ c0 z( @! N
    return(irc);2 @- s% F. \# T6 f1 f
}
/ E6 ]+ W9 j, ~9 y$ c3 P9 s: {7 z) B& @/ j: H& S6 b
/*ARGSUSED*/5 t# z/ a. O' x4 B, Y/ f$ k% c, b
void ufusr(char *param, int *reTCode, int paramLen)$ B. W' T  e8 {7 Y9 F
{& n4 l, Y2 X+ X  d  z+ b
}
! f4 D$ C) Y  a; X- W1 p% G; Y4 l/ T9 X
/*ARGSUSED*/
2 @1 q- g. H* ?( A' U1 Gvoid ufsta(char *param, int *retcode, int paramLen)) @! n; p3 k: ]5 N
{
- M5 G, o3 h& Z  D. B" @}
; ~9 j8 M$ D' F- e" ^( q9 P; Y5 @7 P
int ufusr_ask_unload(void)6 o4 C( |. O% I: M* O' {4 C
{
1 m+ `% d' J, X0 I    return (UF_UNLOAD_UG_TERMINATE);
! K- q$ ?$ M, D  U- I' B) J}
; C6 g5 `( H6 h6 j
9 g# b/ z4 _' t9 s. _7 uvoid ufusr_cleanup(void)% f7 J# n2 k6 g+ \- k. i
{
* T, p: u) r+ l: V  @4 {2 D    ECHO("NX is shutting down - running ufusr_cleanup\n");
1 k) h# G  M  J* Y, r) G. ^2 J/ U/ n
    /* put your code here */
2 @: o: _# W1 _* f0 a}[/mw_shl_code]
! }- \5 d# J7 k' ~  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
4 G% w4 C. D. K7 ?. p5 w* j3 d请问这个函数是怎么用的?有什么用?
& \/ |/ c. C$ |& ?
入口函数 改成 ufusr_cleanup : Z) ?  f+ l" V& u" S0 \' T

/ g% v1 g4 ?3 z' A  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二次开发专题模块培训报名开始啦

    我知道了