|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
' s) s" T, r+ B# C/ b+ Q
/*****************************************************************************% a: T& ^& D4 V% Z! Y8 O$ b' u
**
. z# e! X" @2 K3 A0 c* \4 l% J** createfilebox.cpp/ D5 ^, v3 L9 M/ n+ g
**
. i0 ^9 A4 E- Z1 S& B9 Q** Description:
4 U( G! |# K6 n3 ]6 k** Contains Unigraphics entry points for the application.6 Q( x% y2 ] T/ W& M/ l" {
**
4 \) X' Y1 Z8 ^( [*****************************************************************************/
5 C2 O% t' S @- L/* Include files */
8 F( o9 u/ E6 F# C* Z, K#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )7 v9 B4 q+ e. W5 R
# include <strstream># t9 G- L6 v( Q, S5 L/ I5 E% F$ R
# include <iostream>
% ~) w8 t( `' s, y+ n# i' ~ using std: strstream;
% [3 [7 t, l/ e% h' b% e0 V using std::endl;
$ q" O- A, u d; t( r6 f2 { using std::ends;9 K# ^' ?# V4 `$ U
using std::cerr; K8 q/ x" p/ e) s1 N
#else
. W- m% Y6 L/ B# u9 m4 g5 D! y8 g# include <strstream.h>5 i9 u, X4 f9 p& G
# include <iostream.h>7 P0 ~+ G, Q' q t
#endif
" ^; ]1 l0 D% U#include <uf.h>+ V' G' A; q& h# Q' l1 g
#include <uf_ui.h>6 E. C* W( _: C
#include <uf_exit.h>
9 P+ ?# Y4 P8 S$ a( G#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
9 ?8 c; n2 _! o. I$ a4 t7 W8 [5 K7 [static int report_error( char *file, int line, char *call, int irc)
" r# l6 c- a4 [* X{3 G5 Q1 B7 l' ^; i' V
if (irc)
4 S4 m) p1 F: R' @, W {
8 _$ \) E4 T% O, x! a V) P char err[133],
( Z. C3 F9 X" ^" m8 @# Z2 q msg[133];
$ z, q' @" |6 [4 [ sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
8 | b! w% R Z- m1 A$ y8 h) a: Z irc, line, file);' _- W: W; T+ z2 @2 d% I
UF_get_fail_message(irc, err);
) w8 s; a" v: Z& A. t- B UF_print_syslog(msg, FALSE);) b1 b5 T& a, y2 ?
UF_print_syslog(err, FALSE);& R- n9 c" I( D. N* S p! A, z
UF_print_syslog("\n", FALSE); v8 y" m! V, M' J$ x. i
UF_print_syslog(call, FALSE);& x) Z" i5 `7 X) T1 L1 W0 U" T+ n5 E
UF_print_syslog(";\n", FALSE);/ o. Q, V$ ^* G; ?. u
if (!UF_UI_open_listing_window())6 C* a" l$ P9 o
{
+ n5 V2 Q+ L9 ?" M0 T: E UF_UI_write_listing_window(msg);& o; |0 m4 w5 ~- T( X* D( H# }
UF_UI_write_listing_window(err);
9 v( a7 `9 W+ E UF_UI_write_listing_window("\n");
/ ] S6 n+ B: t" V UF_UI_write_listing_window(call);
' w! w% t$ d3 x e" S0 h3 F Y UF_UI_write_listing_window(";\n");& G) I0 {, G& T
}4 `0 e. X) F, \
} u3 C h/ a- |; i, n Q! z
return(irc);
$ N) w1 v8 b% r. Z}
4 r1 G7 z1 ^: S" |4 l: A& V% _) p" R6 Z, ~2 K
/*****************************************************************************
$ k1 T- g* S5 U" p# s: O% F** Activation Methods$ z3 x2 b f0 M
*****************************************************************************/
/ n1 b/ z7 R- Q: k: }, y2 _+ \/* Explicit Activation
9 x8 c0 [. s6 ], a8 x% {5 u" s3 N** This entry point is used to activate the application explicitly, as in
0 d5 j, e# r& t2 g; K** "File->Execute UG/Open->User Function..." */
# l; u8 Q/ U) h+ |extern DllExport void ufusr( char *parm, int *returnCode, int rlen )& p4 H# o$ ^0 t1 Z- r6 c( c
{9 x# m2 A% h' l
/* Initialize the API environment */4 q2 q* V+ b4 [4 r
char prompt_string[]="open file";- T& F; p3 j+ C0 Y2 ]
char title_string[] = "select file";
% r: G: {8 Y* s- z, a4 \- o& R char filter_string[] = "*.prt";# L0 @4 d% N. _4 L: _3 I. B* X8 F
char default_name[] = "my file";# y7 i1 e! ~& \9 L8 W$ A2 p5 m
char filename[256];
6 w7 r! V. @5 w# F: y, q% r3 ^7 M0 K int response;
# H: D% W. V2 E) k9 a; w7 s& z if( UF_CALL(UF_initialize()) )
* q8 g# @3 [4 q6 u* l {/ ]. M& a3 |! Y- `
/* Failed to initialize */
4 i. P+ a7 b0 \1 t# c, e+ _7 Z$ Z return;! V4 e. U3 ?, e; x- u
}
6 {/ U2 C% [, ?! Y' k+ } 0 d- K. G" W! D- u0 C$ f: i* t" e
/* TODO: Add your application code here */
* `& j. G/ e" _4 {1 a5 T( h) G UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox
7 a- ]4 L2 I+ S /* Terminate the API environment */
% i( y: I6 ?8 b0 f UF_CALL(UF_terminate());
6 z7 K1 y9 [( Q8 ?& J' j' _, E}
G8 g9 e# Z w; @- r" j/*****************************************************************************
# n" ]. G9 S# Y) N( k2 ~) V4 ~** Utilities, r) J- y$ S% v
*****************************************************************************/
) s* p7 z& x# f4 r9 G+ v/* Unload Handler6 U7 H9 R. Y: J
** This function specifies when to unload your application from Unigraphics.
# Q2 i! q+ N( ?( b9 ^+ G. k) k** If your application registers a callback (from a MenuScript item or a$ |7 D" Q/ r* l- |5 }
** User Defined Object for example), this function MUST return
9 Y( K x% T$ l* l- y& d** "UF_UNLOAD_UG_TERMINATE". */# Q. D9 a* a' b/ a
extern int ufusr_ask_unload( void )
. p) [. M2 v$ v7 h( T# f{
( o9 ~8 u2 [% j4 g return( UF_UNLOAD_IMMEDIATELY );
' B8 `, ^ L3 n& O/ G- {}, d+ O3 m, H: @! p9 A3 `4 b% ~
& u+ `" o5 `$ a$ ]
|
-
|