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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x
9 M5 g2 R8 O# A9 ^% ]$ c! y) m
NX二次开发源码分享】关闭NX后,做点儿事
$ f- \9 N. C' t- n4 N! R+ \# ]+ b& W4 V1 y5 w
[mw_shl_code=c,true]/*
' I" ?: f) l0 n, `3 f6 M8 P9 ~* A  x% D& N
    ufusr_ask_unload is invoked immediately following the completion of ufusr
  ?+ U' g. Z7 M3 m3 X2 r    (or ufsta when the dll is run from a startup folder) to find out when you, l% ~4 Y* S& w
    want the dll to be unloaded.  If ufusr_ask_unload returns
* g+ G9 p& E- R    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
! o- p: N" J, H- e8 F4 v+ b    unload when NX is terminating.  To prove to yourself that this works, set& C5 r2 q/ y4 O8 G( U$ Q
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not/ V: m2 T: P- u9 K' M# G
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX
: q$ Y+ o$ A8 }    Log File and make a note of the full path to the syslog which will be shown
7 y3 ?$ y) T9 N1 H$ x* c& w    as its own first line.  Run the dll built from this code (nothing noticable
& T& l5 G( Q( j) m4 \    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
2 F! L, `( b3 d2 Y; A7 G    see this line near the bottom:
) F  |# k8 i2 X) z* k) d; w
1 M& Y; j5 z0 _3 }& iNX is shutting down - running ufusr_cleanup
4 B/ |( b0 a" F# _/ p! F
9 _& S! ~- k9 M*/2 p( V6 V' w! ]/ N2 t* W( V3 k
#include <stdio.h>8 M& e6 m9 |4 @0 o% M; E0 v: f( U- _
#include <string.h>7 A  e) o2 z* N( y5 [
#include <uf.h>
+ B" ]1 F# H) d* ?; |0 l- i#include <uf_ui.h>
) w2 x! E7 e! K# t- N#include <uf_exit.h>
1 P% p, M( P, o1 {
0 T. u, s3 a5 r  E$ l#include <stdarg.h>0 }/ j) ]) ^3 E; q2 |) f- n4 @

3 ]# z4 `, ^5 j0 x2 x  l$ B8 x; Pstatic void ECHO(char *format, ...)8 @* Z0 }$ v) l0 {: J. d
{0 O! j7 @8 {8 E$ l: S) [
    char msg[UF_UI_MAX_STRING_LEN+1];
. |7 _& W% M! X8 O- y: i+ L    va_list args;
5 C) m' h, @# F- e( R    va_start(args, format);
/ ]1 S' m2 m: p+ m3 G4 S    vsprintf(msg, format, args);4 l" p' h8 [) g9 S
    va_end(args);
2 s/ {. l9 x7 m, x    UF_UI_open_listing_window();7 a; }! y/ i9 z; G) W
    UF_UI_write_listing_window(msg);# E: H+ w7 {- f4 c4 H
    UF_print_syslog(msg, FALSE);
) G: c. U9 W, m) B}
5 K4 D  k- @8 t1 V( L8 U( Y. Y3 X% {$ K0 P& s  P9 B
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))9 P; a' M5 B6 I, F& |

. M3 s6 ?: k' O/ X4 Fstatic int report_error( char *file, int line, char *call, int irc)3 ]9 ]& x' k8 e0 \( u
{0 m9 r9 O0 g5 w1 p0 I. |3 U) _% y& e
    if (irc)$ W0 d* ^( q+ M; y0 W8 L4 _
    {+ h. N& d* K1 H; d' b+ B
        char err[133];
1 v) Q- k3 ]% Y7 }. S
" V6 I% R6 W% @2 C: B. M# p1 W4 k        UF_get_fail_message(irc, err);$ m, {& \# W0 _, {1 ~2 E
        ECHO("*** ERROR code %d at line %d in %s:\n",6 o2 E* X" T. j8 K. i7 U
            irc, line, file);( `; T- A' s8 ^0 f! y9 Q
        ECHO("+++ %s\n", err);$ B2 m" T1 Y* E* _& u+ |
        ECHO("%s;\n", call);
, ?+ B+ Y8 s& M    }
% W6 F! Z0 `- M0 v7 W$ @: _/ K* a3 Y; t
    return(irc);# A7 A7 i9 s: `" y( I
}
, c5 i0 U: e$ M& s9 E0 e9 o3 p9 e9 u( B' \. k9 a9 I, H
/*ARGSUSED*/  b2 M$ z  U2 w# g; V4 m
void ufusr(char *param, int *reTCode, int paramLen)
7 F5 F: O' F$ I  D1 @{" f9 f! b( \/ |0 \4 A' }( I
}. ~1 V; I) f, v4 J$ T; t! H
7 A3 `: `4 N  j* N: A# @* H
/*ARGSUSED*/1 F, K! v# P1 @0 ?. t6 n; K* R' g
void ufsta(char *param, int *retcode, int paramLen). p1 W! i) u" {1 n, H
{
; s! g1 K% V/ O2 c}0 ~& w: r0 D' _% q2 s* ^
/ ~- e4 P7 a! H0 g" s  O4 ?! I. D7 Y
int ufusr_ask_unload(void)7 T0 y6 l" e8 G& t
{& Y+ _, t$ {( z5 ~2 p0 k
    return (UF_UNLOAD_UG_TERMINATE);
' R  Z$ K0 }) J% y& r+ A}
. a0 j# Z1 K' l9 c. |* L$ j0 v- S2 A+ J2 `& r
void ufusr_cleanup(void)" F* F' `' w" u: e. [) W: D: Z
{* L+ t) I8 ^. c  m7 i  U
    ECHO("NX is shutting down - running ufusr_cleanup\n");$ K; ^* _& O6 i7 J) H0 R
; r+ |3 G& Z1 m' P6 A6 I% F
    /* put your code here */
% e) ]- d9 B& h5 V" p* S+ F}[/mw_shl_code]
& I3 j( z$ g: t2 {
上海点团信息科技有限公司,承接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
( D6 P8 D/ c9 r( H+ }5 ?% {请问这个函数是怎么用的?有什么用?

; m: f! X  W! v: R* h入口函数 改成 ufusr_cleanup
8 Y( [+ g' D( [; `7 A; \5 Q. ~3 ^. f/ o( T
意思是 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二次开发专题模块培训报名开始啦

    我知道了