PLM之家PLMHome-工业软件践行者

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

  [复制链接]

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

2470

主题

1275

回帖

8万

积分

管理员

PLM之家站长

积分
82170
QQ
发表于 2018-7-12 11:12:47 | 显示全部楼层 |阅读模式

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

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

x
- @! U5 U% K: F# l# X
NX二次开发源码分享】关闭NX后,做点儿事
& I6 m' G( L- O- c) K! J8 C; S! ?( ?& y. Z
[mw_shl_code=c,true]/*. D+ l  l- f9 R& d! H
2 ^; Q5 R1 H# {+ D2 @
    ufusr_ask_unload is invoked immediately following the completion of ufusr
5 z1 W+ k" u* z1 O) ^5 \    (or ufsta when the dll is run from a startup folder) to find out when you- s* V; U+ J& P' f2 {
    want the dll to be unloaded.  If ufusr_ask_unload returns
5 C3 a  X* X" I    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is
+ y0 ^% C8 {# _/ M% S    unload when NX is terminating.  To prove to yourself that this works, set3 s; B. ?, |5 e. U) F
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not
6 T# i! f( \( i# b    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX5 P1 w, s' B% k
    Log File and make a note of the full path to the syslog which will be shown' {: Q% N% Q, ?) K( m
    as its own first line.  Run the dll built from this code (nothing noticable
7 ^" m/ C5 V4 h. u  e) K    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
" a6 G: q4 R) v$ X6 W# q7 @$ w8 n    see this line near the bottom:
/ _" t2 t% y7 a; x; R9 I
8 E9 X/ G9 `7 _: ]NX is shutting down - running ufusr_cleanup& H/ G4 M) z( f* H
" s" h% e& @$ i* G! K% k
*/
4 u) h  b, }% }#include <stdio.h>  c/ Y/ ~8 h+ Z7 W$ s
#include <string.h>( c) X8 A0 h% i- @9 l1 I
#include <uf.h>8 H7 ?9 q) r- P1 J2 m
#include <uf_ui.h>  d9 B; C) o% j* m( u' f
#include <uf_exit.h>( _- g: [" U  I  k- \

8 E( I+ @9 Z" A' ^, j#include <stdarg.h>' }, a5 p7 C! M6 i( @7 X; W  |

: [% F, E; a# o$ cstatic void ECHO(char *format, ...)
% ]4 E0 X1 G6 N5 S! c/ m8 k{
+ W/ `2 }) M" g2 _& M! E1 G    char msg[UF_UI_MAX_STRING_LEN+1];7 `1 a2 G8 G  j# h2 Y) K
    va_list args;
6 ~( L/ t9 J0 h% ~    va_start(args, format);; ~+ s- V4 S* \) \! d, _  L
    vsprintf(msg, format, args);6 U, b2 _& S  x) p6 x5 e6 o
    va_end(args);7 e$ d2 Z. _3 {) l8 P* Y% P
    UF_UI_open_listing_window();, l( g, I4 Z5 P% C  }
    UF_UI_write_listing_window(msg);2 e- N0 p6 M1 z; r# Y9 J
    UF_print_syslog(msg, FALSE);
: T. @, r' I6 q" F}
* k+ I7 X; G" I( e3 N, t* a% A, ^: V' e9 k  m8 y, L
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
7 i2 M# A/ A: }+ ?  `8 I' u3 Y! T. u3 j# z2 D
static int report_error( char *file, int line, char *call, int irc)
* S  U8 \, M5 g/ z. G# p& E0 p{1 c" Z0 W' \# C( F8 a
    if (irc)( ~3 P; }3 l) [( j2 ~
    {) _  y5 S0 |. m! w& r, |9 ?
        char err[133];
  z7 O# R4 ~! G( F" }, ~. R2 Y' V6 r. h9 J2 ]* h' A
        UF_get_fail_message(irc, err);  R, N/ V  u) ?' {2 w
        ECHO("*** ERROR code %d at line %d in %s:\n",
; U! n$ n" d* [2 s9 G) Y* G            irc, line, file);
2 a4 s  j" R2 F; x% ^        ECHO("+++ %s\n", err);, N: U" j! i. Q" M# h$ y- n7 C
        ECHO("%s;\n", call);
. r1 s: O! q: i* S% r7 R9 r" n    }
) X/ G+ h8 P( F5 `' n
: q) Z: c  ~: W# r2 _# J, L# L    return(irc);* e0 o" D# M& ?0 R9 Y- E  T& J
}
! U0 J( t5 u0 K, I/ y" H; C, [5 w* m/ A
/*ARGSUSED*/& Y+ I' @1 j6 O% F8 E" t6 C
void ufusr(char *param, int *reTCode, int paramLen)* {$ E3 k0 y! t4 ?
{+ r( w, }4 n2 Z: ~
}
6 E/ v8 s# E7 H$ N, k3 X5 V3 i# m( u" ]! G7 i
/*ARGSUSED*/; Z5 e9 t8 ]* k, ^
void ufsta(char *param, int *retcode, int paramLen)2 b- j% |4 h, k( G) }
{
4 M9 I1 T# {2 ^}
8 E. Q1 E! a6 C% q+ [* D+ R7 R% _+ Z+ v0 O
int ufusr_ask_unload(void)
7 J# O. g* G2 ^' x4 J7 l{7 a& g$ h0 J0 `6 {- a( p# `' P
    return (UF_UNLOAD_UG_TERMINATE);
  H8 B1 Q) M9 [7 ~! N9 @}% ^9 }8 I  `  D) ^

% W& }2 d: q2 L8 h- Rvoid ufusr_cleanup(void)
1 p7 X* J% C7 c" H, W5 U7 L{# N$ U. _+ Y, P4 a$ C
    ECHO("NX is shutting down - running ufusr_cleanup\n");0 D1 ]* V& N& L6 s# c6 D7 L
  }' c" ~( b" |8 J+ c6 |
    /* put your code here */
# ?; n. E, v& ^* W, M/ W6 q}[/mw_shl_code]
" A0 K* w+ }: d! K- o& R  Y
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复

使用道具 举报

全部回复5

1

主题

45

回帖

203

积分

培训VIP会员

积分
203
发表于 2019-12-25 08:49:24 | 显示全部楼层
请问这个函数是怎么用的?有什么用?
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.doteam.tech
回复 支持 反对

使用道具 举报

2470

主题

1275

回帖

8万

积分

管理员

PLM之家站长

积分
82170
QQ
 楼主| 发表于 2020-2-13 08:43:55 | 显示全部楼层
licxsw 发表于 2019-12-25 08:49& H8 ~8 @* P. C- h" n
请问这个函数是怎么用的?有什么用?
3 v, E  u8 H" C6 H  O
入口函数 改成 ufusr_cleanup
+ m# ?5 t- T- n* [% ~3 V4 _) h4 Y  ^6 Z: v" f4 u
意思是 NX 程序退出后,你可以做些事情 ,具体做啥可以自己写,就是个入口
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 doTeam.tech
回复 支持 反对

使用道具 举报

1

主题

45

回帖

203

积分

培训VIP会员

积分
203
发表于 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.doteam.tech
回复 支持 反对

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了