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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x

# _% a, U) P( C2 z4 sNX二次开发源码分享】关闭NX后,做点儿事
8 E9 S9 C1 ^6 z. k) j/ l
. `! Y  n9 X! i8 ]+ x[mw_shl_code=c,true]/*
& V- w7 {9 J3 @6 x; y, M- }# T+ G, X% w/ Q
    ufusr_ask_unload is invoked immediately following the completion of ufusr
- x* l; f7 A" q% C: R6 p    (or ufsta when the dll is run from a startup folder) to find out when you
: u. ^: g/ Q1 J' ~  z    want the dll to be unloaded.  If ufusr_ask_unload returns- [! ?" }: z& d8 `: p
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is$ z* I0 ?9 B+ O8 ?- ~7 A$ C( l
    unload when NX is terminating.  To prove to yourself that this works, set9 v" B( Y- T0 e) `8 ^
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not
& \  k2 @2 c3 v7 ~; R    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX
, X# C. f5 J& S' n' {% l1 t    Log File and make a note of the full path to the syslog which will be shown/ `+ O# q7 @! V+ a" |) F
    as its own first line.  Run the dll built from this code (nothing noticable% l3 q$ f5 O1 w/ {& l
    will happen.)  Exit NX.  Find the syslog and open it in any text editor to$ _+ X9 D8 q% z: {$ \
    see this line near the bottom:
' y9 j7 o( c4 R4 ~( A0 ~- T+ A# B- S9 q6 {
NX is shutting down - running ufusr_cleanup
6 s1 D$ q7 C0 [" S; R8 a% U) r8 N7 \# }6 t
*/
$ N. q" q% n8 N  L- ]% K! c3 G#include <stdio.h>
  m2 W% y* X1 i( y. t#include <string.h># e1 ^- l8 w+ Y* `
#include <uf.h>
& v0 B' n6 l: e2 H#include <uf_ui.h>1 x* a3 r) ?7 \: _* W. {
#include <uf_exit.h>
! B' q& A$ G; m' W( M% ~8 O* m, k
#include <stdarg.h>1 I& X( m6 p, V4 J4 {0 K

* N8 p: [' g- Istatic void ECHO(char *format, ...)5 \" y; c0 `6 P; S% r
{
- k1 Z) M) }3 a+ S6 e    char msg[UF_UI_MAX_STRING_LEN+1];
4 H1 [7 t, J$ O" K    va_list args;
" |8 _9 A$ r' ~7 ?& t  e    va_start(args, format);" P9 x' R$ z3 K+ T( n- u- B
    vsprintf(msg, format, args);
/ `) H* Q/ C; K, A# e& T/ q* @    va_end(args);
4 @$ _& G, v+ r. l- Y6 p4 j    UF_UI_open_listing_window();5 K- ?! x6 g4 M3 k2 S
    UF_UI_write_listing_window(msg);4 J& q* ?5 a3 y8 F9 o9 Q1 F
    UF_print_syslog(msg, FALSE);
6 S. t  k2 t* l, P& |7 W5 V* z/ }}
# i' C; G# i7 r* Z9 J4 x  d
% q4 R7 c  n$ B#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))5 ^. z7 Q* N/ X0 A. J
. h, }6 L, [3 q, m$ C1 K% N7 ~
static int report_error( char *file, int line, char *call, int irc)6 }+ e- L. V% m3 l% f, S
{8 ?9 i+ ^/ `, E$ ~
    if (irc)
3 B  R1 \# K9 ]6 Y. y" @    {5 l$ D; j: z; |0 w0 R5 v5 a7 s
        char err[133];
+ O7 m$ N! p/ J; m
( h& e% c0 _* Q  a* E        UF_get_fail_message(irc, err);
5 |# |. t- p- V" [6 U' ~! g: P4 H        ECHO("*** ERROR code %d at line %d in %s:\n",
9 C5 E7 N, ^7 R9 M- l            irc, line, file);) `6 t+ @' m. X& j  N* S) `3 c
        ECHO("+++ %s\n", err);$ V# C0 |7 I$ G5 R2 q
        ECHO("%s;\n", call);8 n* r0 Y# S3 y; V# g
    }
7 H6 G# _. T: \- m) E% [5 ~" R5 J% g, Y' |
    return(irc);& ?7 `* O+ c: S# G: g2 v
}- w) O4 }! }- {+ `; j+ L9 y

: Y9 E$ K3 P# F# @/*ARGSUSED*/5 s" M) E' j9 j/ ~+ b" ~" a7 M
void ufusr(char *param, int *reTCode, int paramLen)8 u; b" Y( e( A9 @4 @7 Q; b
{
5 [" u/ M+ X' `9 |1 s$ U$ w}
8 S/ K2 N4 a; C0 p: i
' [/ Y" F; @) w5 d) _: P+ d! T) y  m/*ARGSUSED*/
) w) B8 B( f8 r8 uvoid ufsta(char *param, int *retcode, int paramLen)0 ~5 t( {3 I0 T# |
{
, \) O& n: j5 D* z}
' `4 W* h* _. K  q3 @, w5 o
, c* F9 K( Z/ Y3 tint ufusr_ask_unload(void)+ E2 `# f3 t" e# c$ d6 {& C8 x
{9 }  B' n9 m6 h% d" v
    return (UF_UNLOAD_UG_TERMINATE);, x6 W+ x9 ^# }3 F5 w3 ?  i
}) G# K3 A3 g! j/ y; v4 l+ P, r

; }9 [( u. j# p5 ^; kvoid ufusr_cleanup(void)
  J8 C" G) a3 M9 F: l( n: z{
  I" Z# x8 S7 J/ a    ECHO("NX is shutting down - running ufusr_cleanup\n");5 n. j9 v) }% d$ d5 h; F
2 F6 V) w: i5 M' {1 T& j- [
    /* put your code here */4 r+ m& J3 d& O% z- N: f4 R: h
}[/mw_shl_code]
  d" R# S5 X+ I: f
上海点团信息科技有限公司,承接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
0 a# e3 [; Q2 U8 S1 A. D请问这个函数是怎么用的?有什么用?
% b% Z4 S# a& E# V! o; T
入口函数 改成 ufusr_cleanup 9 q% w/ L; P1 Y& W; ?

" s) i$ s5 L6 b$ w2 n意思是 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二次开发专题模块培训报名开始啦

    我知道了