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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x

" B) r& b9 u: B( w+ M( \( W/ m6 `NX二次开发源码分享】关闭NX后,做点儿事; V( I  I' ~2 G+ s0 Y' A( z

; B, j* ?4 J' C[mw_shl_code=c,true]/*0 V. h; h, b. }' E6 U

' n8 f; U" ~7 k, O    ufusr_ask_unload is invoked immediately following the completion of ufusr
! W6 U# F. f- S) m0 Z# z2 r    (or ufsta when the dll is run from a startup folder) to find out when you
5 i" i8 q& ^3 C: X# Q1 @+ G* u    want the dll to be unloaded.  If ufusr_ask_unload returns
& o% C/ X  R' [- v' U. [0 z( o    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is$ b3 a; s" Q$ [2 Y3 x) f
    unload when NX is terminating.  To prove to yourself that this works, set6 y5 w2 H: v9 _9 I* E6 m* I* B
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not
" Y3 I" ?8 D- {3 @4 B) m7 ^    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX
" X: b3 Y, H* K; Q2 f, J3 k% @. I    Log File and make a note of the full path to the syslog which will be shown
4 \/ z8 F& @  y    as its own first line.  Run the dll built from this code (nothing noticable9 k1 x* d8 X& o* j
    will happen.)  Exit NX.  Find the syslog and open it in any text editor to# d- y; p6 @. M5 A
    see this line near the bottom:
/ l' t+ e, M, P- s2 K  i+ U, D7 U" \2 G4 n& e2 Y$ j
NX is shutting down - running ufusr_cleanup& `5 }% L; K. d: L4 {
: L! c" _- A, q/ {$ Z  Q/ `6 o3 {  `
*/
; w: L7 {$ l  y1 K+ S#include <stdio.h>
, Y* N  p' A6 a#include <string.h>
7 D: p& V. w. F: c' N) V; ^#include <uf.h>& |; W) E  \7 h) ~1 r
#include <uf_ui.h>
3 S& {% ~: K6 r8 T% R# Q#include <uf_exit.h># F3 L/ r# m# {4 F
/ Q' Z  H, z; N6 j2 {( U
#include <stdarg.h>) @2 ~% o  t" O( ~+ `0 X# Z% w& D

' d3 Y9 I: R: w, Z% pstatic void ECHO(char *format, ...)
7 _9 j$ ~# C4 O1 w{( l' _3 Y6 L- v) u" m) o1 `5 X
    char msg[UF_UI_MAX_STRING_LEN+1];( s7 l; Y* `0 ]( O* W8 `8 w
    va_list args;1 y' y9 f- u- O. Y( J
    va_start(args, format);
& i1 U3 g' D- r% D7 V& o2 A    vsprintf(msg, format, args);4 d+ e% U6 p8 e- @
    va_end(args);
/ r# S, k. R" s9 D# M# z8 ~    UF_UI_open_listing_window();
$ Y" i3 @% l4 J    UF_UI_write_listing_window(msg);3 k$ ]  w+ M6 I4 T5 S
    UF_print_syslog(msg, FALSE);) c& Q: T) v! ]+ g5 {
}
, `/ t. O' {9 g
, U0 \4 N& X; F' z7 M. N# R#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))8 o7 k, f5 W  X& d% k0 ^
1 U# x5 j) C/ o! j& `0 B  o, {  a
static int report_error( char *file, int line, char *call, int irc)
7 H  S$ ^8 i: r' }{: l  w( q) i0 T2 A
    if (irc)* ^( f% ?! _! U4 ]
    {
3 H+ ~6 K0 n( ], e        char err[133];" ~, L1 L& T* y% V
9 p+ L4 ^, E  M8 K" D2 L
        UF_get_fail_message(irc, err);0 X2 c6 W3 [+ }2 D# `: X4 k- |7 |
        ECHO("*** ERROR code %d at line %d in %s:\n",
2 i" u' `( r' F6 o' \' R            irc, line, file);
! w; V$ `' }7 @5 z  y5 ]        ECHO("+++ %s\n", err);
/ l! Q( K. g( p        ECHO("%s;\n", call);3 U8 j. z- _  `
    }
1 X& G9 C$ v9 Z# y3 T/ s  h  Z+ i# q0 H( ~6 f' F
    return(irc);3 J$ E; m5 q* |: |/ _
}, u. |  c  |2 S4 t4 v
- i, s3 y4 q' Y% v7 ?0 {8 p* x
/*ARGSUSED*/* y9 ^: z; ^; O$ `4 U
void ufusr(char *param, int *reTCode, int paramLen)
1 z% G3 h; D& c/ `- }( ?3 w/ h$ E{0 S( U7 G: C) p
}
& ^5 d# u. @+ [1 {, f  b) m% s+ e" {  w; K
/*ARGSUSED*/
) J$ G3 R, S& v. t' M7 K9 Y3 Kvoid ufsta(char *param, int *retcode, int paramLen)
; p) @6 k$ y5 n. n{" q, f2 Z6 u+ B* @% u6 R
}
- b2 h8 ~: N* }! g# T; X( h+ l7 N9 Q; }$ n$ L
int ufusr_ask_unload(void)9 f- N6 u. Q3 n: i: O/ S: i/ K6 J
{
8 [' |4 @: w7 [8 B2 r    return (UF_UNLOAD_UG_TERMINATE);3 F% f2 v6 U0 x
}4 ^) z1 j: M* T, V% P
# o9 _* e% R0 @7 k
void ufusr_cleanup(void)' ^0 e; F& ~2 G
{( G) X; f7 K' o
    ECHO("NX is shutting down - running ufusr_cleanup\n");, v$ o% z  B) o9 q" u
# m( E/ N2 a* N$ f$ D
    /* put your code here */, T' ?9 D0 G, |' p# U1 ^
}[/mw_shl_code]+ c. s' y: F" v1 U0 L
上海点团信息科技有限公司,承接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
) J$ y3 @- ?5 r请问这个函数是怎么用的?有什么用?
) C5 o' X8 b; e3 @1 l$ H
入口函数 改成 ufusr_cleanup
- E2 P3 I1 H: x  m: ~6 q! F$ a
( v! _1 J  a2 U, B3 _& [意思是 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二次开发专题模块培训报名开始啦

    我知道了