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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x

- Y- L- l& }2 ~2 h0 K+ O$ J) NNX二次开发源码分享】关闭NX后,做点儿事- L$ Z, v( q4 \- Y+ w$ T0 `6 G1 }
, D3 s; A5 C: v5 w
[mw_shl_code=c,true]/*
& C/ j- O4 {! {5 k+ J% T# x1 K( O# r/ y$ ?4 l
    ufusr_ask_unload is invoked immediately following the completion of ufusr6 {& Z/ z: s0 U5 j4 u% {5 D
    (or ufsta when the dll is run from a startup folder) to find out when you
+ S& d% X7 i% k    want the dll to be unloaded.  If ufusr_ask_unload returns3 s, r  T$ `9 v# F. n8 c
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is; N( Z8 x& S$ V! D
    unload when NX is terminating.  To prove to yourself that this works, set3 t: S! N* x) D: I  t
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not5 t% a& I% x$ T
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX
% R8 f; z9 V1 M* w    Log File and make a note of the full path to the syslog which will be shown
5 d4 t  h5 {* K0 v- G: b    as its own first line.  Run the dll built from this code (nothing noticable
8 `& P4 Z) u1 V4 U$ p    will happen.)  Exit NX.  Find the syslog and open it in any text editor to! h6 v+ Q/ a' A+ p' g0 k  O0 K
    see this line near the bottom:/ {/ B% L) O4 Y! {# A
6 m& q  q- @. a4 ]# |2 b
NX is shutting down - running ufusr_cleanup, t) ~3 r/ }# Q3 v/ ~2 k

, h0 _: R  C, S, T" Z/ n*/$ d: J4 M! E6 }+ I% K. {9 _4 a# x
#include <stdio.h>
/ w4 ^5 d4 @) S$ G' N2 @  e* B#include <string.h>
$ b( s/ }1 N$ p- r% g3 c8 [#include <uf.h>3 [& e0 x1 P! H# f. Z
#include <uf_ui.h>
- \8 ?! A! n; J8 K! G7 M#include <uf_exit.h>. S! v* G' s; m9 e  @9 x, M

. J. G7 C& A8 }% b! |" h# Z4 Q( _& j#include <stdarg.h>
1 M. t6 O1 }/ u" ~1 d6 @
8 A: s* @4 _& J8 lstatic void ECHO(char *format, ...)) M& F8 \; }# x0 h  {: f7 S5 M& k
{
6 q' {+ C% k! x5 {    char msg[UF_UI_MAX_STRING_LEN+1];9 [; R& I8 R: q! n& ~' j/ m
    va_list args;
1 q+ @; r. }# B4 [/ b    va_start(args, format);
. k* _9 x3 D  \  g, k) J: p    vsprintf(msg, format, args);
, F5 ]' }: a0 p, u- ^5 c    va_end(args);
$ h6 I# R: ]# l/ w2 Q    UF_UI_open_listing_window();
5 ?0 ?/ _& {3 ~9 I& D; W# m    UF_UI_write_listing_window(msg);% o; P/ M8 D* f- {
    UF_print_syslog(msg, FALSE);
1 c  O, M4 s0 Q  U, y% ]& C& d}. ^. j5 T8 z: p" D
2 y- e0 Z. R4 t
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
3 {, N* |0 Z' ^% u* ]
1 g  }$ S) o& o' o$ H/ l6 Z: astatic int report_error( char *file, int line, char *call, int irc)
2 ^$ k$ O2 A" p7 [! O1 Y{7 r( n% `4 Q4 S  q) c. h% Q) W# y! k
    if (irc)1 b9 B  g% P( x( X' u* f
    {8 {9 p" U: r7 L9 U3 C; K/ Z
        char err[133];& a9 R* d& Q* G$ z
1 N8 Q0 ]7 C" F! k* S  i% ]
        UF_get_fail_message(irc, err);" n) N$ W5 C5 m, |. d6 w3 D0 `
        ECHO("*** ERROR code %d at line %d in %s:\n",+ ^/ o1 K" U# Y1 y+ m* a
            irc, line, file);
' W# }3 e3 ~6 g# u. H- h7 ?        ECHO("+++ %s\n", err);; k5 ]! m) R& g
        ECHO("%s;\n", call);
9 h+ |8 f/ W, T8 |    }
7 @/ b" C1 ~2 I. m/ c
/ [5 u& P( v! r$ D, O* v3 v' W    return(irc);
" Q. w: q. O+ J( X) F}
7 b' O# F, J9 I4 H+ M+ `( K& G9 Q0 m! |0 f1 }/ w# z0 Q4 _
/*ARGSUSED*/7 T0 C; j- ]6 m  y; Z" u+ P
void ufusr(char *param, int *reTCode, int paramLen)* [- E1 c5 ~  c2 w0 n( i
{
' ^# U+ n8 T# o" m; H# @}/ v8 Z9 B/ _* a. N2 h( X- t' ?. J# q; c

  I9 ]8 d2 z- r. B" g4 W9 }/*ARGSUSED*/$ _! ?) e  p7 M
void ufsta(char *param, int *retcode, int paramLen)
' i3 ?2 B: N$ x- M{
" W& t4 ^& Q8 M3 n* k" f. K}
: w* z& P: y- a3 e9 G: v( v. |7 M. Q$ ]* S4 x6 O" w
int ufusr_ask_unload(void)" e: R  x+ D; T  E. k+ a, i$ I
{
" D4 a! b9 G3 x4 {8 P5 I9 p    return (UF_UNLOAD_UG_TERMINATE);
$ w7 x- Z1 `: Z+ ?}$ h0 \$ |* ?, |; o

6 }0 Q% ~8 B1 Z3 v  b' gvoid ufusr_cleanup(void)! ^8 b  P7 v# a- ]$ [7 o1 u1 k7 I
{
* W+ V: b* u3 J. ?    ECHO("NX is shutting down - running ufusr_cleanup\n");6 h3 l' v2 @6 Z. r$ S

0 d: p4 q8 \  }- u* A6 }4 K    /* put your code here */
4 v/ W0 f) E3 U4 M  k- Q}[/mw_shl_code]
; A/ e. j! ^8 b7 t; d# x" b
上海点团信息科技有限公司,承接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
  p; Q7 f# T1 U$ ?) t请问这个函数是怎么用的?有什么用?
2 I) K- @* c7 d; o% a/ r8 s
入口函数 改成 ufusr_cleanup
% L1 G. @6 ]/ k9 N# H; W0 ^( \, ~9 |# ~
意思是 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二次开发专题模块培训报名开始啦

    我知道了