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

[交作业] NX9二次开发培训作业001_使用ufcre入口函数

  [复制链接]

2021-8-23 16:29:12 3768 1

清江 发表于 2014-11-17 16:45:55 |阅读模式

清江 楼主

2014-11-17 16:45:55

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

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

x
本帖最后由 清江 于 2014-11-19 10:45 编辑 6 o4 U/ V- W& e' F& O
) ?- s3 B* l7 c+ K; A
6 a2 n& K! j% t1 z% }. R2 y
11月16日培训课程的作业,运行效果如下图:
0 I8 \: N2 [8 |5 Z- R test001.jpg 6 {3 c4 |3 e) v# b! E6 e3 r* d# V; ^# ]
4 |0 P5 r+ a4 V; i0 F% X
开发代码如下:5 E2 y1 B) ?- s8 ]

+ N8 x3 N5 q1 t/* Include files */9 b! ?2 {6 w9 ~8 a# |; `* p
#include <stdio.h>
* N1 y' A' [3 B% C0 A, @#include <stdarg.h>( M3 h& e0 c& v: t8 F
#include <uf.h>
9 w* K% X% w1 X) g#include <uf_ui.h>
& v7 L& q( U. g' Y( U- E  k0 c* y! O
4 t! g6 [6 V1 Z, @% ~2 Mstatic void ECHO(char *format, ...)2 L% M9 ^( S5 c7 m
{
* v4 I+ h8 ]1 b- s5 [" }0 k4 L6 p1 S    char msg[UF_UI_MAX_STRING_LEN+1];
* j( Z8 o* o6 D  ?$ t    va_list args;# ~0 G7 J& J% q$ d/ X
    va_start(args, format);
5 d0 S2 B- R0 F2 d, m1 g  R    vsnprintf_s(msg, sizeof(msg), UF_UI_MAX_STRING_LEN, format, args);1 j# q2 Y+ `: b$ l+ ]
    va_end(args);
1 r: ~  \" B: A' |    UF_UI_open_listing_window();
( v7 G7 |1 I) n( `3 }5 Q$ ?    UF_UI_write_listing_window(msg);1 B' W9 t2 j2 L5 A
    UF_print_syslog(msg, FALSE);
+ @  x& X8 v! Y}9 w9 f* A; Q* k8 o! T; o8 A1 f: R
5 F  w0 G" W" j4 {# Z' M
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))+ K0 `' ?9 ?9 W

5 V, a2 ]5 i0 T7 c4 mstatic int report_error( char *file, int line, char *call, int irc)8 V% n% p  ]# F& b/ x
{/ D. `0 Q' l. h0 k
    if (irc)
6 q' b5 s* Y9 u    {
8 q" X1 O* G8 O        char err[133];- v& \6 d/ E1 P, c

- X) F6 Z, B9 v0 E! L        UF_get_fail_message(irc, err);
0 p& ]/ h2 {* m8 E        ECHO("*** ERROR code %d at line %d in %s:\n",
* ^& z* n: R. s6 V) _            irc, line, file);
' n, o' M0 E6 V% D0 H( Q        ECHO("+++ %s\n", err);
7 o' v6 S( R" X9 R        ECHO("%s;\n", call);
  J0 b  M. k+ S4 n* x, E) P    }. n4 v6 P6 d; J$ U% Z2 P2 E. |. |

- d- \0 K- }5 J    return(irc);" }1 a/ g# t# K" k3 e% [+ a+ B5 ~6 q
}
# G: ?' R4 F% d/ z6 W# \$ \7 ~: q

: _5 y! m" o# c: K+ [3 V" o/*****************************************************************************! g! u& }- C8 a) ], ^' ?  j3 b
**  Activation Methods8 r- [& k: V# G9 O( j
*****************************************************************************/* Z3 h) V4 T. m4 o6 Y1 K
/*  New Part3 n  a. N4 d- ~; H  q1 \( \
**      This user exit is invoked after the following menu item is activated:
1 _* _- _0 }. N3 B, i# ]**      "File->New" */
# u) G8 j  E( T" {' t0 e+ ]extern DllExport void ufcre( char *param, int *returnCode, int rlen )
0 y6 M# {3 X* \% K{
, R  o7 N3 U# U    /* Initialize the API environment */2 s+ j1 E4 R* @- m5 Y
    if( UF_CALL(UF_initialize()) ) : J  A, i* i# g/ J* X
    {% o) N, F- e3 L: [
        /* Failed to initialize */
- I( N; P' B! _& D; h" j        return;/ l  N' V) x9 \( H* i: o
    }7 ~% ^0 S$ }2 S; Q

* e) }% x9 h# c; J    /* TODO: Add your application code here */) g9 a8 i  I2 x$ J" L
9 q* s* K& t9 d; R* F4 l- p
        uc1601("新建部件名称规则:XjfXXX(Xjf000)",1);5 H+ F4 V, ^( R: k$ `9 M2 T" r2 G

. D/ u" |+ J' O    /* Terminate the API environment *// _& ?* v  ^+ m; J! `2 _. N# O4 W
    UF_CALL(UF_terminate());$ q3 s0 l9 q. C9 @6 E7 e6 K9 I+ O
}
: y! }" u( K5 v, j
' F  [) E. m* e& w# `# U/*****************************************************************************
* A. @3 _( k/ K, J- o**  Utilities
2 o3 w* ~6 S# |$ e/ b, o5 U# W! j1 @) e*****************************************************************************/" {3 u% y1 `2 l; I$ I+ ]( o  o
3 z7 u; ~5 D; c; ]* {4 Q7 X
/* Unload Handler* a  U! R( X. G
**     This function specifies when to unload your application from Unigraphics.
! ?" e" H% Y) ]4 f6 Q* T**     If your application registers a callback (from a MenuScript item or a
8 u7 J5 a! G# n" D0 K7 X. E**     User Defined Object for example), this function MUST return/ `! r' e, Q0 C4 [! E8 d1 F
**     "UF_UNLOAD_UG_TERMINATE". */
9 [, ?6 o. a8 a; @' \extern int ufusr_ask_unload( void )
7 [+ G9 U+ Q1 ^/ D1 A2 P; d% I{
+ K. w4 B8 ]) M; r8 F$ M3 w1 u( H9 Z    return( UF_UNLOAD_IMMEDIATELY );- {% i$ `; D& F2 i3 P+ x) m7 L
}* |! S9 r: [2 E0 d

, R, z8 s' t8 `) j  F1 u0 y: j; ~3 W# v

3 L, s, W* A5 ^1 y; j# d8 c6 w+ t/ ^) |/ f

评分

参与人数 1PLM币 +5 收起 理由
admin + 5 很给力!

查看全部评分

上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复

使用道具 举报

全部回复1

发表回复

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

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

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

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

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

    我知道了