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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x
! }) o0 T0 U7 m( B$ D+ Z
NX二次开发源码分享】关闭NX后,做点儿事
4 i2 H; p8 W3 \: T) x% M
8 n: B# E' }9 b; M4 _[mw_shl_code=c,true]/*( V8 g: c0 r+ A% }, D' l' Q
2 ]3 C& `! J. m; F
    ufusr_ask_unload is invoked immediately following the completion of ufusr
/ `+ u% a9 H  z4 {/ ^- z    (or ufsta when the dll is run from a startup folder) to find out when you
6 J. z, W5 s" r* }: C. d+ i7 W    want the dll to be unloaded.  If ufusr_ask_unload returns
1 H/ U- Z7 s3 |4 n; {    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is8 ]( ]$ x0 H  f+ E
    unload when NX is terminating.  To prove to yourself that this works, set
# u' [' V9 @/ x8 V    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not
/ M5 _0 v, Q& }/ h0 `: U    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX$ z; ?* v' n1 b! F
    Log File and make a note of the full path to the syslog which will be shown
/ e0 O# G4 S  I2 s    as its own first line.  Run the dll built from this code (nothing noticable$ W2 i0 H0 @" \9 e5 f. d4 \+ c
    will happen.)  Exit NX.  Find the syslog and open it in any text editor to* s! p, Y4 H# d6 M
    see this line near the bottom:
; C/ U. W8 _5 }& g1 ]" b
+ c8 k* L# m& Q) ?# FNX is shutting down - running ufusr_cleanup
( {& E6 u: |7 x
3 ]4 V$ J! |1 r: {/ l$ o' z*/
  h* \4 U- P$ e5 W! F+ ^; K#include <stdio.h>
; q, Q. V4 |1 U! T9 k#include <string.h>
; e& `$ T9 K; @' T& b#include <uf.h>9 B% _2 L8 X7 L
#include <uf_ui.h>. G0 q* F% F9 U3 s0 w% E0 [' ^
#include <uf_exit.h>
. s- L! y. w1 l! d$ z: m0 w, w( l
0 N% d# ]6 Q3 Q3 A#include <stdarg.h>
# }- p( e* w+ z' m
* i7 f5 l% E& _! J  Istatic void ECHO(char *format, ...)" p' A: l6 k4 H1 t4 L
{- _) Y# z2 J7 F" n% E/ s2 G  g; N
    char msg[UF_UI_MAX_STRING_LEN+1];" l( v/ ?# i6 e8 P4 e) s
    va_list args;
$ U6 k0 F, O" b* Y    va_start(args, format);" I' S, C% J4 Q/ q% D* ~
    vsprintf(msg, format, args);
2 M7 Z8 a6 Z) M! ^8 R( c$ a    va_end(args);
& B* A7 d, @+ q) e6 {    UF_UI_open_listing_window();. T! H, o. W$ Q7 T) E2 a3 R1 I8 M
    UF_UI_write_listing_window(msg);
7 j' f8 {3 y" d: B. O- d    UF_print_syslog(msg, FALSE);
. k# W: V+ P  u* C2 b# k}
; D9 D2 ~3 d4 e, t' q9 Y( o5 i2 h( \5 I: N
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
  C9 z" V+ k# ]; H
, i. s4 N1 U4 f# j5 b5 _static int report_error( char *file, int line, char *call, int irc)% ~: Z' k+ b/ N$ q: W$ S
{
: n: W9 i4 H! S: J    if (irc)
( O1 M8 u# g6 m9 V7 n    {( H8 s3 l3 m  x4 i+ }( [# L
        char err[133];' Y. L$ g9 {; _
! N( |/ P/ b+ {- a. J/ ?
        UF_get_fail_message(irc, err);+ k8 N+ F* W+ w6 X+ v: O" x! X
        ECHO("*** ERROR code %d at line %d in %s:\n",
% y& F- ]- a1 |4 ~3 q* }/ N% O            irc, line, file);$ x- x3 z( g3 L/ P
        ECHO("+++ %s\n", err);
; X8 ?- R" D& t% \/ g        ECHO("%s;\n", call);
+ O, v, K# x1 M0 F" x) K/ h1 b    }. r, b0 Q7 k/ r& v1 y

: P& u2 E+ Y! u8 \    return(irc);! ^5 i3 J: D( n
}
* s% X& J1 O  d) D- W% w2 V* K/ n4 P: P
/*ARGSUSED*/9 H9 C$ A$ F- p/ v
void ufusr(char *param, int *reTCode, int paramLen)& t! {; T+ q9 V& M5 Y& g
{
: P7 D* f  I8 F$ K' {}
, [- C* f9 V8 |, D& Q7 s- J/ Q$ o6 H5 K2 M; {2 r: s
/*ARGSUSED*/
5 r& T8 X8 [) F  E6 uvoid ufsta(char *param, int *retcode, int paramLen)  Q: \. V2 v& I+ D4 R+ S
{1 [2 o. l: d" l( ^
}
  W3 F, {, U+ @$ i4 C  E5 Q8 ]9 F
% Z8 {& h" q3 d; t) Y/ f* Kint ufusr_ask_unload(void)9 `( L* {- d& O
{2 c- J7 ~* H5 c1 _# O5 x" w
    return (UF_UNLOAD_UG_TERMINATE);4 H2 z9 f' `6 Y2 ~, p4 G
}1 S. R6 Y6 G& k4 N
5 I/ q4 Q8 ?0 e& F9 i
void ufusr_cleanup(void): p; q" T( d$ O4 s2 a
{. S* H: i4 [) I6 `+ {4 R
    ECHO("NX is shutting down - running ufusr_cleanup\n");
/ z2 a' y0 E% r6 z* `! t4 m& l0 i* C' y
    /* put your code here */
6 `6 m" C! G+ j. @}[/mw_shl_code]
0 _. i& `8 i8 u5 v+ 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
% G7 _$ n9 b) }  e  n. K3 \$ s" }请问这个函数是怎么用的?有什么用?
) X4 T& @; N5 a- W, G/ ~5 Y
入口函数 改成 ufusr_cleanup
+ {. D; ^& h3 U3 m" u; Y6 T
' `- O2 O$ L2 j& ]8 G意思是 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二次开发专题模块培训报名开始啦

    我知道了