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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x

) a9 h- m6 ~8 _NX二次开发源码分享】关闭NX后,做点儿事: T: \. Z# X/ b& }  ^( R

" x0 }9 y1 A- A; g[mw_shl_code=c,true]/*# S$ H% g4 R4 X: @2 I: `6 B: E  J6 m+ v

. {/ ~% s3 i7 ^- I1 o5 I4 F    ufusr_ask_unload is invoked immediately following the completion of ufusr: {4 b0 E+ g3 ]
    (or ufsta when the dll is run from a startup folder) to find out when you$ K9 B4 ]' e; h. n' h4 Y
    want the dll to be unloaded.  If ufusr_ask_unload returns8 d5 [: i4 W* j' B; u/ s
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
7 j# o3 g' i5 ~# L4 Y    unload when NX is terminating.  To prove to yourself that this works, set( `5 T0 d7 b, x9 f: B* x( Y* r
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not! Q% y# L# J! x+ ]
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX) _3 {* p5 V$ H* M3 f+ y
    Log File and make a note of the full path to the syslog which will be shown
7 `8 v8 b/ `- ]9 X8 o    as its own first line.  Run the dll built from this code (nothing noticable
! G7 g9 P8 c' t4 S6 q    will happen.)  Exit NX.  Find the syslog and open it in any text editor to$ p& L' R  r% P- u8 ]* {
    see this line near the bottom:
8 M! j3 U. D' [6 f% I; a0 e4 [, r% x8 {( H
NX is shutting down - running ufusr_cleanup, a+ i9 [! K/ D- n& p
/ W1 k& b* D7 L  e' {0 A
*/( s( R( ~1 w, y4 t, k
#include <stdio.h>; m& [) R8 v1 ?4 p& I6 w
#include <string.h>7 }8 T2 S- p* p/ a5 B% N
#include <uf.h>* j, W$ T( m" H- Q' w$ f
#include <uf_ui.h>* k- i! q+ A8 ^: \" [) ?
#include <uf_exit.h>
' N2 k6 O* U* ~" _9 b2 Y% k5 `4 S2 N7 u6 V( m$ n5 D! Q
#include <stdarg.h>
, ?4 ]1 s+ J2 a7 `$ w+ O1 z; b; e; B3 R5 @
static void ECHO(char *format, ...)
% O; S; x% t( s1 h$ m8 M{
- g2 V* |$ T# X  m8 g6 M    char msg[UF_UI_MAX_STRING_LEN+1];
! p+ Z9 V# C# o' H7 D* A. b    va_list args;
# u5 w- ^" S( v5 w9 _    va_start(args, format);# U8 d- L" W; Z5 f8 T
    vsprintf(msg, format, args);
/ W) f/ ]4 u4 u    va_end(args);: s! |( l. g/ _5 D) {
    UF_UI_open_listing_window();
# r$ T3 X) H  q9 z# k" u% T- X    UF_UI_write_listing_window(msg);
; [: @% S0 o- e    UF_print_syslog(msg, FALSE);
& T" A5 V  }" M/ K1 E8 y}, A2 v1 Y* r! ?
1 P9 b" c* d, V( _
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
) V5 \. _  K5 d" \' b1 h$ G3 S9 G4 ~4 R
static int report_error( char *file, int line, char *call, int irc)4 p  z$ d: i6 u* `
{
9 V" b" w8 w$ T  x8 E9 w    if (irc)
1 Q! _+ ~$ E8 O& Z    {! u+ {$ Z, U! ^5 Z- ]0 I
        char err[133];8 K. r& s( y9 u: T2 f# c! Z

( S# @" i+ \0 d8 ]: x' E        UF_get_fail_message(irc, err);0 V0 X+ c* b% g% j2 |/ Q; A; y
        ECHO("*** ERROR code %d at line %d in %s:\n",! Q* p/ A  x. A+ r. P
            irc, line, file);
' o9 k4 [2 c% O0 v5 \0 j" I        ECHO("+++ %s\n", err);
# [& K9 v- v2 c; v7 T! f        ECHO("%s;\n", call);8 a, x5 ~3 H* Y% d- v' D
    }
+ b) P, P( }4 s& H$ I. I& W- r" m, i7 v
    return(irc);' ]1 Y: ?# M! g" Y0 Z5 g
}# m9 J. S! `) W- m4 i) ]5 v+ D

( u! |3 p7 n/ {7 E4 a/*ARGSUSED*/2 @  m, l  L; |, w7 B6 p
void ufusr(char *param, int *reTCode, int paramLen)* g& _4 M) N) L4 n9 o; G9 D% ]
{* c' |' ?  @2 G4 l7 {! m& H1 }
}
& T2 X0 D; q7 E: |' g, w" l0 s( {( l
/*ARGSUSED*/
8 d5 [% T3 y; {; k4 x- y; r9 n' {void ufsta(char *param, int *retcode, int paramLen)
) Z$ O- ^. r: B; |, f  U{& J/ N; `) k$ m- r+ t- w/ M0 s
}
* y) w: z# R+ ~1 }- H' ^
- J/ g* l% P# ]0 ~3 H7 dint ufusr_ask_unload(void)! S# M7 G+ F+ I+ _
{
. D9 z, R" z8 R5 E& C0 F    return (UF_UNLOAD_UG_TERMINATE);
& V9 p$ b' x; W}
0 E& h  j* A: m4 C
. @( ?' h! L7 v1 I; {void ufusr_cleanup(void)
2 b, U" S# l1 P+ h3 A, }8 ?{
# D$ Q& o% s" Q, K    ECHO("NX is shutting down - running ufusr_cleanup\n");
% i/ o0 t. D# d8 ~8 S& x1 l3 N- @$ B! o. l9 c* M8 M' s5 a
    /* put your code here */
$ N& }- j3 s" P, v' x. y7 h& V}[/mw_shl_code]: Q' B& h: P& g5 I# 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* [/ i0 E" e( ~. j
请问这个函数是怎么用的?有什么用?
9 D2 [4 W6 s/ E3 M. v
入口函数 改成 ufusr_cleanup
7 f0 V; H" w9 K/ X& L2 y( W( `' i% F6 h
意思是 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二次开发专题模块培训报名开始啦

    我知道了