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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x

6 l3 F% K# E7 [1 RNX二次开发源码分享】关闭NX后,做点儿事$ G- {$ V/ V3 V0 Y

% V7 D* ?3 F7 ?' y1 e[mw_shl_code=c,true]/*; t! k7 o; R! ^2 b% S9 q! z" A
1 |& ]9 b6 H8 s* j, V
    ufusr_ask_unload is invoked immediately following the completion of ufusr; M- I! H3 _" b* S" b
    (or ufsta when the dll is run from a startup folder) to find out when you
  I! E4 i" W  Y    want the dll to be unloaded.  If ufusr_ask_unload returns, T8 I. A: }  n) U; m& ?, I) P
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is( Y$ _8 L( ^% d
    unload when NX is terminating.  To prove to yourself that this works, set2 c: r6 |* ^. y9 e" F: x8 \- M3 A
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not
2 w% d( ^/ n- o6 S: c# \    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX9 n$ a  U2 r5 L+ M6 G
    Log File and make a note of the full path to the syslog which will be shown
3 H. e2 {, O8 L- f    as its own first line.  Run the dll built from this code (nothing noticable
* q- C, x3 E% k# I    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
  l: G& t/ t; a  n  I) w2 c    see this line near the bottom:
) ?" U7 R# b1 F7 r& x' O5 r& I% [7 {
NX is shutting down - running ufusr_cleanup7 a9 `9 u% |8 e4 `" u, ?
1 t4 ]' n+ t$ v) `0 P
*/9 e8 C0 L) x, l. V9 C
#include <stdio.h>7 C7 R! b4 T" N5 ?# n0 z
#include <string.h>
& B" e' f" l; b$ T# s% d  u#include <uf.h>
* k( n$ \0 E  Z* G# s( `#include <uf_ui.h>- k% R! U* W% T
#include <uf_exit.h>
' M8 e7 y. \. L9 g* r- U( \  P: w9 d% Z$ x" Z- o
#include <stdarg.h>
, |3 ?0 ]3 [1 S( {
+ S  m$ p  ]/ Astatic void ECHO(char *format, ...)2 `& b$ n, q  c: \# N
{+ s& X" C3 m# ?2 z
    char msg[UF_UI_MAX_STRING_LEN+1];
# B1 I. w; v# a: |    va_list args;& h+ P! Z9 n9 k. [! b& [
    va_start(args, format);
! q& L) m) Q$ ~2 s: [, ^    vsprintf(msg, format, args);  B( b1 T2 [* J! v" P( F/ `
    va_end(args);# ^7 d* p# R# ?* n, x8 {
    UF_UI_open_listing_window();
+ |; S+ R' w1 R) T' r% v9 b    UF_UI_write_listing_window(msg);
# T( d  V! q  v+ @+ c  ?    UF_print_syslog(msg, FALSE);3 y' R* ^: c* r7 q( Q
}( F$ k$ U- V! Q& U$ L& a: T% a
( E9 Y3 I) ?# c# n
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))4 o: G1 a+ I, ~3 N' E

) X6 p$ `9 Z6 w5 vstatic int report_error( char *file, int line, char *call, int irc)6 p3 s7 a; x5 p2 @
{
- U# E1 \$ M" t  y  @* Z8 l    if (irc)' i- t) L0 m, x+ F3 y
    {
. A/ g; e1 ^% a$ }' k        char err[133];
. A/ p; o9 e4 Q) w
% v4 C; G; k8 ~4 \, q        UF_get_fail_message(irc, err);* F4 s% Z, ?7 B: E
        ECHO("*** ERROR code %d at line %d in %s:\n",
- e" z7 k& M8 t            irc, line, file);
0 ^  G, \4 r6 W: y0 d: n" }        ECHO("+++ %s\n", err);
, V4 _$ t# V6 J! Y        ECHO("%s;\n", call);2 C2 J1 B9 u8 Y" n6 w. n& E
    }
2 {! y3 h4 B; o% I4 ^/ B/ V  C/ ~
1 |# a1 |6 z7 K, m' a, U    return(irc);% d* W/ a# w* ^
}) U* @( ]' ]5 y$ ^3 t

0 V1 a& V( Z& g' y2 c: X/*ARGSUSED*/0 E/ n% w8 N2 W9 s5 b& k1 P9 @
void ufusr(char *param, int *reTCode, int paramLen)3 G3 x5 s! \9 |, b6 d* y! a8 x
{
. v" X2 W5 T6 d" J& q! q}
% C2 T! P* V4 L2 D
# i# d! v: k( K5 `/*ARGSUSED*/
3 z4 D  B7 d% {/ T" {, A. P+ C/ [void ufsta(char *param, int *retcode, int paramLen)
9 x' Q( P7 t4 X{
% s( [! M, c* W( I6 B& p( o4 R}: X. V5 @7 }; v- J

7 O; ?) X6 ^. ^: f- aint ufusr_ask_unload(void)" p$ o9 p3 D3 S" I9 f$ a
{
' S% a0 Q% X' V' c6 P$ a/ d    return (UF_UNLOAD_UG_TERMINATE);! n* `  n6 j2 l  X( H6 f0 |
}% J0 U4 L! ~+ n  M9 q0 U0 j  g

% N  U4 Q; ^' ?0 N) [void ufusr_cleanup(void)
. q9 r  X  r  R" E3 V0 ?{
' _: O3 i/ i& U* U    ECHO("NX is shutting down - running ufusr_cleanup\n");; q0 n+ Z( I7 m8 m8 e

2 j$ @6 d  _7 W5 U3 P. M    /* put your code here */
$ C2 F9 ^, J& a/ P. `+ ?}[/mw_shl_code]& [# e& I, K7 w; w7 F3 x% 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
* R, M0 N6 X+ n# w6 s2 I请问这个函数是怎么用的?有什么用?
6 l4 k4 ~2 l7 @2 f# q* Y3 s2 H
入口函数 改成 ufusr_cleanup
1 A  i/ n& @0 V4 k1 i' n; N5 t0 f1 L6 @4 G/ b4 c
意思是 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二次开发专题模块培训报名开始啦

    我知道了