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

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

  [复制链接]

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

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

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

x
% r% D% [$ O! E% p
NX二次开发源码分享】关闭NX后,做点儿事: Q8 l0 g9 T5 j

0 q, k& ~2 O, @; t' F' }1 g[mw_shl_code=c,true]/*
, Z7 G6 e2 Z+ _" H
; z1 n: C1 a7 U' H- }' H    ufusr_ask_unload is invoked immediately following the completion of ufusr
* \1 j5 y- t; @- j6 r6 A# f6 {& B& [    (or ufsta when the dll is run from a startup folder) to find out when you
0 B+ H# S: L3 j9 n    want the dll to be unloaded.  If ufusr_ask_unload returns; e" n( s% L: R: l4 w( g: K
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is+ ^  l: |& o8 D% u; T! X: P+ M
    unload when NX is terminating.  To prove to yourself that this works, set
" w# W4 m1 p4 Z; e    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not3 y% H- z$ e( x' p  G) j2 u
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX
8 \( ?' H% |. X) Q- ]  _3 D5 a6 r    Log File and make a note of the full path to the syslog which will be shown/ P& T5 c. L# m$ ^
    as its own first line.  Run the dll built from this code (nothing noticable
3 [  N0 V% \0 M    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
, C. x) D6 l2 g0 O- U    see this line near the bottom:  e  W. G5 m) L; ^! R# m
, g; @6 a4 |) P& \( j
NX is shutting down - running ufusr_cleanup! s+ r% P3 l0 u3 F" [7 B
* T) z. n9 G$ W6 F" ~6 p
*/
1 ~) R& b) Y- n* B5 ?#include <stdio.h>
  ?; P7 e0 X0 Z* u: a: [#include <string.h>
. w( ~- [! n7 j% c; N2 X#include <uf.h>
7 Q( C3 h- \9 Z( N  o0 u8 d  B  \#include <uf_ui.h>
/ Y; H1 t: \0 `, F#include <uf_exit.h>
5 R. x( K3 a" W6 v% J
% z$ y8 W8 X. Y! y( |2 U#include <stdarg.h>" ]- S" `$ `+ [
( y& Q; x* _; E4 g9 i
static void ECHO(char *format, ...)) Z9 u8 d8 s$ z) z5 F, y4 D# i
{! x( x; s8 t6 {5 D% l
    char msg[UF_UI_MAX_STRING_LEN+1];
1 W4 i) H5 c# T) m( a    va_list args;7 L: H- x* ]; @: \* N$ U. J* s, [
    va_start(args, format);7 j6 P3 U, a; x8 B
    vsprintf(msg, format, args);0 A" A. V$ {: W8 _
    va_end(args);. g& S0 y5 j  ~; q; N2 u
    UF_UI_open_listing_window();3 x9 {+ X  {+ u' O( [
    UF_UI_write_listing_window(msg);$ }# W/ g5 @0 n) e
    UF_print_syslog(msg, FALSE);; @1 h, g" E  T2 I4 C6 v, Z3 j" m
}
) u4 K: O. J& k7 F* z' e1 \7 R
1 \4 I+ N: I' m0 R$ T#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
* {1 Y; h  b  F/ B6 e5 \
. }; }" ]* t7 e& Y6 Gstatic int report_error( char *file, int line, char *call, int irc)% P1 j! n- x, E4 l! \
{  Q! K4 e) B  w( D, G& I
    if (irc)+ F7 `" @3 m/ V5 N+ c
    {
7 C+ `; |0 r8 x5 R/ u! `        char err[133];
1 x1 Q9 @( O, w! g+ W
, c& }9 l, b4 T, }' h: z        UF_get_fail_message(irc, err);+ I# `; b. Z0 y1 T
        ECHO("*** ERROR code %d at line %d in %s:\n",
3 f+ M$ r. ^* I9 O; `            irc, line, file);
0 C: Y8 n: k9 ?( V  j        ECHO("+++ %s\n", err);
3 I9 F6 p! @$ f/ |1 o* x        ECHO("%s;\n", call);
( s  g' A4 o( V    }  f" ^/ J3 k' Q0 O: n/ P% b4 R
( X1 `% J: H' z4 N
    return(irc);1 C3 N5 @9 a* L! K; m" n
}
0 K4 N5 q& t, u6 t# d
6 F/ a; \2 S& P; k" h& x' I& a/*ARGSUSED*/
& z5 ?( r$ f. M; L7 {3 I+ F" [) ~void ufusr(char *param, int *reTCode, int paramLen)
2 y6 T1 w7 w# g{' e# F$ v0 A1 r2 ?+ J3 h* _
}
- D6 C, t6 o, q  M$ S2 C4 j3 ~  ^: f0 N  c/ b
/*ARGSUSED*/
4 `: ^' i8 X- ?; k, u* \void ufsta(char *param, int *retcode, int paramLen)! W0 i$ s+ \3 A3 l& `% h
{
" n, _' N2 a* g9 m3 K}8 i0 T2 |$ B3 M$ I1 v
  l- e7 o' Y- E, C8 r; e
int ufusr_ask_unload(void). I* P3 B, t; S1 \5 G
{" {- K- s- _( `* y& [  u  E
    return (UF_UNLOAD_UG_TERMINATE);. t# t: z4 O3 l" e# k" P! v: N
}
' O+ e2 [% u* X' y& |( t5 B9 [! M; R5 l
void ufusr_cleanup(void)$ A+ |; l4 z( n8 e
{$ _0 J/ m0 p" i1 }
    ECHO("NX is shutting down - running ufusr_cleanup\n");
* C( @, l2 \( |* x7 T; ?1 B' @  k0 }1 X* y) K) h$ \
    /* put your code here */. C9 x2 [  p8 v7 O
}[/mw_shl_code]
% W! q% g  C: E( X2 V
上海点团信息科技有限公司,承接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
& D- f! j) b0 E% j6 Q请问这个函数是怎么用的?有什么用?

& W9 `) r1 k0 z1 y: F, D入口函数 改成 ufusr_cleanup
1 c; v2 V& J/ O( M; `2 p, |7 n" j( I. G7 O1 P
意思是 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二次开发专题模块培训报名开始啦

    我知道了