|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
. ]8 s+ g% i- g; M& A. q: x
/*****************************************************************************# s! \2 D& n- g
**: X7 k* ?2 L/ P
** createfilebox.cpp
# B& H, W ?7 q7 O' {# Q**8 B( o5 H2 n# f9 r4 l$ I
** Description:
& \; y4 b: _- e" `8 n1 G** Contains Unigraphics entry points for the application.* S( }4 Y2 ^ P5 X5 C" D+ j
**6 {4 `) e) l) V" E A
*****************************************************************************/
/ [- w i; ] i2 F! Z. U O/* Include files */
+ i; S6 D4 C& E( [#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )* q4 H7 W4 V* {) q% ]/ y# M
# include <strstream>
/ J3 n- \6 X+ q; Z# include <iostream>
8 z- e$ b8 g0 j7 R; w/ Z using std: strstream;
! k; m3 C) ` D# N: q4 U# z using std::endl;
' R6 e( X& o" ]3 R/ L8 Y3 ` using std::ends;
3 L% A0 f5 c5 z" V3 Z using std::cerr;& X$ V* z3 G- C
#else) [( A, z% e# m
# include <strstream.h>4 _* E# V2 H5 o' U
# include <iostream.h>
V6 ~# A+ `9 X8 q% e. J. Q#endif ~" X* G# Z% q* |. r7 L6 g6 n
#include <uf.h>
0 n5 U1 t X8 v3 A8 Q0 H( t! H# A M#include <uf_ui.h>
2 M2 ]& }% c1 j8 @#include <uf_exit.h>
7 V( ^/ k8 L% a- f#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
$ V% D# {( J* C9 G# w. [! ystatic int report_error( char *file, int line, char *call, int irc)
5 \" h- G* k/ F j{+ L3 G( x% p) j( J4 O4 P j
if (irc)
% X# s) t6 D) x: L! V# d3 B# l, H {
% R& P n# F0 {; q0 r char err[133],
( L) G. \% f1 v* Z" u7 K2 O msg[133];+ ~8 _, v, @2 C3 u# c8 z
sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
! X2 }; f. o8 p8 q& O/ W irc, line, file);( L3 C2 |( i4 S U- D5 ~9 F2 D
UF_get_fail_message(irc, err);2 L9 \& l; m+ h
UF_print_syslog(msg, FALSE);2 M% Z4 X* z. \5 p! r8 s. @
UF_print_syslog(err, FALSE);' c7 n- w' n$ w8 T. _
UF_print_syslog("\n", FALSE);
6 B' w6 i& h7 L. V5 b" f UF_print_syslog(call, FALSE);
# n. k z2 f' D, D V5 Q UF_print_syslog(";\n", FALSE);
. _) E/ W* V$ Q; L& c/ T if (!UF_UI_open_listing_window())& U8 r. R3 }& O- B$ _, U) L5 W& G
{: ^- p1 A. I7 ^3 j" `4 f$ G5 q
UF_UI_write_listing_window(msg);
9 G- B$ M4 Y8 l/ _4 ^ UF_UI_write_listing_window(err);, i+ N; x- ^: S/ F" _+ {+ @
UF_UI_write_listing_window("\n");
3 y/ m& r6 K9 Q! C [2 V UF_UI_write_listing_window(call);
+ G' N; L5 b7 M. |$ V; d UF_UI_write_listing_window(";\n");
! E/ t% B4 p# M4 j& Q# {7 y }
/ M8 n$ e# ~& X A; s. L$ v) g }& D; |. a; z# J r1 j( j
return(irc);
) D# y& F5 W$ B( n( G1 t}- j6 @+ e$ w1 j/ y6 {
& U$ `3 i* x! q K* M! W# }
/*****************************************************************************" U' {0 K! ^, | ~- V9 w
** Activation Methods
. u( g) e7 l# ~* B; _! x0 l$ m*****************************************************************************/" m; y# G: _* Z$ Z" c' N) Z
/* Explicit Activation
" t8 y1 m3 w$ N: S* q** This entry point is used to activate the application explicitly, as in
: ~8 |3 W0 V/ H+ {6 q# c** "File->Execute UG/Open->User Function..." */$ C7 G1 B% f2 F2 i' c3 _0 P V) {
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )
& c$ W, w# J$ g* E. M* Z j4 w{
2 j1 S, C# I/ W /* Initialize the API environment */
+ J( g* L8 h# D3 }# n char prompt_string[]="open file";4 s9 v0 B; j6 j2 a' ^8 p
char title_string[] = "select file";9 m" x8 L. T: ^, B" P4 v
char filter_string[] = "*.prt";
4 y9 U2 f& u; X0 K% C: U% f char default_name[] = "my file";
8 R$ R" ?9 _% z3 k: e9 z4 w$ T char filename[256];
1 [6 L; M% a6 f0 B. R% z/ _ int response;3 z L$ n9 D! t, x$ G. a
if( UF_CALL(UF_initialize()) ) 5 b' a- C3 H' E) F
{
- Q( P6 Q" I. o9 v: B' y. E% h /* Failed to initialize */
7 r( k+ r* e, a+ M return;
3 U) A8 N' P" r' G& n1 V }; k, ^# w$ X, u
! M/ R8 F( k- `+ t# S
/* TODO: Add your application code here */
4 s0 x/ P! ^/ Y# a UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox1 ~8 r3 G' k$ q5 c- ?
/* Terminate the API environment */& x; i# I% G- C9 l y4 M0 j8 L
UF_CALL(UF_terminate());" t% P6 D/ `3 W% n4 L4 P3 H0 m8 X
}6 D5 A2 S3 ?- b5 r" N e7 C
/*****************************************************************************! f1 E/ ~+ z3 L! W7 \% t
** Utilities
$ f' i; X" R. b0 Z9 ]*****************************************************************************/
+ ]" t1 \% a4 L/ j- Z/* Unload Handler5 o; T# S8 y+ v. S! q% O
** This function specifies when to unload your application from Unigraphics.
& S7 k2 ]0 H) r% I* E** If your application registers a callback (from a MenuScript item or a! ]1 \: }# F! w/ R4 \" P: }+ [
** User Defined Object for example), this function MUST return
' E) R( `( Z0 ?9 Z8 K7 E** "UF_UNLOAD_UG_TERMINATE". */* _0 J, G. @% j
extern int ufusr_ask_unload( void )
/ x$ s# h$ K2 h6 K+ T5 R4 @) G{% l" B* F1 W; i$ T5 Q, O( n( e& w
return( UF_UNLOAD_IMMEDIATELY );+ T4 `' E( }1 a% L
}: ?" C' N1 I1 e4 z9 k/ Z
3 S0 Y+ A# V3 S) T: S$ B" ~ |
-
|