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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x

' W2 d$ v! b( i; S! P- r9 CNX二次开发源码分享】关闭NX后,做点儿事
+ H: s6 P: }% G* t) {+ s
; L0 w) U/ E7 B4 ~( l[mw_shl_code=c,true]/*
  p7 f* ~+ u5 i2 ~
: ^9 Y* Q- D# K' L    ufusr_ask_unload is invoked immediately following the completion of ufusr0 N2 }- |5 _$ G) w9 }" ^1 n4 g$ \# N
    (or ufsta when the dll is run from a startup folder) to find out when you& `. L8 }% P/ M% E1 T0 {+ i
    want the dll to be unloaded.  If ufusr_ask_unload returns* l  E' l9 }1 K. B
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
  H0 c- D7 G0 R' l& D: W7 g    unload when NX is terminating.  To prove to yourself that this works, set
, ?" \6 V. a# T$ d% j) f    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not
- Q/ C- a9 E) Q$ U* Q1 n    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX, d1 _8 ]% f3 A* M+ j
    Log File and make a note of the full path to the syslog which will be shown
3 R$ ?7 B: B9 M" T# V    as its own first line.  Run the dll built from this code (nothing noticable
; W, M" G* E( d+ d* i! p    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
. n! i# ?8 R+ M0 z  K    see this line near the bottom:
! q' R. k3 x: P2 X% i/ D5 S) _2 j0 q+ o& J4 I8 r$ l9 A% M. p( L
NX is shutting down - running ufusr_cleanup
) B+ x& K0 O3 b
% Y  m3 @8 ^1 H  D/ T- F3 O*/
( X5 w4 x% v, l3 P! u9 ^  I7 {#include <stdio.h>
# e; o/ Y  R  T7 E#include <string.h>8 [. W" j* ?& n' z4 b
#include <uf.h>
  K! O5 q; K* ?: `+ C6 V& f#include <uf_ui.h># j9 w" B( o& ?; y/ E. Z
#include <uf_exit.h>
* B# R3 ]: l2 ~; L, P# ~0 p6 Y: K( L, @6 [7 s1 c3 Q, y* K4 e1 r5 G4 F
#include <stdarg.h>
: J% w6 F$ U  H6 \! U& U: t8 \$ b8 }0 W6 G% g7 D
static void ECHO(char *format, ...)0 U% _4 i; h' c( C& f/ `
{8 F/ a* P, C& O4 `4 n& Q" h
    char msg[UF_UI_MAX_STRING_LEN+1];0 x6 |  P! A2 K: d  L8 d
    va_list args;
8 H: T4 q% m* f7 p0 s; v    va_start(args, format);3 X- O5 F. l; |; {( m) J  m+ b3 l5 L
    vsprintf(msg, format, args);
2 q; l7 D+ O6 F! I; ^! i# D    va_end(args);  H$ v; q8 L; l1 _" w4 |& r
    UF_UI_open_listing_window();, G# o( L. o1 s4 Q% G
    UF_UI_write_listing_window(msg);
' g0 j) _6 [1 `4 u6 B    UF_print_syslog(msg, FALSE);
1 z( f( X, {9 b6 K; ~! l9 o+ ^}. N3 l4 I2 A9 l

9 M" H( o/ \7 t# C( S/ T#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
8 t* ^4 E- C6 r6 h
& T; c7 z8 h- K6 [: J. O7 b4 Hstatic int report_error( char *file, int line, char *call, int irc)  B( t7 R0 N+ ~% P7 m# j
{
! F. [/ ^9 N+ c" J% Y, |    if (irc)
/ n' {. A9 P/ K# o% o$ w    {9 Q: U2 r4 N8 K4 e2 ^6 {; R
        char err[133];, L7 s' x% e2 e- o# T. O# Z+ c; f

* d. a5 `, z* u3 y9 V" v3 Q        UF_get_fail_message(irc, err);
% O& g6 N' M8 Y) ]        ECHO("*** ERROR code %d at line %d in %s:\n",
& i' x. x1 N: v8 `            irc, line, file);
/ j' t, A% s" S        ECHO("+++ %s\n", err);9 u0 {7 {1 k, Y, O, n" b0 g# I! l
        ECHO("%s;\n", call);
( u- g; }/ A5 f' v- x! j/ l    }3 {8 n+ j& a+ L% N* y
. |9 m9 ~: [8 H$ _% I: a
    return(irc);/ Y' I& l9 A9 t, Q8 O) C
}4 b/ x8 W/ n! W( B
7 C# I& m5 s7 x$ M5 R$ O
/*ARGSUSED*/3 @, S2 O9 E  s5 Z
void ufusr(char *param, int *reTCode, int paramLen)
' s2 |% C5 U6 U1 K1 E: D{( K& B4 y5 d0 P! C: |. |; k
}
% J7 ^! X; D6 W# \# V7 ?' J6 W. p* R. G. t! u' F% E  B6 ]' B1 U
/*ARGSUSED*/
( O% ~7 G! _. ?( x+ e; cvoid ufsta(char *param, int *retcode, int paramLen)
  D; W9 M  ]5 Q{! ^! @5 O" ~$ K1 q1 s: m
}' s  d, f1 {2 J

5 s- @) x# `, _, q* B7 ?) G* rint ufusr_ask_unload(void)
/ o7 `/ M, \: x& W/ G{
: }" s- \! U& K' F( n3 N% M    return (UF_UNLOAD_UG_TERMINATE);
% }; P! J' j0 B% o}: m+ I8 r2 d: F
# O# q& z1 Z  Q7 Q" @
void ufusr_cleanup(void)
6 R" b/ g+ {1 i0 K) z{
4 H8 t* V) o' M% g9 L0 u    ECHO("NX is shutting down - running ufusr_cleanup\n");$ n- U4 l* b. W/ f* g
6 ?% X2 k9 _1 W
    /* put your code here */) W3 b) N2 m& W, Q& n
}[/mw_shl_code]5 W6 w1 t4 x4 N
上海点团信息科技有限公司,承接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) f& p  K8 m" H+ R8 U% T
请问这个函数是怎么用的?有什么用?
5 |0 \0 x+ V1 z- f0 H
入口函数 改成 ufusr_cleanup + Q; I! N! H2 n. R- G

7 S6 w- b' T* I( v% Z, F$ c+ I# a意思是 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二次开发专题模块培训报名开始啦

    我知道了