PLM之家PLMHome-国产软件践行者

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x

4 r3 n8 R2 a5 X! X# w& cNX二次开发源码分享】关闭NX后,做点儿事
9 q5 _4 V$ m4 G4 J( ^6 {; g' N! v; d) j8 D* }) H
[mw_shl_code=c,true]/*
2 `, v2 \, u4 e: S% v& Y# H  C2 Y5 g( r, K, B. u' G: B
    ufusr_ask_unload is invoked immediately following the completion of ufusr, W/ h" W  A6 P! m! y
    (or ufsta when the dll is run from a startup folder) to find out when you! A8 k6 j) F0 J8 J% l3 e
    want the dll to be unloaded.  If ufusr_ask_unload returns
2 E8 K& Q6 [# k    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is) u' i7 \4 ?* i: Z; `
    unload when NX is terminating.  To prove to yourself that this works, set4 S3 @: s( o. D. N; \; A$ x
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not7 ~! B9 W; t8 c9 U
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX
0 y9 M, p8 m% |) j  r: h  Y5 r- d    Log File and make a note of the full path to the syslog which will be shown( [( J* N( p- q  C, [: @
    as its own first line.  Run the dll built from this code (nothing noticable! [8 w$ |, A. r4 G
    will happen.)  Exit NX.  Find the syslog and open it in any text editor to  Y0 @% E, M; k" d2 Q2 t6 H
    see this line near the bottom:
0 x% k3 N* Z0 Q. v. T3 K" s7 r  e* \( N7 L8 ^/ |
NX is shutting down - running ufusr_cleanup
. X7 L$ z0 q) t7 Y+ T( o0 Z* J& K! m/ p
*/
; V) n% s2 E$ x& ^# p9 K#include <stdio.h>
( y$ F8 U! N% S; [8 P- F& C#include <string.h>5 i* }9 x. D4 a9 v
#include <uf.h>
* G+ M6 F/ j# l# h#include <uf_ui.h>0 g" J* {0 f0 o- E0 N
#include <uf_exit.h>
7 D! i/ V2 e- z8 a) R& B/ F& v, A5 c+ A6 m
#include <stdarg.h>1 a6 j& G& d( R. L& q( I

2 F2 N, B( o% h- c5 s" [8 Pstatic void ECHO(char *format, ...)8 z+ R2 h! ?. i0 z+ \
{
; M5 p5 R- j/ L4 d7 S    char msg[UF_UI_MAX_STRING_LEN+1];1 l. H, ~; g& z
    va_list args;
: k' C7 S- o2 j    va_start(args, format);
9 r7 H* g8 |5 H! ?    vsprintf(msg, format, args);$ G3 Z, j5 }5 Q6 ]/ w1 g6 d
    va_end(args);  _" X, k/ ]: L0 F: m& q* v0 ]
    UF_UI_open_listing_window();6 B* A( j, u% x: g3 H, j; T4 {
    UF_UI_write_listing_window(msg);
3 w& z$ G, N7 H5 A' |, T# o    UF_print_syslog(msg, FALSE);
% k! x  h! l2 q}
) t5 Y8 o0 E) C1 ]1 ]' G" k
, z1 _( g" i. |7 z8 \* ~9 h/ j* G; |# a#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X))). t4 P* }* F  X1 t5 s
8 N/ J, _8 ~9 ]. Q& j4 Z
static int report_error( char *file, int line, char *call, int irc)5 V6 s2 ^# T) Y4 T
{
9 a9 q3 O# W+ A& b! w4 n6 D    if (irc)
# G* C: Y6 P8 K    {
# R8 m$ T; L: g9 g        char err[133];
# W0 g% I4 {3 {2 t( b; V: Z5 |! P3 A4 [
        UF_get_fail_message(irc, err);0 X: ~4 C. J0 \" P
        ECHO("*** ERROR code %d at line %d in %s:\n",
& K" ?5 P8 J. y- z, Y+ I7 z            irc, line, file);
  x6 u% G! D' R3 m        ECHO("+++ %s\n", err);0 p( D8 S7 V. X! K1 o' ^
        ECHO("%s;\n", call);
8 S$ u$ e8 N% E; T    }2 G2 p. X4 z; a. ?
0 q3 O& Y# k( \! q! u% p0 H4 E
    return(irc);0 i; @+ s  G& u) W& y- D
}
) x# ]' J3 w1 H* F* E* w
" J2 N2 f. N+ k( l7 }/*ARGSUSED*/6 \9 t# F* e7 o7 x
void ufusr(char *param, int *reTCode, int paramLen)
& Q$ _$ }8 l& u% ^{
% r& Y9 a" R8 I. ]) |& F# z3 d}
, D# f2 L8 Q. N; k8 ^' m( h& X  e. X" D
/*ARGSUSED*/+ z& A( J! \& n, C8 h" |
void ufsta(char *param, int *retcode, int paramLen)% g5 O$ g( L& {8 R9 K7 U
{
7 {- S9 `8 H' i$ u}* y: r: n, M( }& c" }+ w( o! ~
+ ^" O: E6 d) E* {5 j" T; O
int ufusr_ask_unload(void)3 W$ |/ \" q% o. E' O/ P9 D& l% ]
{& k% Y2 _& C7 d9 I' I9 Y
    return (UF_UNLOAD_UG_TERMINATE);4 O4 Q' t' A% x/ n
}
+ X& U  C: b$ A3 J3 q. }% o1 \" y" F$ s- m2 s
void ufusr_cleanup(void)
3 t4 E  m/ z$ D) y" N6 Z* A" k8 f{: n1 v. s) t! Z: K/ Q  b  r
    ECHO("NX is shutting down - running ufusr_cleanup\n");6 m# Y7 w0 o& I- B
. }+ Z2 ]5 q; S5 @/ ~
    /* put your code here */
0 l' H% n7 }( E# G$ n}[/mw_shl_code]
; M7 Z4 W0 t6 g# e* M% i
上海点团信息科技有限公司,承接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 G2 V9 B6 t( E* ?- N请问这个函数是怎么用的?有什么用?
0 V. V( B  q# C% ~! f/ j0 Z
入口函数 改成 ufusr_cleanup
9 L0 x9 Q& Q) F0 A: H! c5 ?
1 M% F& A% L3 \意思是 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二次开发专题模块培训报名开始啦

    我知道了