PLM之家PLMHome-国产软件践行者

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x
" h7 Q0 M3 O' ]4 a+ }0 f
NX二次开发源码分享】关闭NX后,做点儿事8 r- [3 Y; n- p
# I- u& b7 K, K+ C9 j* A# N
[mw_shl_code=c,true]/*
$ e; t) g: a. c5 j  t
% F3 t; w! M7 z1 q* x) ~    ufusr_ask_unload is invoked immediately following the completion of ufusr9 U0 W; S2 g2 ?
    (or ufsta when the dll is run from a startup folder) to find out when you
0 L; n- ^/ V6 a  Y$ M5 h  }    want the dll to be unloaded.  If ufusr_ask_unload returns) B9 l' G3 \: m* p0 u% f
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is) U, a& i  ^) S) S/ C
    unload when NX is terminating.  To prove to yourself that this works, set
7 c4 Y* n/ i! l3 s    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not- y! j0 o# Q  z& O5 x
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX
& w6 G7 A* a& p! `% N+ u* O, W    Log File and make a note of the full path to the syslog which will be shown1 o+ a  V7 c( |  t4 Q4 ?
    as its own first line.  Run the dll built from this code (nothing noticable
2 Z1 J' t2 @0 @" r) O    will happen.)  Exit NX.  Find the syslog and open it in any text editor to0 V6 r, ]- p9 x! |/ @" p
    see this line near the bottom:7 ^+ @! I$ o4 w

$ F# C+ e, }( y/ a! X3 ^( TNX is shutting down - running ufusr_cleanup
2 B$ G8 u* m7 G/ u( R7 W- b( C) _8 O- m5 ~2 E- g
*/8 Z) i/ l0 \1 @! m2 k) i
#include <stdio.h>* r. U4 l5 ]- w$ ]+ h, X7 o
#include <string.h>
0 Z: w" Y4 _/ ?8 Y9 B  N#include <uf.h>
  n; r' V3 i' \' Y- C, z3 J+ B#include <uf_ui.h>
7 U( g8 k7 p9 Z2 F. R! P#include <uf_exit.h>4 Y( M' U1 h9 V/ b& D# a  [' p

4 `0 G; D( ^: E. d' r) Z+ v8 ^#include <stdarg.h>* x, `) Y& c% r; y; b* a

4 q# Y' g2 n  i8 d2 Istatic void ECHO(char *format, ...)
$ b, N8 b: ~6 m2 Q{. ]1 Y5 N1 x- B, c
    char msg[UF_UI_MAX_STRING_LEN+1];
' u8 A) L& J1 F" Q  q3 b    va_list args;/ S, w( o' J  J0 O
    va_start(args, format);
4 {% \8 N6 @9 [1 [2 B8 V! P0 S    vsprintf(msg, format, args);+ x% o0 B/ k. W6 |8 ]+ Y9 k) S5 _
    va_end(args);
! i5 {% z! v, o% E0 `/ L    UF_UI_open_listing_window();) s1 z3 U( _- I) l  _. u2 q0 Z
    UF_UI_write_listing_window(msg);
6 }2 }, N; L% N0 w5 z/ ~0 ?2 ?6 D    UF_print_syslog(msg, FALSE);
3 }3 S% A5 r  U; B1 v+ U, Y* ?}
: c" M) T8 R  q: `" L* b3 u4 h/ H1 h0 `9 d4 P1 d
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))& q5 b( I5 ?$ ^! R' L

9 j: e( i& {8 S6 `" C8 y9 pstatic int report_error( char *file, int line, char *call, int irc)
: P3 l, I# e" k' g{6 H1 e5 }$ f7 ?& P% s+ b4 |
    if (irc)
0 \3 b; p7 c/ f7 ~( _    {
& o' K$ O" f3 I1 y) }6 \+ B# H        char err[133];& P# t7 o& h  s* u
  C4 Z) ]# ~5 i
        UF_get_fail_message(irc, err);
6 [7 g" c' x. `( }        ECHO("*** ERROR code %d at line %d in %s:\n",
' A3 Y, k% }0 D  U            irc, line, file);
8 y, R" d4 \3 M: J, k0 B6 }7 H; S        ECHO("+++ %s\n", err);  q' [/ Z) E0 L3 X3 X! [
        ECHO("%s;\n", call);% s6 X% S3 l& \" C5 v
    }2 d' q* O- G5 F/ k) d) R- k, z

& l* u& j/ f6 ?9 s% m: B- n    return(irc);
% O  J3 s6 n) h9 t0 P}5 t" J1 e; k0 \9 |

8 ]/ E" M; G6 y$ l! ?$ ~  m! n9 Z0 i/*ARGSUSED*/
1 @% C7 b7 Z+ y$ [8 J+ g# yvoid ufusr(char *param, int *reTCode, int paramLen)
/ j* y, Z) ~- H$ f2 x4 T{
8 S3 t1 ]! M, z( `: q* p}
8 B9 s! G1 K+ y5 w
* R( G: a, p" @6 `4 H# S! X) _/*ARGSUSED*/; i4 Y, J: \9 A4 s) J+ S! z4 z& d
void ufsta(char *param, int *retcode, int paramLen)
/ Z: N5 Q; c- G% f/ v- W* @. R; L{! {6 [& p" P. e! u
}
9 v- j6 f* V& P# T  {0 _8 F% G  g8 s: W/ m, Q5 K8 H1 h  J
int ufusr_ask_unload(void)
0 E. X) m) G  e" b* W{8 P2 N2 P7 V& U+ t$ l+ G
    return (UF_UNLOAD_UG_TERMINATE);
# _9 M* V' ^! w+ f+ ]* S$ T}( s$ v$ z% I! Q: ?! g' F

' v% H7 S. T9 y* D* W5 g' M, Bvoid ufusr_cleanup(void)
! A1 y4 T; u0 J5 n* `! A8 _; F{
6 ?0 _" G/ ]/ ]. b6 F4 I    ECHO("NX is shutting down - running ufusr_cleanup\n");( a9 Q$ m: y/ Q2 X) v3 G
) Z6 l: Z5 e8 U) ~! n( q
    /* put your code here */
3 o, _- Y' o4 G3 J! E6 z3 v, I- a}[/mw_shl_code]
5 \9 e* M# g% g% z; o) z
上海点团信息科技有限公司,承接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
) }' \" ]2 Z9 T5 Y& U! K% p请问这个函数是怎么用的?有什么用?
2 [; X9 q# L* w& w' p( Q
入口函数 改成 ufusr_cleanup 7 h' @' B9 V% R* C2 U8 U$ ?
8 W  z0 B: `9 U
意思是 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二次开发专题模块培训报名开始啦

    我知道了