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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x
1 }1 }+ w: s8 T' U
NX二次开发源码分享】关闭NX后,做点儿事
4 k' `6 R6 y, J: @& G& k9 s& X4 T
[mw_shl_code=c,true]/*- k  H1 l$ d; y- e( r
' x5 `- O' k+ a
    ufusr_ask_unload is invoked immediately following the completion of ufusr
1 V& q' l4 Z) o/ g+ R$ u1 O2 O    (or ufsta when the dll is run from a startup folder) to find out when you
, l) B# r/ c5 _- ]: {3 A2 p! T, v    want the dll to be unloaded.  If ufusr_ask_unload returns
, `2 ?5 n1 W& Y# {9 g0 ~  ?    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
4 m/ @. p2 r+ [  @% ]' k    unload when NX is terminating.  To prove to yourself that this works, set. U) w/ |, W. O  B! N3 R
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not
/ n" a7 z: q6 s& ?    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX9 i. K' }: n' W4 o/ D6 @& V% N
    Log File and make a note of the full path to the syslog which will be shown. W( G( f% G* G. D( }
    as its own first line.  Run the dll built from this code (nothing noticable
4 x7 Q4 ~, k5 p( R9 e" z* O    will happen.)  Exit NX.  Find the syslog and open it in any text editor to/ B! u7 O9 F* K" k& e9 n, W
    see this line near the bottom:
' L3 m& x' [- g- b, g4 W6 ]" M- G" L. w
NX is shutting down - running ufusr_cleanup/ p# @2 |# l' ]& G, @7 U7 T

& u" x* J: Q2 T+ i+ f7 E  n*/6 P- t- S/ d. C' F
#include <stdio.h>; o+ |: o* {- C! D5 r
#include <string.h>
! b( V* Q4 ~4 i* i#include <uf.h>
! V1 |$ T6 n: w& O' w, G: J5 K#include <uf_ui.h>
8 D) i5 I: V% ]! c1 h#include <uf_exit.h>
+ o  l& r* d! h2 B$ j
% D" o1 @6 M) [* U! _! L#include <stdarg.h>
6 D) e- d% ?0 v. H6 `
8 M/ C2 Y; W  `" z5 i$ dstatic void ECHO(char *format, ...)3 |, T: u5 L) |$ |# Q& j6 \6 f( j. Z
{
) L( q7 Q- s# F    char msg[UF_UI_MAX_STRING_LEN+1];+ t0 t6 n4 D  C
    va_list args;4 F3 q, b  \/ O7 M2 R5 I- v
    va_start(args, format);% T8 r' U7 ]3 z% ~: o- E& o/ H( Y5 s
    vsprintf(msg, format, args);
' }: o$ H! G! e    va_end(args);
) k+ S. J# A7 ]# _& b& m2 Z8 N% C    UF_UI_open_listing_window();
9 P9 p7 I, P- R* W    UF_UI_write_listing_window(msg);
* Q! Y2 ~( c' B/ o: M    UF_print_syslog(msg, FALSE);  H! S' A) [' V7 L
}
( K- O8 q  J7 z4 K& }
! ?! ]7 C. O  Z" A#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X))); z6 o, R+ n/ {% p3 }/ Q
# t  {8 R! Y  `0 f  L! X  |2 v1 m
static int report_error( char *file, int line, char *call, int irc)5 y( R. R+ j: z1 {( M2 J- E$ |3 @
{2 E1 J, Z; G4 Z
    if (irc)
1 H  I& V; R, z( S* ~    {; M5 i, H$ e! L4 y3 y; O4 B
        char err[133];
# N; ^4 a/ {4 D6 J
! f! l+ r1 t2 _2 w& o        UF_get_fail_message(irc, err);( S- `1 G" D& q8 U
        ECHO("*** ERROR code %d at line %d in %s:\n",0 o* p' E- ]7 ?  R0 V
            irc, line, file);, g- G0 Y% R. O" p4 y+ s! ^- l
        ECHO("+++ %s\n", err);
: c& s) }  l) ^! I) f        ECHO("%s;\n", call);  G: v8 G: X. P% O6 B
    }3 R( q; W5 p( [/ P0 b& a
0 D# ~- O2 \) B6 W5 k
    return(irc);
6 f4 G) S: P6 [; s}8 M1 Q' z3 E; T6 @

+ X/ @4 b% d5 w4 ^" ]5 H( p/*ARGSUSED*/
9 q6 d2 ]5 ^  y& A9 lvoid ufusr(char *param, int *reTCode, int paramLen)$ f5 B6 V, D7 s. ^
{
: I7 ?1 ?/ O. B; l/ v# y5 G}
0 k  m" W0 M1 U+ \1 g: z: t/ E4 {
% \) ^: X- ?% J/ U- h/*ARGSUSED*/
8 y3 [, F1 N: g6 A) c0 svoid ufsta(char *param, int *retcode, int paramLen)
! R# }' m" m' I" z4 J4 A{( @. K. |# n' x) B0 I7 T6 {! `0 G
}; u7 Z9 T9 a9 {
7 O$ }( I. u' U% M4 ~
int ufusr_ask_unload(void)
+ j+ _: q& \! ?. j/ c{/ X& c  |6 P3 V% }) g6 i
    return (UF_UNLOAD_UG_TERMINATE);& n$ y$ Y- P/ |0 O+ N+ ~$ F  S+ }
}- [/ G* p7 ]9 c$ D1 P
- P  y6 K6 p$ u
void ufusr_cleanup(void): D$ N- @4 ]+ _3 n$ }
{0 d+ `6 ~% I5 {6 I5 x) f$ y
    ECHO("NX is shutting down - running ufusr_cleanup\n");$ g  B" D5 l6 U! Y1 X3 `6 C

2 D5 x3 G# ?6 K( I    /* put your code here */
$ _! i7 J% z  T( Y2 y}[/mw_shl_code]& Z0 T$ S- H5 Z- t$ B8 J
上海点团信息科技有限公司,承接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
6 S* P6 {4 v/ X6 k  K! e请问这个函数是怎么用的?有什么用?
' g2 k' r- P6 x8 z+ W
入口函数 改成 ufusr_cleanup / {$ s# K) |' A! d$ Q) ]

7 k# j2 s% N9 I$ {& }) 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二次开发专题模块培训报名开始啦

    我知道了