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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x
2 u5 }! f# j( `7 u7 o
NX二次开发源码分享】关闭NX后,做点儿事
1 g' |, Z' V1 T$ J4 l9 U* ]9 [+ S$ E7 u% A# ^, f, s2 W7 ~1 E
[mw_shl_code=c,true]/*
2 l! [6 N! q- L) q, i0 L9 [: V/ x2 [( ?  S0 y* V2 y+ h
    ufusr_ask_unload is invoked immediately following the completion of ufusr$ h; K+ t: ?/ G+ R$ o
    (or ufsta when the dll is run from a startup folder) to find out when you9 R& r9 h/ k0 P& P" g$ B
    want the dll to be unloaded.  If ufusr_ask_unload returns
2 j  p: q/ g8 s7 i    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
' U9 F3 E( k, i! _! a4 V6 ~+ k    unload when NX is terminating.  To prove to yourself that this works, set, C3 Z9 g& f' O2 ?& R2 q( J1 L7 n
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not
; ^( b$ e1 j% _- P4 F$ _    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX. c, x5 l, e1 S; P. \
    Log File and make a note of the full path to the syslog which will be shown8 v7 m8 U/ d( G5 M& t7 q
    as its own first line.  Run the dll built from this code (nothing noticable" i9 y6 c& \% a: v& m" s
    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
$ d3 C' F& c% Y  t0 ~9 ^    see this line near the bottom:+ C" `, @# P& u$ i$ j
* u7 |/ B" j( o# c1 M2 h
NX is shutting down - running ufusr_cleanup
" V" x9 c: O& `( k* D- k2 X* y8 X1 _/ ?9 U
*/( F9 y" T" ]& f
#include <stdio.h>
9 K; b  p+ u, H" |3 |/ [4 i0 q5 m#include <string.h>9 P5 L7 Q2 d% }) F, @7 j
#include <uf.h>$ y/ [, ?" M! T$ |1 r
#include <uf_ui.h>0 n2 i& |: X. r! n
#include <uf_exit.h>. g/ X. V: }7 k( k8 v

: r' L' ^! `0 c2 p. z/ \#include <stdarg.h>
0 O: i9 q$ C* h1 ^- n& r. D7 ~2 d- O5 \$ E5 X) F" T4 T) |
static void ECHO(char *format, ...)5 Q7 p7 v" E5 L7 D' j7 Y; ]3 E6 m  u
{, p2 M! R+ f& d( ?" N7 @* p
    char msg[UF_UI_MAX_STRING_LEN+1];
( K/ [( y4 s  ^3 n3 _: V    va_list args;' Y% p9 b8 _, G: t- F4 @
    va_start(args, format);# s! q: b2 B+ t+ z8 t# l
    vsprintf(msg, format, args);, B8 A4 `3 V' p( E4 \' Z
    va_end(args);+ J& Z% Z7 |' A
    UF_UI_open_listing_window();
- @) v! k3 u' u% Q0 Q    UF_UI_write_listing_window(msg);" H- r: {5 T1 c3 }
    UF_print_syslog(msg, FALSE);8 [; C8 `7 r4 o' z0 k! G
}8 B4 U/ Y4 W  J' i; t

9 b; s/ j% A* [# w#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
6 W# f! o" c: h  ]. f: j. _. M, B5 x' \
static int report_error( char *file, int line, char *call, int irc)
; r! K% e9 k6 l! Z$ v/ z- c{
& P5 Y  [- D9 `2 L- a7 V4 E" ^; A' g    if (irc)
7 n! d6 Y, E. E: a    {# o7 L+ B" A1 e* I" f/ s
        char err[133];2 m" m2 c9 @. G

0 ^" ?- d( F" ]+ I. ?        UF_get_fail_message(irc, err);# {; e# F7 F9 V
        ECHO("*** ERROR code %d at line %d in %s:\n",0 }" m4 |! v# }# ^
            irc, line, file);
- s% `9 t$ q) [1 n3 G! q        ECHO("+++ %s\n", err);
$ ?3 J% M2 g7 Q        ECHO("%s;\n", call);
! n0 Z  H% ^8 {% G# d! J    }
* S9 t; a! W; A1 L7 B6 c) s/ H$ N4 o2 p  Z' \) z, ~0 ]
    return(irc);
# J  h2 v5 H' c! P, r8 T}
3 k; ^2 ~2 [, V1 t& ]8 I+ _- ~0 P, \0 [' E
/*ARGSUSED*/
( G; A8 s. u8 z" B) R# O$ T$ E! Cvoid ufusr(char *param, int *reTCode, int paramLen)/ {4 a! K/ V& m8 E7 d5 m8 N
{/ k. h5 I/ U+ F4 w8 W
}
) W% m& F7 ?+ L% _0 _3 k' u/ n, H
; ^$ y. e; @% y4 `& \/*ARGSUSED*/: W5 I; ]2 \9 D8 H9 ?, |. `8 z
void ufsta(char *param, int *retcode, int paramLen)! U0 I0 O# E8 t0 g: ~  f
{4 y5 `# D) R0 z# V, ?
}
$ Z; p# h* m, [, O- u
9 ~/ S% Y* g# _6 xint ufusr_ask_unload(void)
) x0 N( t# {* a0 i: u/ D{6 i/ z' e8 N! H4 r8 |' x8 s( {
    return (UF_UNLOAD_UG_TERMINATE);
0 q) G' d) c; S# R% x}
6 V  y* L9 Z% i# ^9 G# _* h4 `5 B( H( i6 M4 A- h  {. f1 ?
void ufusr_cleanup(void)  n# ?: ?; L3 |2 T- w. F3 r
{. \( i/ j8 H8 j1 r
    ECHO("NX is shutting down - running ufusr_cleanup\n");3 e5 P0 F  T  A8 B4 Q

2 m1 e2 ?# G4 ~0 n    /* put your code here */
: Y, z1 b/ [3 e- ]" E, {3 _}[/mw_shl_code]
. {; W8 W8 u1 U6 \
上海点团信息科技有限公司,承接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; w6 n9 ]: ?: n) d2 F, {- W* v2 g
请问这个函数是怎么用的?有什么用?

; |5 C9 d' {! _1 l/ b9 _入口函数 改成 ufusr_cleanup - ]  D5 P9 q/ t" m5 x2 L/ k1 k- X: R
4 [  s4 \& Y9 D9 b+ R
意思是 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二次开发专题模块培训报名开始啦

    我知道了