|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
l5 P' Z3 o3 |5 c
/*****************************************************************************' U9 W3 t, f8 {+ O6 _
**
?; f: w6 q7 [+ V( ^** createfilebox.cpp$ n2 g- G& [& {9 A" I m2 ? m
**
- E) ], r. V; E0 M; [" w d** Description:* K2 h. H' a& d j8 o* D6 r0 P% t4 g
** Contains Unigraphics entry points for the application.
/ T: I7 S# P) ~) l& ]**+ z2 {2 d$ t) `! Q: E7 {* D
*****************************************************************************/
z3 J0 F1 f& E0 X8 x/* Include files */& l* S; r: [7 V! ?& \' U1 m
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )% v( z; V: b8 G' X! k
# include <strstream>
6 c- b4 ]- S+ }4 `3 M- O# O# include <iostream>
5 p$ Q! d P# d using std:strstream;9 [ V4 V7 b: P
using std::endl;
- ?$ k; O8 x% ~6 H" P using std::ends;
7 w; _+ J3 W$ P1 G/ i8 J0 X using std::cerr;7 K6 t. C3 i2 ]7 R% m Q
#else
+ N! e* ]' J c1 u! x# include <strstream.h>
2 Q% z- Q1 N$ }# include <iostream.h>
( G4 C: E- m; G; ~$ C#endif' @3 ~6 N& M" a& O( M& `- a
#include <uf.h>+ T& C& J* U! v
#include <uf_ui.h>
$ w# i/ Q" V; E3 ]; E+ e& `- Q% w#include <uf_exit.h>
5 j N! m0 z$ O' z% m+ O#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
% h4 ]7 Q7 j* y4 V% @& astatic int report_error( char *file, int line, char *call, int irc)
9 s6 \: B( R3 M& ^! W& c3 ^$ r/ M{
" W9 h1 h* q2 v if (irc)4 N5 i$ p$ p- ]$ l
{4 @% X+ v! {3 V8 c5 F
char err[133],9 M0 u* ]" ?+ C' }
msg[133];' Z& q, D/ U7 \! c0 D
sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
& s' Y: u3 @2 U" B: b0 W# N irc, line, file);5 @' M/ W+ R6 l0 q, X6 i8 b! c5 `
UF_get_fail_message(irc, err);+ {3 z1 m Y/ G" d8 k- ?2 \
UF_print_syslog(msg, FALSE);
5 ?) x, }" M* u5 W$ U) D. M& @ UF_print_syslog(err, FALSE);; H6 k9 S. N* h: s' T$ W U
UF_print_syslog("\n", FALSE);
& d0 P0 b7 ?7 U0 ~. T6 S UF_print_syslog(call, FALSE);
& R% L1 w+ V6 J* ]9 ~# O, t UF_print_syslog(";\n", FALSE);
! Y, z" Y+ _& N. A1 l9 n if (!UF_UI_open_listing_window())$ ?' E& u! d2 o5 s0 v4 [0 b2 T! b
{
1 E" h% r) j+ n, v( e, ]& z! x UF_UI_write_listing_window(msg);4 h9 a- m+ s) ]! k: f
UF_UI_write_listing_window(err);, J( ?7 B; @& V# h2 E! E
UF_UI_write_listing_window("\n");
- V$ G' g! H2 L! l } UF_UI_write_listing_window(call);* F, e5 G9 G1 t$ m% |: r
UF_UI_write_listing_window(";\n");0 s1 J6 t0 E* f5 Z: D0 |* E- U
}: \# I# P [ Z; f# c
}
+ | k Q7 G5 r4 Z- [% N return(irc);
' f7 J- D+ @: c9 g}
4 Z) s# t# Q" y! I( k8 Y* f4 E* [1 ]- [8 o4 h: p5 s& Z5 S
/*****************************************************************************' Z( W2 D3 F% H: ]& w
** Activation Methods
; j% _$ Q" w" N% o: p, L. Y*****************************************************************************/' c( ^/ j+ W6 [8 N, @8 `
/* Explicit Activation
+ L+ A2 F6 S6 q/ I' P** This entry point is used to activate the application explicitly, as in
$ O ]0 Z5 V: ]4 W. ^** "File->Execute UG/Open->User Function..." */) J; e& |3 ]% a; D7 k B
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )
, i- [7 O2 b* M* M{$ L! R) U. ~) l8 j. @, a% \
/* Initialize the API environment */
- c. \$ t0 E9 H* A% `6 O2 O' ~ char prompt_string[]="open file";
# p0 r: N( z' X char title_string[] = "select file";
4 b/ w; }4 U9 n char filter_string[] = "*.prt";( f4 H4 U D5 g$ C2 y* @
char default_name[] = "my file";
5 t. ?6 P& G& w7 u3 E9 P5 C char filename[256];& y2 \# J9 @( G& _+ j& N, Q
int response;% R" O' \0 t4 N9 ?6 g/ d
if( UF_CALL(UF_initialize()) ) 2 t* f. c2 y3 L8 C, D
{/ i4 I2 B/ w# D
/* Failed to initialize */
+ ?- W: y5 I9 K0 o+ P% k9 I return;
9 r2 F5 {2 v4 K( C6 X8 } }# M- W! U. ]' v3 R% I7 O# d
3 W' x7 s. I- T c* ~; x
/* TODO: Add your application code here */4 `5 m* {$ |6 H8 O( h7 o/ Z6 L, \+ ]
UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox# @/ e6 c6 ^* ]: b: L( V
/* Terminate the API environment */
) o* y x7 a4 w. N) m$ w- Y UF_CALL(UF_terminate());7 X1 V7 p9 ]( L3 c1 I
}
- @" J3 q5 ^$ U5 _4 g/*****************************************************************************
( Z1 j' Y& c* w" B** Utilities
& C3 i# q: @: V) V- ~% d( Z*****************************************************************************/
" t( ]% t/ n4 @7 ^/* Unload Handler. z, Y0 A6 p, h! V; Z8 p! x. V
** This function specifies when to unload your application from Unigraphics.- {9 ~- h$ ?% L/ o
** If your application registers a callback (from a MenuScript item or a9 L, q: E" x. o6 c0 X
** User Defined Object for example), this function MUST return
8 T0 z. [8 B8 U4 z- {** "UF_UNLOAD_UG_TERMINATE". */
2 y1 Y d7 H2 `) K% Z4 Bextern int ufusr_ask_unload( void )) q9 ^6 b% E6 a
{
5 b8 u2 J$ c' K9 W6 |1 R8 @0 { return( UF_UNLOAD_IMMEDIATELY );6 {4 u% V3 V: B
}
5 b1 a5 y: q4 m) A7 _, p# F2 n6 F* T p) [, p
|
-
|