|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
6 ^6 o) c+ ]0 ?0 ]! \2 ?! `/*****************************************************************************
* {, Z v, W+ Q/ J% j5 ~**
: @! G& p$ X' y** createfilebox.cpp
- Z( k/ s, O6 ~+ D; D4 ~**
( f2 d- v' t( Z( \$ Q# J** Description:4 W' L+ @# _# x' D$ V
** Contains Unigraphics entry points for the application.8 P4 W8 N: D x) _ U
**
- ]6 x, v7 h1 ?9 V0 ?% L% O3 Y x*****************************************************************************/
0 j2 C7 @' t) u" `) t- T/* Include files */
: G* i% @; b& H4 m' e# u#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )6 d9 G5 i4 Q) N6 G3 O
# include <strstream>9 H; ]' M) N4 H' i2 T
# include <iostream>0 d/ {: N) W l- X& c5 S
using std: strstream;
; w) e- C! C/ [" o4 k5 n, L using std::endl;
" P5 F, k, a: R2 E using std::ends;6 U# E4 o+ O" E) E3 h
using std::cerr;
" O# I2 n$ m6 T) S* A) s#else
. E7 j! E9 K2 Y! L2 L# include <strstream.h>
* V# D% W0 H5 \) I# include <iostream.h>) U7 s4 c, a+ c# W1 v0 b( I
#endif9 Y) O0 Q3 F$ R
#include <uf.h>
. E2 m; J5 ]8 h+ M#include <uf_ui.h>. B8 B1 K" Z& P* ?+ M
#include <uf_exit.h>3 M* T! ]% S: W7 h& S, Q
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
+ }8 f% }. {; a, E- Tstatic int report_error( char *file, int line, char *call, int irc)( o, Y% {" Y$ B* a
{
; U+ v& Y$ [/ u0 }( Y3 {# I$ B3 \ if (irc)
9 f! l K% q. @ {
$ P q, E8 g$ |( t2 H char err[133],, N0 v. K9 T7 s _
msg[133];, ^6 i9 x( Q* b7 M
sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
4 c4 q) F. H! X$ z: d% i irc, line, file);
( N* Z+ I7 f& I3 ?- L" S% p UF_get_fail_message(irc, err);, @, y/ B( x4 c
UF_print_syslog(msg, FALSE);% H" @9 z0 s7 W
UF_print_syslog(err, FALSE);4 ~6 b8 c/ o3 T$ x2 b! t! X
UF_print_syslog("\n", FALSE);- B( @4 k# D7 R: r( E3 s$ d) }* D
UF_print_syslog(call, FALSE);0 l! d, S! h, l- N0 t# S
UF_print_syslog(";\n", FALSE);
4 z, L4 {/ W: h; L7 i9 [% y! y& g/ u if (!UF_UI_open_listing_window())
4 S3 W7 d! {, ] {* D$ b: `! W' x3 }
UF_UI_write_listing_window(msg);
5 f- R: B/ c1 x" ^9 w/ t UF_UI_write_listing_window(err);& g' D3 U' g7 m; z9 {$ ~+ z7 M4 _
UF_UI_write_listing_window("\n");6 r4 S( ]6 F3 j: Z
UF_UI_write_listing_window(call);5 d9 X7 `# ^2 f5 X( A
UF_UI_write_listing_window(";\n");& b* A7 `" \1 [. [
}* J6 r7 Q9 @4 p# l
}
2 k) n$ a, o y return(irc);+ [- T- I3 K( j" ^
} u, T& U5 g W% d
' Z1 ]9 u6 X0 { Z0 n/ M# Z/*****************************************************************************
+ O- X* ]' V; E2 e$ B' e+ p** Activation Methods1 d: F" W. d6 n4 T+ n. U6 N
*****************************************************************************/
' f% l. C r: X% C/* Explicit Activation7 g# n/ ^( B! i# p
** This entry point is used to activate the application explicitly, as in y/ u p3 n& @9 \& W. g
** "File->Execute UG/Open->User Function..." */0 k% n" z. |* P0 L* c( r! \5 h% b
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )0 r$ {% c) c2 G& E: L( G
{' `! }* E0 [/ |+ l3 ~& a
/* Initialize the API environment */
8 g/ Z, m+ X, D8 j- i; W% a char prompt_string[]="open file";
& d+ |: A1 P2 [" x/ b* \ char title_string[] = "select file";! ?# p5 g0 ^: f$ g. \
char filter_string[] = "*.prt";, m' W1 \# R9 V2 ~9 {4 o
char default_name[] = "my file";
4 J5 r% n4 u5 _4 i/ o9 X* S9 v7 S$ [ char filename[256];
( j. @; ?, q7 u: b" f. ]* ]! ? int response;
0 }/ I/ n& }3 k; s; d ]# b if( UF_CALL(UF_initialize()) )
) _! b! R# m9 n2 X" m+ f9 p* M8 r {
. J8 m4 u# g9 Q! H' b /* Failed to initialize */. X- m. R0 C f, L
return;+ l; c7 i! B( o e. t _0 {
}
! H) r4 ~, Z0 J# i u$ O6 ~0 C$ c6 U& B
5 l& m' e" e7 s, H# T# w. g /* TODO: Add your application code here */6 g7 q; Q, J, k, |
UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox- [2 r7 F' h# E4 e9 ?0 C
/* Terminate the API environment */
/ \' t p1 X; p! }* ?6 g UF_CALL(UF_terminate());" B$ U9 ~8 v6 J
}
" T) R; v4 @+ j/*****************************************************************************
' K( Y7 e2 @$ B0 c** Utilities
7 t4 ^' k0 C2 D: J6 e; x, R*****************************************************************************/
, x; o8 X$ m- X' f0 i& A* C' w4 t/ s/* Unload Handler" F q. j2 i, \: v
** This function specifies when to unload your application from Unigraphics.
4 }; Q; G9 C4 E5 f& C$ a$ ?/ r, ~** If your application registers a callback (from a MenuScript item or a
! r' y9 D z" @+ V9 j9 |: V** User Defined Object for example), this function MUST return6 ~" T2 k$ k/ A; |1 s: t& x
** "UF_UNLOAD_UG_TERMINATE". */
3 i$ p7 R. ]6 f# `extern int ufusr_ask_unload( void )
# d$ I0 U) G m) ^: y: k& {, F{ P1 e {, A. z1 w& E
return( UF_UNLOAD_IMMEDIATELY );& \, R# l0 I/ M# e5 [
}2 [1 D# s8 W1 Q6 \6 O6 ^ m
4 E9 k+ N' f0 q4 x0 _2 z9 q/ @
|
-
|