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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x

  e7 r! I* U/ p* a* r$ C& n" U3 YNX二次开发源码分享】关闭NX后,做点儿事  S1 F8 |" _( ]# y8 ^- a( k
+ A2 N1 o/ e0 x$ k. Y' d0 H" v
[mw_shl_code=c,true]/*; A+ N) M) c9 W6 C  l% ~
; p% c' x" M" `! e% L
    ufusr_ask_unload is invoked immediately following the completion of ufusr
4 E" q1 ^3 m; s2 l4 c/ L8 ?- I/ |    (or ufsta when the dll is run from a startup folder) to find out when you& Z6 R' |% L6 O6 b
    want the dll to be unloaded.  If ufusr_ask_unload returns+ w9 X/ m# I9 l, G, v. L6 F+ V6 M6 A7 ^1 |
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
7 u: G' m. J* F2 ~# g! n  |# i+ j    unload when NX is terminating.  To prove to yourself that this works, set
/ d1 e( `2 M4 r# V- r    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not: \3 Q. q# n& R
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX
5 ^; e& {6 e6 j) h; M    Log File and make a note of the full path to the syslog which will be shown
. p6 b$ A. p  K3 W1 v# X+ U$ ^. \7 X: \5 b    as its own first line.  Run the dll built from this code (nothing noticable/ D/ }6 ~. c  j
    will happen.)  Exit NX.  Find the syslog and open it in any text editor to, B+ a* ^( j+ D# {
    see this line near the bottom:
* C9 F- K' B1 \. o+ c6 w4 _' x* h
NX is shutting down - running ufusr_cleanup
2 G$ ]1 Q0 B; ~/ x, e1 v$ ^
, t8 ~1 `) g7 |$ u8 ?5 d" j*/, W! q4 H' x! y' b1 R
#include <stdio.h>
+ O; I8 O+ ~& p/ F/ _#include <string.h>& c8 N4 J" v' t7 `( p  Q
#include <uf.h>
8 X# r2 f6 S0 K' L& [$ t- s) B6 s5 U#include <uf_ui.h>
& v; s8 P- a9 x( a#include <uf_exit.h>
1 l( o2 H- d5 A# W/ B0 z- _4 c
' p5 w& f$ D0 B8 B#include <stdarg.h>
1 N& B( T! e* b" l
$ Z( @$ }1 _$ ^% J' s! @' sstatic void ECHO(char *format, ...)0 U1 v7 q/ J" Z) i
{: z' Z/ Q& X, T% n
    char msg[UF_UI_MAX_STRING_LEN+1];5 Y- \, r* T; N: y8 k
    va_list args;" c7 l: H0 B/ q5 f3 @& k: |5 C
    va_start(args, format);" J3 `) X3 C* h- ?5 _2 P1 e
    vsprintf(msg, format, args);
0 q2 R) e& a- _" j    va_end(args);3 [0 P1 I2 v" v7 D, ^- Z
    UF_UI_open_listing_window();- g9 i4 n& H; x. t' r' z
    UF_UI_write_listing_window(msg);
- x, y  @! D! i. Q9 I4 d" v7 M9 ]/ N    UF_print_syslog(msg, FALSE);
+ _  Q" Z/ u5 D6 I}0 b9 g1 S0 ~# C7 u) j% f8 {7 e6 K

& h. h+ G6 a2 \6 A, C0 C6 j#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
9 J0 Z7 d, J  }1 n5 m& r. |
! T6 q1 @; p* Istatic int report_error( char *file, int line, char *call, int irc); m! Y# O: \! E
{
% E( P  D# v# B7 A- s+ W* b' ]    if (irc)) c0 J& O, P2 B6 e+ A, G
    {
3 w+ S0 b4 [# A8 ]9 S1 c1 D6 g" q        char err[133];
. n* {$ I" g. ^
' w2 o( }3 ^; }# z) ?3 v        UF_get_fail_message(irc, err);* r6 R1 i) ^- S! ?! J6 W
        ECHO("*** ERROR code %d at line %d in %s:\n",0 L* V9 L" w2 N) c9 ~" J+ T
            irc, line, file);
% a+ R' ^3 o7 U  \& A5 x        ECHO("+++ %s\n", err);
* q9 A! t1 h# ^) {* `$ b        ECHO("%s;\n", call);
! U) E% n( T: U1 R+ M% o    }
) H' f+ o, i9 K  S# J4 C- ]- [5 f" i; P* d
    return(irc);3 m' M, t7 n4 M2 I7 m3 H3 D2 y
}
4 T( f9 }1 q* ~: O% B
# T; E! ?/ @3 ^, j, T$ T: J) [/*ARGSUSED*/
) t& l2 u( z8 j0 l& \& xvoid ufusr(char *param, int *reTCode, int paramLen)5 n1 \6 i; e* ^( n' ]
{
- ^8 {! c: Y! A$ G* i}! K* q9 R- Y6 V6 Z  ^! i

; C. K3 q8 t2 C- _& D- h/*ARGSUSED*/
, I& F; |6 h5 \  ]& J5 avoid ufsta(char *param, int *retcode, int paramLen): T1 v9 t4 Q- `  {  X
{
; A% O. U4 p  M/ k}
4 k% U, u, m# V$ p% D+ H. C0 a! G2 a. j5 v' b& p
int ufusr_ask_unload(void)+ w6 u( Z" Y! o
{: U) \/ s7 I/ i( a& h
    return (UF_UNLOAD_UG_TERMINATE);$ o! W' m& N. c' T$ C0 d
}
1 c" u. N2 ?4 e+ n1 f
- _1 [: F% ~0 e2 h+ h8 Zvoid ufusr_cleanup(void)$ q; _! P  X! N5 g* {- ^
{
7 B6 Y5 Q0 H( ?8 X& M    ECHO("NX is shutting down - running ufusr_cleanup\n");
2 ?* Z# Y& A5 p1 L7 {
4 v$ V$ z7 v* q# B1 z8 \$ a- O    /* put your code here */
0 C1 _0 t5 l) C. [9 }}[/mw_shl_code]
8 n9 d; y! e' l+ P2 s  ?
上海点团信息科技有限公司,承接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, M5 p1 U( x+ k1 p
请问这个函数是怎么用的?有什么用?

2 u7 U, A( J( A$ U+ y2 N' i入口函数 改成 ufusr_cleanup
% N8 r- [6 i; i9 }
+ T8 l8 x0 N4 ^9 e- t0 `0 j意思是 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二次开发专题模块培训报名开始啦

    我知道了