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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x
" Y: C" M  R  k( ~
NX二次开发源码分享】关闭NX后,做点儿事
! O& w( @9 [9 H* p7 K7 @6 Z& T& ~6 B" U5 M. g
[mw_shl_code=c,true]/*
. s( k8 ?, |5 i
  H! Y2 {: M, I5 m    ufusr_ask_unload is invoked immediately following the completion of ufusr
1 ^$ ~6 r) s7 m% P/ B- f# v7 w0 S    (or ufsta when the dll is run from a startup folder) to find out when you
2 G8 [9 l# \# O3 u8 O8 |" b7 \    want the dll to be unloaded.  If ufusr_ask_unload returns
' Z  S) _: j9 E2 I& m    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is7 `8 {+ L7 W6 }" q. ?5 }$ Q) x
    unload when NX is terminating.  To prove to yourself that this works, set% }5 f- b* k* e" @) U# K$ h. q/ M2 [
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not! |/ G& E- D6 i; b) H& Y
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX
" Q: x3 R# F) N# `2 @% K1 x    Log File and make a note of the full path to the syslog which will be shown) R" e5 M6 c) u
    as its own first line.  Run the dll built from this code (nothing noticable) a6 |0 N3 @; a  I' T7 U* \9 X
    will happen.)  Exit NX.  Find the syslog and open it in any text editor to! _& X9 q1 o9 B6 {
    see this line near the bottom:
. Y7 `# W) w( _! p9 i. m" F9 k3 R9 z4 [) f
NX is shutting down - running ufusr_cleanup5 x1 S6 t) F. w5 [1 V# q% g8 X1 {

" v1 G& R8 ^( E*/: V9 P# S' Z  T5 y6 b4 K
#include <stdio.h>
& S/ S% [( G" s( D1 o; X, G#include <string.h>+ B5 s3 Y7 s7 ?4 U. B+ q
#include <uf.h>
$ Z0 n; S% N: H* o#include <uf_ui.h>
! s$ N; P$ H$ C* W#include <uf_exit.h>
! ^$ D4 L6 n& k; O. _+ G* J
, u; t! `) z2 w! R#include <stdarg.h>+ X5 ^, C- ]5 i: k

% v' p& r2 I% f+ e- vstatic void ECHO(char *format, ...)
0 B: z- y8 U7 ^& ~7 w8 C6 @/ t{. p7 \5 y' Z: _  U5 k; x) c2 X
    char msg[UF_UI_MAX_STRING_LEN+1];
  j# S- u' r  |    va_list args;4 L' k7 r* c$ D. a# l' q& h
    va_start(args, format);4 `1 J  f1 n4 `' t
    vsprintf(msg, format, args);5 j  Z( Z. X4 F
    va_end(args);3 O; ^4 y1 W. I
    UF_UI_open_listing_window();0 W: p# Q2 n9 h# A9 l4 _9 r
    UF_UI_write_listing_window(msg);
0 Y& Q3 ~: }% R5 C  a9 e    UF_print_syslog(msg, FALSE);
. s1 n' P9 w" b- {) J}
8 U! W+ n# q0 }$ ?* p& q! \
6 Q* g' r# f8 U# ^#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
& F+ _# y, n, p+ r0 b  N: {4 |5 ~: P  z  h
static int report_error( char *file, int line, char *call, int irc)* Z" e  o3 D# e
{
0 w1 K2 c1 s3 Q$ g, t8 s- `    if (irc)
: W. u9 `% s# R4 x7 R    {4 j; i6 Y) _; q( B0 C4 c
        char err[133];1 ^5 d. A1 s) N- N) j8 t

6 s$ T% q4 C: w0 `& {        UF_get_fail_message(irc, err);
+ k. ~4 w( k$ l( L, N        ECHO("*** ERROR code %d at line %d in %s:\n",& u3 d/ i% X) z# c6 S6 o
            irc, line, file);0 ]" C, A  {" }& }; ]
        ECHO("+++ %s\n", err);
( E, ~, f$ p! t2 M2 y        ECHO("%s;\n", call);6 l- |* d4 @) F
    }! x9 t, a; X/ @+ O: p+ j6 r( {+ w1 y
8 o# B, l  y6 F4 z
    return(irc);/ O% q/ {+ c0 M' i/ `/ Z2 m, o$ o+ X
}
& H$ N! s. z; i. V  X" e# O9 i
$ z1 ^; b4 c2 {' |3 d/*ARGSUSED*/
# W0 A* S" f% u, F' A0 {& dvoid ufusr(char *param, int *reTCode, int paramLen)/ w2 n1 [! L3 _- V
{
) j8 Q# `* |, D}! E+ q9 d( |5 K" ~

  H. ~2 V" k. |/*ARGSUSED*/% E# T( l6 G! g+ }
void ufsta(char *param, int *retcode, int paramLen)
- n+ P/ p- W6 T2 r8 W5 G{- b$ D1 J* y& A0 n# l- K
}
8 p1 J1 A* k9 @3 K% U+ B+ t5 G6 g% k0 E- z# R/ {8 G
int ufusr_ask_unload(void)
  E, J& q2 _2 m{
% M6 Z/ N8 S( j0 Y. b  e, n    return (UF_UNLOAD_UG_TERMINATE);7 a9 R1 f/ o+ ]) h
}2 ^6 g/ }4 B6 W1 T+ `2 V9 g

* q/ b4 d/ k( V  Kvoid ufusr_cleanup(void)" ~$ l, v$ @) y3 Y4 _
{- T9 b) g+ E% c% S* Y* E6 j# [9 e& O- k
    ECHO("NX is shutting down - running ufusr_cleanup\n");
7 {9 a5 q" m3 m& P8 c3 i; t3 v' I; K4 J! _/ c8 m: \  e7 t
    /* put your code here */% _: f: y/ f- w, m( w1 w1 U" \" X
}[/mw_shl_code]" F# ^: n) U  ?% g, k+ q$ _$ n# C
上海点团信息科技有限公司,承接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
& Q. d9 \$ J; x3 K7 x  U请问这个函数是怎么用的?有什么用?

' j; v" X; [7 s! a) {0 p+ l# G入口函数 改成 ufusr_cleanup
5 j7 \6 G2 W" i: ~" @* I) x
1 I. b8 Y3 U! n1 ?5 a$ [$ `' C3 ]意思是 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二次开发专题模块培训报名开始啦

    我知道了