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

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

  [复制链接]

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

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

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

x
8 W  O8 K: L6 {3 E6 h
NX二次开发源码分享】关闭NX后,做点儿事
3 ^; W- `5 q" i( y! h
/ Y- H! O' e2 S+ q: W: I! N[mw_shl_code=c,true]/*
. l  r: _4 h8 |% H/ L7 c! Q0 n
    ufusr_ask_unload is invoked immediately following the completion of ufusr
  b# X3 O9 N2 M3 W    (or ufsta when the dll is run from a startup folder) to find out when you& s! ~2 R" `6 A* d: h! M5 x
    want the dll to be unloaded.  If ufusr_ask_unload returns$ N. w! \: I0 q# c' l2 }
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is6 R  S; W3 c0 X- q
    unload when NX is terminating.  To prove to yourself that this works, set. q( a6 E% A6 q& l2 }6 N6 r
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not( ~" R9 w( l$ J1 u: H
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX& e/ r0 V2 y7 f3 G% _7 l5 F
    Log File and make a note of the full path to the syslog which will be shown4 D0 o2 H1 M! i4 V+ C
    as its own first line.  Run the dll built from this code (nothing noticable1 q/ ~: @, |! N& H) s
    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
2 r# l4 }) h* g9 g* @    see this line near the bottom:
0 w6 w  Q! d2 J) A7 m
3 Q+ Y3 r$ x$ q2 `/ k/ w$ e$ s0 ?NX is shutting down - running ufusr_cleanup
0 M) H2 R/ ^1 p6 a
# a8 _) L4 f- D: y: _, _1 d*/. A- l5 x/ D% G3 K4 g- L
#include <stdio.h>
9 J, M+ z/ y! q6 U7 D' w) @  D#include <string.h>
5 G& t6 q8 M2 V- C  k. i# \5 v3 ^#include <uf.h>" P7 b* `8 Y- |/ r. C" U7 t, k9 r
#include <uf_ui.h>: P5 ~/ z3 u; z0 e/ [
#include <uf_exit.h>4 x, Q3 L2 R2 q7 z9 g7 T0 s) u+ [& [
( {) T+ ?* E, s9 c6 j; P& o& d/ X/ V
#include <stdarg.h>! s2 Y% H8 c! j, T
2 I  |+ D/ U! Q- u" n) \: ~* ~
static void ECHO(char *format, ...)
, H) f. ?% c/ v) n) a3 z{  K4 q, E! J3 I- n
    char msg[UF_UI_MAX_STRING_LEN+1];+ _' P. w  Y2 ]/ N0 e
    va_list args;
" ~( b" n5 e$ P- K7 C    va_start(args, format);% E+ E7 e6 N7 D
    vsprintf(msg, format, args);) L* Q( c9 A1 G# z7 A
    va_end(args);" T; F5 q' g3 H
    UF_UI_open_listing_window();. u, L8 _+ k) @2 L) [2 ^
    UF_UI_write_listing_window(msg);
& T' g9 n3 L' P1 C    UF_print_syslog(msg, FALSE);: w/ n  y7 s2 q
}
0 \& `0 [. q  E2 ~. I
4 o5 ^, m1 y' `9 ]  W# f( b#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
7 ^7 W% s. d% i- U/ t
, o' u0 [* V- `7 j+ Istatic int report_error( char *file, int line, char *call, int irc)
! u, ]' Q1 ^& q% F{/ d; T9 a; R) I4 l2 ]2 W5 H# U* K
    if (irc)
; N! H! u: U% c1 k$ N) r    {* u% }8 ?$ O$ m, y% g7 q
        char err[133];
( f9 H. s2 ?# x$ w+ \1 P
# Q/ R  `& `  h; q; U& V% A        UF_get_fail_message(irc, err);5 U8 N; s* D. E4 M
        ECHO("*** ERROR code %d at line %d in %s:\n",3 p% }7 S+ i, Y
            irc, line, file);
) B) b4 _* K7 B/ \; W  W7 c; O$ d        ECHO("+++ %s\n", err);) Y9 w9 u8 f, Q7 {/ A
        ECHO("%s;\n", call);( a; G9 X, n! a
    }2 H% z* b& ]6 R1 q- E" g; V8 r

& F  T5 D; I: Y! [7 {6 w    return(irc);7 S! F" H4 ?- J* H; `+ P
}
' v% _8 d7 ^/ A$ y+ d
& P8 a+ |" {& r5 C; i4 b. Q/*ARGSUSED*/
  C4 X/ W% a7 r, Mvoid ufusr(char *param, int *reTCode, int paramLen)
1 `# h9 F6 G# D- Y6 [7 Y{0 M$ T8 u; ?. ]/ O! e, ?+ u3 [( a4 p/ F
}  T2 z4 N8 _* V  I; T2 ~0 E

0 E' `6 p) k7 c4 c3 l( D' Z( B/ |  _+ z/*ARGSUSED*/
' t% H5 e: ]1 h. c$ x: }% Z( L  Z. }void ufsta(char *param, int *retcode, int paramLen)/ g+ z9 e1 \0 W, V  ]) N
{
0 q. \6 e2 ?* Q0 l* S}. m1 q! f% o& O6 U' h8 e

) w$ Z- s) c$ w1 m' [: Eint ufusr_ask_unload(void)
* e* w! Q7 t0 e9 x( Q# ^: W{
! }; z4 p/ q8 z0 j4 w) L    return (UF_UNLOAD_UG_TERMINATE);
0 g$ x6 m' U3 m0 F, X1 _7 [}. ~" [2 D, S2 e% k
/ T: o# k0 @) L0 L% B
void ufusr_cleanup(void)
" y0 h) v! r0 F: Q7 K{! [* E5 N' y2 f/ A/ n, b5 {
    ECHO("NX is shutting down - running ufusr_cleanup\n");$ q& h8 e8 d5 I0 }
# S, r6 ?$ _) O9 z- s2 p
    /* put your code here */# i. V: |" \& J8 m# j& b' Q
}[/mw_shl_code]& l( J9 C+ P/ v* a( E- S0 q
上海点团信息科技有限公司,承接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:495 B* Q% c& {* _; i
请问这个函数是怎么用的?有什么用?
7 j( L; _4 S7 b; p  p) }
入口函数 改成 ufusr_cleanup
: }* d* K+ \' x- Q0 g6 M
" h" X0 [) n+ K: \/ 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二次开发专题模块培训报名开始啦

    我知道了