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

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

  [复制链接]

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

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

admin 楼主

2018-7-12 11:12:47

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

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

x

1 a3 r1 s5 y+ }! \NX二次开发源码分享】关闭NX后,做点儿事/ w* H5 H: ^$ S

- S; T. f* {, ~. s5 u) o[mw_shl_code=c,true]/*
! J8 p# S) W$ b# c% e: V" l5 t6 u* H1 o6 d3 L
    ufusr_ask_unload is invoked immediately following the completion of ufusr
# \" {: x- o6 c( ^+ c3 g$ f  [    (or ufsta when the dll is run from a startup folder) to find out when you* y# \$ F& ^+ O2 T* C9 j4 P/ O2 q6 A
    want the dll to be unloaded.  If ufusr_ask_unload returns7 i8 P9 W& }7 `, B
    UF_UNLOAD_UG_TERMINATE, the ufusr_cleanup is called right before the dll is. r4 B7 ]: M( g5 l
    unload when NX is terminating.  To prove to yourself that this works, set  Z6 e5 s7 w9 @8 l* Q7 [
    the environment variable UGII_KEEP_SYSTEM_LOG=1 so that the syslog will not9 w1 ^' z- O1 b* t. q- Y- x% e
    automatically be cleaned up when NX terminates.  Start NX.  Use Help-> NX
  `4 r+ p- `" U# i( y1 p. X    Log File and make a note of the full path to the syslog which will be shown3 ~$ O+ u" z, i9 S
    as its own first line.  Run the dll built from this code (nothing noticable
4 P9 u$ S% p8 e5 ]6 i7 ~4 ?8 Z; r    will happen.)  Exit NX.  Find the syslog and open it in any text editor to
8 d: v' k' l5 B3 ]; X4 d7 k    see this line near the bottom:
. t" S; |$ @1 R, c1 a; C. h
5 W( j% z( s4 T' W$ i- {" ^, zNX is shutting down - running ufusr_cleanup8 E$ N' H( |; J: U5 E) C/ U% P

$ \: y2 h8 A0 C5 {+ r6 e*/. b$ P  Q; N6 G7 @+ x1 h4 s
#include <stdio.h>: K4 @7 [; \$ a
#include <string.h>! ^# G% J- a8 x4 M* V
#include <uf.h>
* D& w0 W, m& `#include <uf_ui.h>8 {2 z. f, g' [& e5 j3 z- x) l$ l
#include <uf_exit.h>
7 _' C! V) Z3 i  J2 E. J6 o# ~! g1 N2 W# P, y# t; s
#include <stdarg.h>- ~6 Y. M, k- P7 R/ j

6 i# D+ N$ Z6 P" O; Tstatic void ECHO(char *format, ...)
" m: L- k+ q- A" N{1 Z& c5 X% x, G& [8 ?5 e
    char msg[UF_UI_MAX_STRING_LEN+1];
* d6 H) I* D1 d. i# H, P4 a- v    va_list args;: j* M0 ^; H: X5 F
    va_start(args, format);! k+ |3 G1 M$ V" {4 i
    vsprintf(msg, format, args);% i5 L, N/ E% J
    va_end(args);
7 ?! _' G) u, b    UF_UI_open_listing_window();
) C+ @. J4 z& n9 U5 g& v2 g    UF_UI_write_listing_window(msg);! i4 ^) ^0 a# j/ k9 v
    UF_print_syslog(msg, FALSE);# z. f+ k6 }& @  Y7 [
}) ^* n* J  Z/ J/ q5 m
' g& p* l2 r, v5 H' y" u
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))" Z3 k8 C' I1 i' x. \( Z

) m. a# E. {& e+ ^7 }' V. wstatic int report_error( char *file, int line, char *call, int irc)
  s1 ]% @  _1 J. ]{
/ C! p" S; ]9 e8 A0 X. T    if (irc)
' `( G# E# B$ K# z  K& [    {, G( F/ e2 ?$ Z- m8 V% g' |: o7 b
        char err[133];
6 [+ _- F- {, C0 I8 ]" c+ Z) {1 V3 h2 s
        UF_get_fail_message(irc, err);" ^- b: ?8 w+ Q) Q
        ECHO("*** ERROR code %d at line %d in %s:\n",+ ?( U( f  H* P" f; Y
            irc, line, file);5 J4 A$ Y+ w5 ?. S6 M8 a
        ECHO("+++ %s\n", err);2 {/ \1 [9 z4 k' O- n8 e
        ECHO("%s;\n", call);, Z: Y+ |9 K4 S/ Q
    }
! s2 k7 O& |& l! Y& {' C7 g5 M' V3 J2 j
    return(irc);
( s6 u8 z; W& Y" P% v) r}
7 H/ M$ S! q% {: [1 i, s; Y* e$ i& B/ ^5 d  B& q3 k
/*ARGSUSED*/% a% t: t1 k" R3 _5 T
void ufusr(char *param, int *reTCode, int paramLen)
3 ]1 r% l& m* x$ h$ a1 g{
7 {, ~; q6 ?+ M" S# w" X; D, }8 C}* F& Z$ a& w2 {( @1 F$ s2 Q6 A1 e
2 r* g) `4 b5 u% k, G5 B. M: y+ d' a, z
/*ARGSUSED*/- b/ I) ~. w) ~$ g4 [
void ufsta(char *param, int *retcode, int paramLen)
9 T3 R5 f8 d, A) U2 i3 w5 k{
8 b/ n6 e$ e7 _}7 n% K! K0 J* q8 k) }
0 M# m2 h" H$ u2 Q. i
int ufusr_ask_unload(void)
$ I' ?7 E+ Q( P1 g) F/ _2 b. ?{
9 x6 L  f0 m9 e6 C! l1 ^+ w    return (UF_UNLOAD_UG_TERMINATE);: U9 M' I( s0 Y5 A' n& @! b# G
}
7 a6 p$ C' e$ H! L0 Z; A0 O6 [7 V
void ufusr_cleanup(void)
% ]/ H4 z7 t5 y" i3 K9 T{' w( C% L$ a( w1 d; s& o5 M
    ECHO("NX is shutting down - running ufusr_cleanup\n");. @1 s& Z4 j  Q

  v# X4 _7 u$ Z4 L* q" d9 K/ J    /* put your code here */
2 D% S$ \  f) b4 n$ Q( N4 e+ ]0 ?8 b}[/mw_shl_code]4 P7 y; E! k# g" `7 F3 E; W
上海点团信息科技有限公司,承接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+ [9 W! N" p% @+ x7 A1 }
请问这个函数是怎么用的?有什么用?

- ]3 n: v; h: @, J, g入口函数 改成 ufusr_cleanup
# a1 f! _9 g( ~* l1 j) d
# l, |1 W' v/ _( f意思是 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二次开发专题模块培训报名开始啦

    我知道了