|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
( h4 r. x# Z) w v; D/*****************************************************************************
/ U- E8 w( ?* ~8 Q, u**
5 O" y% O. _: ]( v r. P** createfilebox.cpp
8 U3 A9 \6 w0 ?% f+ T5 c**+ [, A* b, z) }( o: M# k# q
** Description:3 V. Q# F# z1 y8 Z
** Contains Unigraphics entry points for the application. f8 h5 E; r g0 }1 l; _4 D) p
**9 a3 q* G: C" ^8 D
*****************************************************************************/9 |3 Z. B; F3 @
/* Include files */
; l$ ^* @! q O O& k#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
6 `4 i1 O1 ]: y4 R* y) g) D# i% L# include <strstream>1 M" S8 o$ f# P$ s- ~$ C3 w, E6 G4 w
# include <iostream>1 b! L3 @ y P, J& n3 T7 c
using std: strstream;
& ]( T! d X5 Z: \ using std::endl;
4 z" F& R0 |; N: n6 i using std::ends;
5 g/ G; S/ G- x- x5 r. w3 ~ using std::cerr;; P: [" R. G9 ^( o! H) Y. U
#else
8 ?# X! k& G; U: H( @# include <strstream.h>" ~/ R9 V7 ?! j8 W% @' z8 j! b" _
# include <iostream.h>
8 y. v* c1 \% a#endif: W" O# g5 i7 k( S
#include <uf.h>! [ P1 d+ c& b3 N
#include <uf_ui.h>* g9 _% A" k7 i0 s# b5 @. H7 k( F- n9 j
#include <uf_exit.h>9 l% y" E3 |9 T; q
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
4 l, D. x! H% Z) gstatic int report_error( char *file, int line, char *call, int irc)- ^7 d3 q D1 @1 A
{
4 E# I* c* i0 y2 M$ J. E3 x1 g if (irc), g( g8 t; l, h8 g. }
{8 T7 Z3 S3 R9 Y+ F' c# i3 m
char err[133],. z3 B) j/ Q& t/ E: S
msg[133];
3 {$ Q! ?1 V: W% m0 i1 | sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
+ s/ N+ ]9 r" Q8 T. q irc, line, file);
* O6 {9 c- i5 [, _4 F/ {# F! ]2 e UF_get_fail_message(irc, err);# f4 y( E) ~3 v6 _. U, K7 q
UF_print_syslog(msg, FALSE);4 X8 r# Z3 J- k& K( I9 T! Z
UF_print_syslog(err, FALSE);
# _* E V2 i! [2 R8 T: b UF_print_syslog("\n", FALSE);4 K# Y- `2 K6 v
UF_print_syslog(call, FALSE);
* r" t3 f! A. H0 `9 \) w3 W8 H+ Z8 ` UF_print_syslog(";\n", FALSE);: s$ Z; W: R6 \. o' K
if (!UF_UI_open_listing_window())
5 v- f7 K3 m0 v) H {# t# U& O" j9 _$ |9 H8 y! }
UF_UI_write_listing_window(msg);8 c; u) j6 T$ X9 y( O& Q# ` N" K) D
UF_UI_write_listing_window(err);: Y$ Y1 N% h, Y
UF_UI_write_listing_window("\n");
% v7 ?/ d7 ?7 W; H UF_UI_write_listing_window(call);( Z! g( c- [" T1 z% b
UF_UI_write_listing_window(";\n");
. K/ k) F$ R m3 Q' q1 H }5 a# m/ _ {% ?# S. W) Z9 _
}
" k& {2 ^$ _0 g; x9 Q return(irc);, m/ f& Q k# l) b) x) y' Y
}1 F% t8 r' H5 F
7 I1 Y" N4 Z, m5 A7 S
/*****************************************************************************
- M$ _5 j- U4 N0 \0 Q1 V( V** Activation Methods( e3 a/ u' G0 D
*****************************************************************************/# I5 m: G0 f3 H3 V7 p
/* Explicit Activation! c* W- B2 t& U8 f# c7 M
** This entry point is used to activate the application explicitly, as in
1 L/ B6 l$ T/ }$ e# W! |** "File->Execute UG/Open->User Function..." */
+ M# B; C! u' K! E) q, textern DllExport void ufusr( char *parm, int *returnCode, int rlen )
. E d* ?- Y) @. Y7 g# K{" l! e$ Y e: Z6 W: K) N
/* Initialize the API environment */
- Z9 [8 V8 W# w+ l* I char prompt_string[]="open file";
7 D# Q5 g4 l! b7 `" V char title_string[] = "select file";
+ I4 h2 W; Y7 r7 r# _! ` char filter_string[] = "*.prt";
' @1 y+ c% D7 e: @7 B, q char default_name[] = "my file";
2 y8 k. f& x( H char filename[256];' d5 `; c+ }& ?8 i# y
int response;0 ~! A: T# |) O1 {" N5 o- \ s
if( UF_CALL(UF_initialize()) ) " N' j, `5 J# k7 g) y
{
$ u6 N7 l. s' i1 ] /* Failed to initialize */1 i* r- l! i& x4 e/ C& W
return;/ y9 R$ T, Y" A! n- J
}
" ]4 | a6 A. |$ f! q
: j) k6 o) M& @3 o /* TODO: Add your application code here */1 h9 V9 y! i& S
UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox# h/ [$ j2 E" f s' N
/* Terminate the API environment */9 u7 |( j: K! \
UF_CALL(UF_terminate());
1 i+ U* Q5 b7 v: \, N: w& F# v}) ~- m9 D/ g- g0 a8 I
/*****************************************************************************4 G* [* N+ v9 ~1 I5 j) D
** Utilities
9 I, ?' s3 O# ~*****************************************************************************/$ K w+ J1 T- \" g% p
/* Unload Handler
( g" }( i2 G6 G** This function specifies when to unload your application from Unigraphics.7 _' I& k4 q( ?) k6 @6 i
** If your application registers a callback (from a MenuScript item or a
0 m0 g- i+ r& X6 G. X** User Defined Object for example), this function MUST return) Q! Q. r& X& ~; Y) i; b, ^5 S' ]; `
** "UF_UNLOAD_UG_TERMINATE". *// _$ b0 W8 b: G3 y& H6 n0 R
extern int ufusr_ask_unload( void )
7 @8 n* q5 O/ ~4 b) W{) P- z! |# a, h
return( UF_UNLOAD_IMMEDIATELY );
4 O4 Q2 T9 i8 p}
z' M- l5 s9 e, @% `, D
7 f" L; t% v& a+ m% K5 H% {) ] |
-
|