|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
9 g- c0 |9 M) a3 X
/*****************************************************************************
, i, y3 z" A5 A3 N**
1 M* ~# {4 G- t4 \1 g3 ]) ?: j% O$ J** createfilebox.cpp
" Y" ~$ o6 R7 w+ _ l2 G3 I**: M5 E i; |0 b
** Description:
- v, k% g7 h8 O5 H0 n** Contains Unigraphics entry points for the application.
) n( r% O. j& c**8 m" O# b. G/ U
*****************************************************************************/
) }; v2 l8 O, S9 C8 r3 P% B! o9 }/* Include files */
( I; K" C6 a5 {#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )# [5 H/ ^& i7 B/ H# @
# include <strstream> }: x! ? t! G* ?* B1 \- a% Y
# include <iostream>
& m$ z& p* S* }$ ]: s/ x using std: strstream;
0 A: f2 j* E5 |' h6 ?# S using std::endl;
: K% [* }. `; V1 Z3 F using std::ends;0 D' p6 W; V& x& A. m7 D$ N7 T& m
using std::cerr;
. y9 _8 J1 g6 f+ g8 T#else
0 ~! @% e+ X" ~- u# include <strstream.h>
' q0 ?2 x# I4 n5 h, |! s# include <iostream.h>
: u! b1 t4 q+ x! [" P#endif
* O- B& g& c( h3 W$ G% O/ _#include <uf.h>; v5 ], w$ d' r& v! x
#include <uf_ui.h>* A1 x4 T7 W5 B( @6 [+ z( ^
#include <uf_exit.h>
" u$ `6 n8 V# K* T! g/ z% x" l#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))$ g! I' G8 L3 F4 | a" K
static int report_error( char *file, int line, char *call, int irc)
$ g8 |( h! j @5 G{
' v2 l' j& \' @, a* r if (irc)
7 Z9 M' ]" e6 ~ {
6 Y4 n* X6 K8 {6 u char err[133]," Y+ u o/ B" S5 U Y; f
msg[133];
& _/ ~/ B7 D. s sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",/ i8 E! Z3 \ n
irc, line, file);
) F5 p4 C. v) e: a5 x5 c UF_get_fail_message(irc, err);
5 ]( k; t8 X- N m/ ~1 b UF_print_syslog(msg, FALSE);
: n2 b8 h8 T+ o! X9 r8 { UF_print_syslog(err, FALSE);( F" [% A, x0 |5 o6 o
UF_print_syslog("\n", FALSE);
! ?7 a; J1 R8 W+ q2 Z. W UF_print_syslog(call, FALSE);
- | z! K" d( X. M2 {+ ~1 O UF_print_syslog(";\n", FALSE);
6 R7 r5 f6 _) u2 N: S0 P% q/ x if (!UF_UI_open_listing_window())
2 d& i3 o' }% H' a {& s* E- K# D, e% H
UF_UI_write_listing_window(msg);) e$ d; M+ d4 G# V& Q
UF_UI_write_listing_window(err);
: q+ [' f, o ^0 L3 d UF_UI_write_listing_window("\n");
/ F u' y. O( y UF_UI_write_listing_window(call);
. Y. \" W; \. Z( i9 { T UF_UI_write_listing_window(";\n");
5 x7 r4 e: S n9 ~. f/ J' `8 b! M }# q6 M w, h1 e! P( ~/ v% f+ x
}
. z {* B; V5 K- {: f, K+ c5 |. T return(irc);, w# r' b$ x1 b- p/ w) E1 C8 r7 f
}
& O/ S& x, t; @9 j) Q+ o2 [3 @) b2 c3 N( p, ^: J/ {! Q
/*****************************************************************************5 K- ?- w$ b3 B6 H/ M
** Activation Methods
- ]" z" A( q7 d" B1 B7 c1 [7 V*****************************************************************************/
1 r( Z( O5 y E- @6 r) W8 R; L3 B/* Explicit Activation* Q- _4 v6 M) x% m; Z
** This entry point is used to activate the application explicitly, as in# ]9 d9 G, E" s8 U+ F
** "File->Execute UG/Open->User Function..." */8 J! B9 m0 W' M
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )' X. j4 \: s% n1 H" v
{
/ m$ t) ^8 w( |2 t4 j7 B& b b( F' ] /* Initialize the API environment */: a0 f& u3 ~$ k9 l* j" i
char prompt_string[]="open file";
. U2 j2 a8 _$ x8 L char title_string[] = "select file";/ I7 d' S* K* A0 P; h8 \
char filter_string[] = "*.prt";1 w* s( f: K9 e) L7 `( ~" ?3 \* E
char default_name[] = "my file";
+ o6 N8 `5 b4 ?3 u; f char filename[256];* A7 _* N6 U* ]6 E' k' I( v9 q
int response;
* ~; j6 L3 o$ j; B if( UF_CALL(UF_initialize()) ) * e% V* A, l+ x& a: C" C
{6 Z) P- e( U( h* ~1 ?7 r+ L) f
/* Failed to initialize */
* C+ z) ^! y6 M" N4 k3 E5 s$ G return;5 `# |. U" M2 E' l6 u% ?' m: S
}+ Z3 I" H$ o- N1 X
) k+ I8 g* y- {% u7 b7 \ /* TODO: Add your application code here */ u8 h: H$ d) D9 f
UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox
8 y) t) M3 y) O0 s. ] /* Terminate the API environment */
/ z8 H& B4 D7 t p# ]( U UF_CALL(UF_terminate());2 s/ p' t+ C; `; w
}
# Z {7 X" `" [$ ^" ^/*****************************************************************************0 w2 b5 _# u% I( t$ o- k
** Utilities- q" j. u8 d: X: R" l
*****************************************************************************/2 Y# c" [! Y0 x
/* Unload Handler
/ A: B/ I1 j6 N( o; e: E2 H, H** This function specifies when to unload your application from Unigraphics., N- k1 s2 q5 w
** If your application registers a callback (from a MenuScript item or a: T' j- I; X) D0 O- {
** User Defined Object for example), this function MUST return
8 b' O8 p5 H/ \8 C, _** "UF_UNLOAD_UG_TERMINATE". *// }3 x8 {( [6 W& I/ j1 |1 o+ c
extern int ufusr_ask_unload( void ) y q& X: a6 |9 G" e/ E# ~# c% j) w+ p
{# b9 T) d. u5 Q$ \* m% n9 Y. P5 f
return( UF_UNLOAD_IMMEDIATELY );9 P3 i. K/ c. ^$ u
}
! U9 N9 k: ]& ?0 u P" R# r
& e* I" @ |: {$ K) ~, S |
-
|