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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x
" U) U9 Z4 B& Z* [8 v. _
NX二次开发源码分享】关闭NX后,做点儿事
8 ]5 ^8 |' q: h$ R% l
& P2 d- \; k; c9 ?- o[mw_shl_code=c,true]/*% q# ]1 b. y$ U* J/ V
" p5 |+ u& }& N# \  S
    ufusr_ask_unload is invoked immediately following the completion of ufusr! O; @% ~* j7 ^+ d) i% E2 o
    (or ufsta when the dll is run from a startup folder) to find out when you
9 u3 v, W5 v& E1 }# ^    want the dll to be unloaded.  If ufusr_ask_unload returns/ P) R% d% t3 _7 m" J
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is! |8 [: P% ^* m' o9 l
    unload when NX is terminating.  To prove to yourself that this works, set$ Y8 L0 h, N! n& d
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not
# A$ a; Q: e! G% t0 c    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX
2 L0 @9 @* c6 {/ Q3 l1 C    Log File and make a note of the full path to the syslog which will be shown
& R7 R0 X& C0 a4 n* K' m4 A8 _. r. R2 Q    as its own first line.  Run the dll built from this code (nothing noticable
- S1 f: P4 d. A    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
' u3 S5 g! R$ G! a* y- U* Y    see this line near the bottom:6 n" x% @( ~( j, S2 T; p

" k  S- a# z3 JNX is shutting down - running ufusr_cleanup: M6 {6 _! A5 P5 ^  d/ Q
  N. W& t3 |; o3 g/ Q! n0 |; Q- Q
*/# v5 J& B5 j- \3 S! G$ C1 \* T
#include <stdio.h>! g8 r: j( e8 E. S# y7 ]
#include <string.h>
+ \# m* T/ v( c3 G. P0 b& V/ X#include <uf.h>
& |4 u8 U  `7 T% @: c#include <uf_ui.h>, v( }" {: `% ^) u9 v
#include <uf_exit.h>
/ H; g2 ?/ r+ y( g5 n
* J/ b4 a  z* K/ w) u" T/ A! w0 x! S. n#include <stdarg.h>
: z! \8 N* a; E5 g& s
% p$ c) o) ~3 J" b/ N1 i5 {static void ECHO(char *format, ...)0 L$ g0 }1 N. x, b2 c/ U7 `1 k
{, B5 ~5 O2 }% y* m9 L
    char msg[UF_UI_MAX_STRING_LEN+1];2 X- ?0 v  F# x0 g* t) A/ _  C
    va_list args;1 q7 V: a9 `, L. p- u; _9 q
    va_start(args, format);
$ u- i6 `* C0 Q% P    vsprintf(msg, format, args);
$ f6 v0 C/ V! b    va_end(args);
/ `- A- L; `  B    UF_UI_open_listing_window();
1 G2 v3 o: I: @+ U0 R& Z    UF_UI_write_listing_window(msg);
- U5 f: N( |& @- m, H    UF_print_syslog(msg, FALSE);$ g( R# v* b+ S6 r9 V$ B5 t& u' p
}
7 V: p/ F! v" ?7 c- Q9 c0 K) x
2 x2 \# {' ]. v, s1 Q$ s5 ]#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))$ q# s  l1 l+ ]  Q% H

" e4 {; T" e1 Y' c! E. Tstatic int report_error( char *file, int line, char *call, int irc)
3 A. O3 m* U6 R/ ]7 y{' w" c  o  Q9 Y9 X' I) ]* l
    if (irc)# a* l' o% C) C8 U+ a7 u
    {
2 n. R" j( T% Q7 \2 z        char err[133];6 {8 {5 `* T$ |+ q$ L

: M1 ~( r9 i0 E6 U0 P* W        UF_get_fail_message(irc, err);/ W$ G5 ^+ B9 k( I& j+ y  b% d1 z0 i
        ECHO("*** ERROR code %d at line %d in %s:\n",
+ Q$ B: `6 `0 ~& {, G, a* v; ~/ H            irc, line, file);/ ~& N* @+ }, ]% a" H5 e
        ECHO("+++ %s\n", err);) R$ h- ?. q4 N
        ECHO("%s;\n", call);  i, C2 v8 T5 H6 w
    }: K6 F) @% h# m

$ U6 l, T; H  c    return(irc);
- o' n9 V1 t% s% _" L. {}* ?% E6 C& n/ ?" J
7 n" H/ F* ?) ?# o& j$ |# N
/*ARGSUSED*/6 B: u5 H2 v, |  \( v
void ufusr(char *param, int *reTCode, int paramLen)$ l* I) [. Y+ y, n" e
{7 V3 F" }6 _9 R/ [; e" ?: l% W
}  Z" g) v" X2 D) k$ F/ J4 ?

0 W9 k* F% m5 q0 r7 p/*ARGSUSED*/
# q  ?3 }* a) ~$ J/ A/ Cvoid ufsta(char *param, int *retcode, int paramLen)% H3 e& b( G3 K% F
{. V) \6 M- ~8 v6 u3 J- r9 |
}( b: ~, M0 J$ z- N% ~& Q$ _

+ n7 E# o: R# G. }- aint ufusr_ask_unload(void), s& u& w" P" w% r+ N
{2 F% p1 U/ o5 U7 B% R7 q# r; x2 E
    return (UF_UNLOAD_UG_TERMINATE);
! A, ~  {% @$ Z2 n, p* x0 Z}
  K2 G; W6 l& E! s4 T
7 y5 T* r2 C4 Y) xvoid ufusr_cleanup(void)  u" t+ Q# V3 n; n# M
{
* J2 z* d* g$ o; r* ~    ECHO("NX is shutting down - running ufusr_cleanup\n");, V: E: g; D4 ~: q+ e) G" f. y' x

; W2 w1 r, }9 q; U    /* put your code here */, P; s- U7 D$ t# _" |+ l
}[/mw_shl_code]7 x- E: M2 Z* O& h
上海点团信息科技有限公司,承接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# h5 X4 s' R- Y  B3 A& R: j2 @
请问这个函数是怎么用的?有什么用?

& H* t3 ]' i+ c+ W8 v入口函数 改成 ufusr_cleanup
2 `  V" o9 w. @
) M. }0 f0 q' c意思是 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二次开发专题模块培训报名开始啦

    我知道了