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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x
! s" {, b+ l: P, W% U# o6 r
NX二次开发源码分享】关闭NX后,做点儿事
& D* y7 E* W+ U* s8 h) x& }& Z
+ L, i' H4 O+ r& s( U- _: z9 N[mw_shl_code=c,true]/*
$ t7 _, I0 w2 h1 s, y
1 ~* t3 ^# V7 H+ w( A& z    ufusr_ask_unload is invoked immediately following the completion of ufusr
1 \! C2 L  @2 A" ]2 h2 Z& W$ |! d& E    (or ufsta when the dll is run from a startup folder) to find out when you
4 M0 s8 U6 I* z( Y    want the dll to be unloaded.  If ufusr_ask_unload returns0 X( L) g$ H' B
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is* {+ h6 a- p6 Q2 L
    unload when NX is terminating.  To prove to yourself that this works, set
1 s3 n& A4 u% z$ L& m! p    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not
/ I. ~/ k- M. k) q    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX( ?  H; P* x! v. d4 K- g5 G# y
    Log File and make a note of the full path to the syslog which will be shown
3 I4 I  D9 Q; \" b  x: C    as its own first line.  Run the dll built from this code (nothing noticable- ]' X1 e4 R& D# m( L0 F
    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
0 N2 e" A- z. n9 X0 x2 e    see this line near the bottom:
& |2 m  o: i' k7 f1 m: ]9 B) L4 q) Q: W4 a# o7 V
NX is shutting down - running ufusr_cleanup1 m  Z! l0 O+ t+ F5 c
9 y: E6 J  \! E- Z7 B
*/
! R# ]7 S7 o, y6 u& E#include <stdio.h>" n, I# }+ [1 E) T
#include <string.h>1 w+ a" {6 ]( N: @7 e; D
#include <uf.h>0 _/ q, K) e! n9 K% f1 C' [
#include <uf_ui.h>
9 T! ^% }2 ]+ a6 H2 H: e#include <uf_exit.h>5 `2 r9 A$ H, p" j

( Y' y( p: b- p0 _6 k; w- u5 [#include <stdarg.h>
  t- G" `- u" o; q: x: L
; w4 N1 o+ T8 c$ G  ^4 bstatic void ECHO(char *format, ...)
* o& r; v, V& \' \0 x# B$ x{  ]. C1 g/ {4 l3 X7 [, s
    char msg[UF_UI_MAX_STRING_LEN+1];) d2 ]: T& M6 [
    va_list args;; Z; K* l+ ?3 o% b4 K8 Q
    va_start(args, format);
3 Y4 i! C4 L& G* W5 x% p    vsprintf(msg, format, args);
0 ~+ E7 S" U; ?* k( G    va_end(args);
: G) B  E4 K6 i2 S) F1 g& p: _# H    UF_UI_open_listing_window();
+ `/ G5 t/ D3 V" n1 `* R' s    UF_UI_write_listing_window(msg);% U, ]0 ~) x! c* b2 T, F
    UF_print_syslog(msg, FALSE);
5 B4 P: C# _% L}
- }8 A% t; y- z" t/ ^4 Q) M# j+ b! ^% ~
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
' v% y" W* I; M  }  H* }3 Q+ N4 e
static int report_error( char *file, int line, char *call, int irc)- h( g% |4 T$ S5 B/ v
{
! L4 R* Z) Z2 u3 n" l4 d    if (irc)
9 Q5 c" w  V! m3 m# ^3 Z    {
) P: Q0 o5 X7 w  s! z6 H        char err[133];
. @' {# B3 s( Q' n3 {" K$ }) X
5 L% ^* i% Y: `0 a' c4 f        UF_get_fail_message(irc, err);
$ \9 _, s- h  I; Z        ECHO("*** ERROR code %d at line %d in %s:\n",& G6 p, R7 n  s3 d& m& }. h
            irc, line, file);
% c$ R* @: _  q2 z5 x* x        ECHO("+++ %s\n", err);
2 e* X" M2 z% C2 z" G        ECHO("%s;\n", call);
/ S7 l, ^- E% z/ g! _. e# `* s- ~    }
/ y$ n' n" {9 n1 U% m# I. T) ]1 ]( O$ G- ?
    return(irc);" J2 m$ I3 V) G0 Q3 n1 P
}: Q5 Q8 H  F0 |6 m

9 B7 V6 e6 {3 j) V" k/*ARGSUSED*/5 R0 G% J* h" L( H! ^* i! L
void ufusr(char *param, int *reTCode, int paramLen)
6 M8 A5 e; @( O/ q6 G1 i9 J{6 y. L9 d8 s- W  p7 d
}
0 l/ `1 J! ^3 Z7 c; ^# T* C- z0 \2 q" B" z$ S& i! f+ A: i$ `' s7 x
/*ARGSUSED*/
( P/ Y9 E6 s7 dvoid ufsta(char *param, int *retcode, int paramLen)- b1 g. W7 R) F, s: `/ G+ C# p4 C: ~
{
7 a- M0 w7 \9 ~! }6 ~}
4 m5 J) B& c2 X! m% m; T- d4 F6 n) {2 a- [/ H+ u+ x
int ufusr_ask_unload(void)* c: @- M& O) a& \. h0 J; u
{6 d! s) U6 F9 h
    return (UF_UNLOAD_UG_TERMINATE);& ?) N9 X  {. l- s& g- f1 [
}$ n( e9 h  L: t5 y
& O5 f  n/ ~* b* d, @
void ufusr_cleanup(void); M/ \( [/ f7 g6 U9 X
{$ C2 u( z' s9 ^! f$ s
    ECHO("NX is shutting down - running ufusr_cleanup\n");- \" M' G6 ^' I3 h1 G
6 |, v1 m9 r( ?5 D9 M5 A" ?
    /* put your code here */
( z3 }" D# d* s  O}[/mw_shl_code]% P$ J* F! h# ^: g
上海点团信息科技有限公司,承接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' t5 Y! t: F; B, y
请问这个函数是怎么用的?有什么用?
9 r, h) i. {- ~3 V% h/ p, R
入口函数 改成 ufusr_cleanup   o- D0 v% p1 [: t
* V' F( A1 n1 O6 u
意思是 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二次开发专题模块培训报名开始啦

    我知道了