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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x

7 \+ B8 J7 ^; C: V/ RNX二次开发源码分享】关闭NX后,做点儿事
# `$ d* L9 `3 d$ F, v4 ^5 }3 G5 ^
, f1 G0 L+ p' q. E[mw_shl_code=c,true]/*% G, d* M- c) L8 i/ x' p

: L# G1 r' O- @    ufusr_ask_unload is invoked immediately following the completion of ufusr
3 R4 R. x/ z/ l) \$ U    (or ufsta when the dll is run from a startup folder) to find out when you% Y, o2 u5 Q" B# q3 w' X
    want the dll to be unloaded.  If ufusr_ask_unload returns( g7 h, ^5 ~* V3 O: v* @9 O5 i
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
. |; a) E. L* Y    unload when NX is terminating.  To prove to yourself that this works, set
# K: t7 g  ]2 @/ _+ d! v$ s: X    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not
7 _& L0 u( P0 [    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX
, R+ X9 @' D" o    Log File and make a note of the full path to the syslog which will be shown5 T+ c9 a6 f2 o- K5 L7 x
    as its own first line.  Run the dll built from this code (nothing noticable! p6 }6 v4 l: p# m9 ]8 q8 Z
    will happen.)  Exit NX.  Find the syslog and open it in any text editor to  O+ _3 R+ Q" D' Q' C3 ]0 |" ]0 D
    see this line near the bottom:
4 C5 x6 _. q/ Z6 |% t0 f, `0 ^) r
NX is shutting down - running ufusr_cleanup
! u! F* @: G) {" }8 p/ Z: y1 j) j6 F$ f4 e; m2 }4 h0 N
*/. Z& a# V/ S$ X) s) [7 ~6 Q1 U. m
#include <stdio.h>
- ?, c5 Z% B1 [% ^#include <string.h>
! q, n/ |9 W" S% Z  b1 P& R#include <uf.h>
# r/ g6 N4 ~* u7 A6 c/ z3 s#include <uf_ui.h>
: ]3 _/ A# B: v9 N#include <uf_exit.h>
, x+ Y5 S7 L" T0 i3 u5 D# C  v$ l& C3 X
#include <stdarg.h>
. l2 D* G) L4 g
: r0 G6 V" o& M4 s9 u! Vstatic void ECHO(char *format, ...)5 T" G3 c  c% c: n( N+ L7 c
{# z8 J, ~  _) I+ u  _
    char msg[UF_UI_MAX_STRING_LEN+1];
0 `* O0 ?) |9 J9 N3 ]: }% q9 a* L( \    va_list args;
0 j# W8 n9 h. @3 X7 A    va_start(args, format);/ W+ A) P9 T3 V$ a/ l3 q$ I
    vsprintf(msg, format, args);) I1 d' Y' o% R- U# c) C/ _
    va_end(args);
4 [' \" m! C0 X    UF_UI_open_listing_window();4 A" ^% q- D3 O) H
    UF_UI_write_listing_window(msg);
" q: C7 X" ^4 h$ y$ N. t) d  n" |6 t    UF_print_syslog(msg, FALSE);9 H. A$ l$ M, A5 R- O7 u
}
, Q) p% Q6 {2 K- O9 v# M6 `! g8 ^; w4 x  S
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))5 C/ ~9 v; S5 S. Y- }0 `: d* k
) H% v4 a1 v+ `8 W( d' g
static int report_error( char *file, int line, char *call, int irc)8 g7 Z2 k3 a- v# F
{. T) L  T/ x6 y0 Z% G
    if (irc)
  E* v9 z/ b. {- D6 a) g    {
2 T, _. q4 B% A2 A4 w( a% ]        char err[133];
+ Y# J* `5 }9 J  G) s3 o
$ q2 A  d3 J6 \& T  R        UF_get_fail_message(irc, err);
* d. K* q2 Q  F( a, z$ M, F        ECHO("*** ERROR code %d at line %d in %s:\n",5 L$ t1 A6 i8 ^/ X, J' J: s1 C% j
            irc, line, file);( w  u/ g/ ?' g/ j% d/ V+ V# h
        ECHO("+++ %s\n", err);+ K8 U( \! n- v$ G- \4 n
        ECHO("%s;\n", call);4 H( G) }; s# g5 Q5 ^) l) w/ n
    }
; J& D) I+ s3 J7 z5 @# U& u
+ w7 O  l6 Z& v5 c    return(irc);1 D0 M, n2 V' j+ F. G* W
}/ R% M. Y+ s2 O

9 T, ^  j* W& \" J& n' N' n/*ARGSUSED*/
3 w8 Q" S' N) f8 g" ~void ufusr(char *param, int *reTCode, int paramLen)
; Y+ G/ B1 f' H7 }{# v" h6 B' B$ Q  c
}1 u$ X: S- e# i" F& b
, W5 [6 @" Z# U, }
/*ARGSUSED*/- T. _* x2 Y! h' X
void ufsta(char *param, int *retcode, int paramLen)2 m/ @! V4 _0 ~" l$ B6 x5 ]
{
7 G+ Q1 B, F  C" j$ e7 ]}& T/ x; C5 J8 @- e  ^  M5 e
7 v, c; O" _9 O4 v7 J3 V
int ufusr_ask_unload(void)
/ w3 t! Y9 o' j{; g$ t/ l2 M' c+ k# _" R
    return (UF_UNLOAD_UG_TERMINATE);
; m& [2 \5 ]4 H2 X  u" I}. m- Y0 X7 B/ h' O: `4 F
2 n% U" A+ f4 I" O. x+ F1 H
void ufusr_cleanup(void)8 f- r4 z2 C& A  O, l
{
  M% r1 S' @$ _0 a% Y. U7 x* e    ECHO("NX is shutting down - running ufusr_cleanup\n");' u4 {, O2 u# ?) Z$ H; G
8 X: T( `3 F* {) g
    /* put your code here */
8 }* \4 z6 I9 X}[/mw_shl_code]3 v, q3 J2 o/ o9 ]7 I6 z: r
上海点团信息科技有限公司,承接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
& l  x! U  H% [- z' U% F/ H9 d& q请问这个函数是怎么用的?有什么用?

& ^/ y6 W- P$ D# c! Z( W9 [$ E入口函数 改成 ufusr_cleanup ( ]. h& O! G5 K1 `5 A  @, D" y0 X

* ]5 Y8 f: m( y' P/ p# e意思是 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二次开发专题模块培训报名开始啦

    我知道了