PLM之家PLMHome-工业软件践行者

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x
4 O; V$ H: S- e; X5 x* L" u
NX二次开发源码分享】关闭NX后,做点儿事" q( {5 W" M2 }
. z, v- n& S; a
[mw_shl_code=c,true]/*! \& r4 x* ?+ t1 ~" F
0 U$ J  _- R) j9 x4 Q9 s
    ufusr_ask_unload is invoked immediately following the completion of ufusr; ~. `1 d6 |# }' T
    (or ufsta when the dll is run from a startup folder) to find out when you% |# h6 l9 ]; y/ ]# t5 ?
    want the dll to be unloaded.  If ufusr_ask_unload returns
. p( p% x& }- V" b+ C' E    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
- q% E' I6 r2 ~* x    unload when NX is terminating.  To prove to yourself that this works, set3 o, K; `4 b1 x7 T5 N; j& @+ f
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not
/ T- Z% `3 T7 v' D: b" |4 K9 s    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX) W+ ^7 |4 `) y
    Log File and make a note of the full path to the syslog which will be shown
4 n" ~, U, j9 m# g: y+ w    as its own first line.  Run the dll built from this code (nothing noticable
/ l3 n5 F" N: t# O4 Y3 Q    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
1 h& k! Z, e" z& e. s0 [    see this line near the bottom:8 \& o# |$ [7 |

! Z; w, c' f1 h: A* [4 INX is shutting down - running ufusr_cleanup
( m# n# J' c6 x1 ~% c3 J' ~, l  d, \0 |( Z% J+ i
*/
$ w3 v0 g* P# J#include <stdio.h>
3 C3 z$ L) w7 ^5 f# m; L; P9 }' b, b#include <string.h>1 L9 @% G8 g9 @$ N; Y
#include <uf.h>
( L" [/ b: ]( J" S* G/ [( u#include <uf_ui.h>  ?4 N& C1 H3 p" Y3 W
#include <uf_exit.h>/ I/ O# q/ h  x3 g; b; `
5 i4 c& ?7 b+ c+ H
#include <stdarg.h>6 i% H& J7 \4 Y; V" [0 F  g' G$ u
8 f) S, T$ [* S- {' l4 n; b
static void ECHO(char *format, ...)
; H; B/ D( o; o3 {- v3 L; O8 M2 c{
, f! H- c% ~, m" s' ~. Y    char msg[UF_UI_MAX_STRING_LEN+1];0 v- M- `0 i& H, h* Y
    va_list args;+ E  c8 q) p$ n6 z. ^
    va_start(args, format);
" L; D( h: R% B( n; u( C0 h    vsprintf(msg, format, args);
$ X+ k/ ]& X3 ]2 e( u* B  y: _    va_end(args);
( ~4 @' u8 _% ^0 J7 S$ |    UF_UI_open_listing_window();$ q6 ]; e" v& B& O/ [4 E
    UF_UI_write_listing_window(msg);
- J( ~" W4 A" L- w/ J    UF_print_syslog(msg, FALSE);
$ I8 s5 O/ K1 z' T3 ?( |}! {3 C: b+ H& Y; b, j3 K' X2 z6 R

7 w' a( A4 B- b#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
5 a3 ~$ {. v) `6 P% r( e* x
  V' S! y8 ^$ z: s; Gstatic int report_error( char *file, int line, char *call, int irc): E! i7 [6 L' G  [8 X
{
7 W9 @- U# e, X2 A- w- O+ q' `& Y* Y    if (irc)
+ y' x( p) s' ]/ I' e+ ]! B$ N1 X    {
- q1 T/ v# r+ p, g+ E! X$ H2 k        char err[133];
6 A' Q9 f4 T+ r1 O  |: o
2 ^) ^; |3 D+ q- l5 X# F        UF_get_fail_message(irc, err);
4 R4 g" e; Z% P) U: B5 i. W        ECHO("*** ERROR code %d at line %d in %s:\n",) x) w% W" }; `( ^
            irc, line, file);
; y- d" A. A* W/ G, e        ECHO("+++ %s\n", err);# j: I" ^+ {0 a6 g1 P7 P; T$ A
        ECHO("%s;\n", call);
/ B. l" m' o, ?( c. \: O    }
  }  S8 |& v& @. F; d8 P
2 U* |' F5 J5 f. U& K( n1 u1 d    return(irc);
6 w* k4 ?/ P6 y8 s4 \& h}
2 S1 z4 }/ a) \+ q/ w. P  X1 o, o9 |7 c* }) _
/*ARGSUSED*/
" o& D" m8 }; W9 tvoid ufusr(char *param, int *reTCode, int paramLen)9 H  x9 j  H0 i5 ]
{: `/ j0 N8 W4 \! h' ]$ D
}* ?) J9 e9 f5 p, u/ L( D
3 f+ F0 u) |" k' r1 X4 {8 `
/*ARGSUSED*/
4 I0 G5 s0 ?1 A& q( `void ufsta(char *param, int *retcode, int paramLen)
) O" H2 }/ E, K4 j{
( K3 J! a: p$ X}
+ c" t% }9 {) \9 l) u' n" @+ J+ I& [, d+ ]1 E& {+ I; b
int ufusr_ask_unload(void)  a! a5 J( P- T  Q+ X
{! h5 {8 m& o: {4 |& M1 i4 ]9 Y
    return (UF_UNLOAD_UG_TERMINATE);
2 J* j. p' s5 t$ W, r}
; d3 e# u( |* F$ a+ v( m# }$ x# ]4 U. M& I: A. T& D! E' x
void ufusr_cleanup(void)  k- q$ U) J3 u# K
{4 d/ ]$ G# `) U1 {- R) D. r
    ECHO("NX is shutting down - running ufusr_cleanup\n");& L2 R, D: h3 }: {8 e, P5 `

4 y) ~' j! Q0 H# V" Z6 ^5 c# z4 K$ W    /* put your code here */
; m& }- N: G0 k9 U}[/mw_shl_code]
3 f' I( w; x0 b6 k
上海点团信息科技有限公司,承接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
8 x0 _8 c4 g- U* A请问这个函数是怎么用的?有什么用?

7 I7 Q1 U! l, ~( S' B入口函数 改成 ufusr_cleanup ( T& S6 j- i9 [" @# R
  o; ^' S8 }; T' C, F, W
意思是 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二次开发专题模块培训报名开始啦

    我知道了