PLM之家PLMHome-国产软件践行者

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x

' Y4 v4 I: \  m4 W' INX二次开发源码分享】关闭NX后,做点儿事3 X+ G# D( V+ ~- e

: y( f) ?$ U3 @[mw_shl_code=c,true]/*
% k# ]. M4 _1 g1 {
/ v' K! ]8 t" {( O4 I9 r    ufusr_ask_unload is invoked immediately following the completion of ufusr
: I; }3 ?% n! [. e1 S/ E; {. Y% T7 u  V    (or ufsta when the dll is run from a startup folder) to find out when you
; Q+ Y9 }3 g- q3 B: s" l1 h$ i    want the dll to be unloaded.  If ufusr_ask_unload returns5 c. O( P& V2 v) Z0 V  A
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
# H2 I6 u& [( x6 i) b, h    unload when NX is terminating.  To prove to yourself that this works, set
/ I1 o- Q6 |! [) K6 _    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not% n1 j# l& D) l2 p
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX
3 k3 ~( c2 @" d) n6 t9 s( h    Log File and make a note of the full path to the syslog which will be shown$ U: P' }& Q; K: y8 D2 C2 _$ j9 x1 X
    as its own first line.  Run the dll built from this code (nothing noticable
, M& {# B$ R  d, V* c6 D    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
3 C5 D1 U6 X& ~5 K    see this line near the bottom:
) I& {! c& f0 H, x* L
. P8 z4 t& n, `3 w3 P- {7 B9 q- zNX is shutting down - running ufusr_cleanup
( W/ L4 T5 l3 H- Z/ m- Y! d+ U9 A) J  ^8 e  g
*/$ w* {% }8 F( u; i' H  D
#include <stdio.h>
$ c6 f' a& v) G; ]) l7 Y#include <string.h>
8 y3 b9 n1 {% |/ g6 r#include <uf.h>) L  g9 @8 K8 `* X! U" g
#include <uf_ui.h>
1 Y, R5 m0 J4 s* ]6 y#include <uf_exit.h>
+ h3 G4 W; u3 S6 n* |5 Y0 d
, q* Q! h' R' g) w% f#include <stdarg.h>9 h' i3 {7 w' q# j& t5 W) f

1 f$ B/ s6 K$ K( Q$ Q" d. astatic void ECHO(char *format, ...)$ P" z2 Z1 Y" N
{
' ~4 H. _0 W; ~3 g  v    char msg[UF_UI_MAX_STRING_LEN+1];
' U1 s+ o% X$ v+ K- l    va_list args;
0 R; F2 F6 U0 ]) N+ G/ j% e    va_start(args, format);
* t+ a; Q# ~9 J# U" D! U3 D    vsprintf(msg, format, args);& z. h) L3 ?2 W& x4 t% t0 Y4 k% P/ ]
    va_end(args);+ V- [/ G7 ?# z% q8 x" z: {% Q* s
    UF_UI_open_listing_window();
# f; N8 L' i7 a9 O  X    UF_UI_write_listing_window(msg);
6 M. ~5 m% ^, U7 m    UF_print_syslog(msg, FALSE);5 B' V8 N/ c  v# |. }2 q: l
}
1 ]1 v1 ^- x% e* v) o- |  {
! b# ^  @2 y$ H- {#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
1 ~, }. ]' d0 w7 G
) |, G9 f! P; z7 ~/ i, C8 Kstatic int report_error( char *file, int line, char *call, int irc)
  D* h! U* Y/ \; D{
9 H4 O! B7 _( {: d4 p2 I0 c    if (irc)
& L# A2 {- z0 R    {1 O$ J4 q8 g1 V
        char err[133];% m4 x; t6 Q- \

$ g8 V% z7 Y# |' |5 E        UF_get_fail_message(irc, err);
9 s2 I5 m8 g% W* m& [6 p, P; B& F        ECHO("*** ERROR code %d at line %d in %s:\n",
: I2 i( @- n% x" @3 F            irc, line, file);. ^: w* Q9 v# x2 U6 J( H
        ECHO("+++ %s\n", err);2 d4 M0 `! z8 E! \' ]
        ECHO("%s;\n", call);2 b- J% m, V0 J5 u
    }' h) X7 G0 ]2 I+ X$ B+ i" T
; s6 q8 `/ V9 J; y  F# N
    return(irc);
$ M$ Z* Q8 p8 a; e; K9 F/ V8 D}( @( c/ h8 I& B

. _- R0 z( q( D4 z* W5 n6 \/*ARGSUSED*/" R4 j- s9 I; i: u2 t; e+ s9 U2 T9 d
void ufusr(char *param, int *reTCode, int paramLen)" w# `. e8 h- b, M: I' W
{- N5 g( n5 g7 b
}
& {! b' K! ^, N- l2 u& s
0 s' ?' C( K- E  x/*ARGSUSED*/7 c6 D5 H4 B) b& w- P5 A, r# o$ E
void ufsta(char *param, int *retcode, int paramLen)
/ }7 C+ k- f) o5 K{& q1 J+ g% j/ ^$ M$ X0 _
}2 M& y( L* L% T* O

2 B& ?& J  N+ C! x5 }: @" r# K1 Kint ufusr_ask_unload(void)
* M9 W' E$ y( b# q% `8 M, b$ Q{
: |+ l8 O( n+ q8 R* l) V) z6 C( H0 g" q    return (UF_UNLOAD_UG_TERMINATE);
" s$ n& z+ A; i( x( X/ e+ V5 m}" A/ k: U+ [; U9 E$ U

, M; A/ Z+ ]# lvoid ufusr_cleanup(void); C3 j- j8 [1 k3 L" J8 P# w
{
" }4 g6 Y- M; V    ECHO("NX is shutting down - running ufusr_cleanup\n");( q) @2 D) r& j: W% ^% }  T
% o! ?) c4 a' y% z- [4 U
    /* put your code here */
& q5 @8 R4 o0 h2 u9 F6 @0 P6 K}[/mw_shl_code]
! G& N! I& \3 G# e/ g! V; 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
! T/ V4 R3 K$ l  ]2 j  p% E9 M% Z请问这个函数是怎么用的?有什么用?

- [# r; d: a  a, U) }入口函数 改成 ufusr_cleanup
: r, F( X2 p/ ?6 R: M3 x0 n  G0 A  q- Z! \
意思是 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二次开发专题模块培训报名开始啦

    我知道了