|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
- Q4 p1 X( ^; o" f/*****************************************************************************
) J8 Z4 F( K% |1 n**$ x. G+ X V7 g; ~
** createfilebox.cpp
9 x& X& t1 w/ \8 T1 X4 d# D**
c$ U m( U3 z** Description:* V8 j8 \( j' C- U$ n g! L& |
** Contains Unigraphics entry points for the application.
* M, [ F P) I% Z1 ?; \**4 {: i+ A1 k8 V# f) f3 R2 h# Q! ?
*****************************************************************************/
; r$ }! X$ J7 \6 t3 o* k+ P8 C/* Include files */
+ n9 p& S& |2 D( T! a! D#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
2 N4 U6 n. C' d- s+ [# include <strstream>
* K/ k9 i, h" _% ?# include <iostream>$ I1 l) A" Y. @( N
using std: strstream;& Z; W4 A* H& ^& i# r) O) g7 J9 b
using std::endl; 4 M& q& X! y/ S$ T# J e$ k
using std::ends;- _ s+ p+ B! W+ P( \* L
using std::cerr;
4 w! L3 ^5 {6 P" G" G' x; G#else6 z$ g, U4 ~: r8 q& s1 P
# include <strstream.h>0 @! Q1 K' w; q) o7 t! _$ n7 i2 x
# include <iostream.h>8 \5 |( G3 O4 y3 p! x; E
#endif
' C w4 t1 }; P1 c#include <uf.h>
: Y- T9 x2 k1 _" f: Q8 Z6 v#include <uf_ui.h>
. D/ T) h- `6 E2 f- V3 n% f5 U2 ^+ Q/ n#include <uf_exit.h>
0 p1 }( o8 ^( T6 A, y#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
x) ]; n' A" rstatic int report_error( char *file, int line, char *call, int irc)
! q, |# y% @) b+ W* }' c* d |{
% t% g3 x( Q& A: k9 [4 m if (irc)
! l, _3 C. M& F2 c1 { {
. k! [$ O: \1 k/ W char err[133],
! @0 P2 T, j9 f4 k k msg[133];: x7 s& R# v# K! V/ {
sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
6 d" I/ u: n( l _% s irc, line, file);
2 y6 b3 }9 ]5 s" X- F* E UF_get_fail_message(irc, err);+ W+ @; I! y, x8 M( ?) E* s" |
UF_print_syslog(msg, FALSE);9 D4 S5 n( k; ~3 s
UF_print_syslog(err, FALSE);
/ k: J' g ?& H1 V2 j. P UF_print_syslog("\n", FALSE);' q$ l' |% U" l
UF_print_syslog(call, FALSE);8 L6 y0 d7 u# \. d
UF_print_syslog(";\n", FALSE);- y" N8 @ V. f0 S
if (!UF_UI_open_listing_window())
7 S3 i7 }2 |* ]4 q {
& o$ \% a4 I# |: e UF_UI_write_listing_window(msg);% e" ^0 m; ?1 |5 F0 _0 J" i- T8 H; _
UF_UI_write_listing_window(err);
6 U; @0 R; G% w, k3 S( u3 v UF_UI_write_listing_window("\n");
' @: S9 o( p9 Q+ N( B UF_UI_write_listing_window(call);
' ?, r* r' M4 ~9 X0 A UF_UI_write_listing_window(";\n");# d4 L! H" _. V0 j( e# w; M) Y
}# {+ J" l/ o+ v6 q& ^
}
' H! j; ~$ ^8 {" I. ? return(irc);7 D2 }7 y5 m! P' k Z1 r8 v* e
}8 T& q6 w& K! w) G
* v+ c$ ^) s H9 E
/*****************************************************************************# r) E7 s2 }$ o n8 y
** Activation Methods) M; @5 u% D9 F
*****************************************************************************/7 U x" E' Z- _& X: r. Q
/* Explicit Activation z! i1 {4 A: D2 E" c
** This entry point is used to activate the application explicitly, as in
+ L' J; Y. U( u+ t1 u** "File->Execute UG/Open->User Function..." */
8 l1 h& m* v' G* T# @( y, Cextern DllExport void ufusr( char *parm, int *returnCode, int rlen )
) u, G0 j: a) n8 Y9 \{
- u: A3 T, c- U3 L. W/ P+ o /* Initialize the API environment */
& r2 W7 U& t) Z- L6 q char prompt_string[]="open file";
5 i& ~ w8 Z# ]1 J3 u2 I char title_string[] = "select file";
6 q% \% ]+ O p$ e- I( |) w char filter_string[] = "*.prt";! ~' {0 y, z$ d3 ~8 N6 j: ~
char default_name[] = "my file";
; t- d( ? f% E, h# h3 `; m char filename[256];5 w2 ^9 P3 }& ], t
int response;
& q# B/ D Z, | @ if( UF_CALL(UF_initialize()) ) 2 ^% h! z) k7 D- t0 ~7 r+ n$ ~
{
" M8 A H9 Y( `& C& _ /* Failed to initialize */0 H& w- L8 I. {: t2 Q
return;
, H$ L3 I8 _9 e) d3 a. U1 X! z }
: j1 g( f& i0 S: V7 p+ ]
7 @! j* B9 V1 u6 w3 n2 _ /* TODO: Add your application code here */
' R3 i8 ^3 R( t% s6 Z1 L UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox
7 O/ g) V( F7 A /* Terminate the API environment */
K/ S% l' c( M3 q UF_CALL(UF_terminate());
/ J# [& b; W) {+ D6 [2 o}
! x* L! D' W6 n9 ?# N. M5 K1 w4 l/*****************************************************************************
: i3 G( c' C3 ?, I** Utilities
2 c$ n P* n& s6 v5 s. Q*****************************************************************************/5 Z$ S4 ^" n" N4 l" I
/* Unload Handler
7 W; m8 W0 f- R4 |, W4 W** This function specifies when to unload your application from Unigraphics./ P# a1 a# K7 ` Z
** If your application registers a callback (from a MenuScript item or a; ~, A! k2 r L- L# Y" ~0 V u. \
** User Defined Object for example), this function MUST return
+ q1 x( U6 T+ n8 L0 v** "UF_UNLOAD_UG_TERMINATE". */: ~( c$ z1 O: T F6 a# U- c- U# p4 u
extern int ufusr_ask_unload( void )
1 m4 m" G+ Y, r{
# D6 A1 z' B% q3 s) @- \ return( UF_UNLOAD_IMMEDIATELY );4 p- O7 C: `; x/ t3 L) B
}, _$ C1 O1 b8 {" G/ E
/ \! U4 R: O' Z& `* S* _$ p |
-
|