|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
: E6 F& b7 O: _ s' t) W
/*****************************************************************************4 ~7 P9 p+ ?4 p) u
**2 |6 A9 A4 ~; F- B" ?
** createfilebox.cpp
4 M2 O( X* n& D, b3 o O* v+ @**
H- f/ F! u; Z& c) B! k** Description:
: z: q3 T% B+ e, O3 U) w8 h** Contains Unigraphics entry points for the application.
6 T. r7 ~( F2 K' e**, v" y; Y$ m' J. k2 ^( A/ U
*****************************************************************************/
7 v! T8 G1 b- a% G* M- f/* Include files */9 ?! ~( L! g9 |
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )/ s9 v$ j* N& O
# include <strstream>. f; I& F3 r0 q, C% }8 y
# include <iostream>
8 I( p) [ s0 y$ q+ | using std: strstream;2 Q5 }- `5 W1 E' W+ h
using std::endl; 7 {% z5 m5 f6 c- J6 W
using std::ends;9 t4 o2 p# y$ v. W, @
using std::cerr;( {' q+ x% C" W
#else
% {1 V% f3 p; ~& K# include <strstream.h>6 r7 ]1 B. _+ J; W# u
# include <iostream.h>
( h6 X; ]0 v. J$ v0 \#endif
2 c2 T- F* p& g$ c* d0 k5 e4 D. `#include <uf.h>! M' i- d: i! p! h3 j3 G: r
#include <uf_ui.h>9 }. X) Q& x- i2 G6 {/ A# \$ Q$ S
#include <uf_exit.h>
: [, F: k% b" t9 ~: H#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
3 K% L: r# ]# K8 W. h' l8 jstatic int report_error( char *file, int line, char *call, int irc)( t; y& X8 u1 @4 F
{
& a- `* I# a& p( U if (irc)
5 N( P$ L5 P2 k# }% u+ r {
5 j) K8 C5 A5 U$ B2 S char err[133],
1 P- M* Q# N$ L3 C msg[133];' G! v+ p2 d$ K
sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",- z' \/ }8 Y# u$ `5 R( E+ ?4 O2 i% X
irc, line, file);
. S, I9 L2 f3 f$ y1 i UF_get_fail_message(irc, err);* L8 a6 Q. m! E6 p6 F
UF_print_syslog(msg, FALSE);3 S- @, J' K7 f* Z- ~6 `+ m* Q7 g
UF_print_syslog(err, FALSE);
! h) l) o% d" ^7 E( ~ UF_print_syslog("\n", FALSE);" P4 b0 S2 N" P+ ^
UF_print_syslog(call, FALSE);1 ^ ~$ N' ?' d" [- l8 W
UF_print_syslog(";\n", FALSE);
/ n' F7 N, C5 K6 p' U2 X0 I$ }0 d! @ if (!UF_UI_open_listing_window())- s2 K$ D& u# O: b% K
{' C5 K, p6 k8 K' J( t" }
UF_UI_write_listing_window(msg);
/ e8 m% k( T2 c UF_UI_write_listing_window(err);! u6 ]3 w6 a* a- m
UF_UI_write_listing_window("\n");; Y5 z0 ]' b2 B& u- o
UF_UI_write_listing_window(call);
8 R) z& Y* s! H+ L' P: C UF_UI_write_listing_window(";\n");$ T) I- R" J' ^6 P4 l# r! e1 O
}
- O2 k( c) |/ G3 m+ P7 G6 S: q } Y4 M1 j! M, C( o! C
return(irc);
6 L6 ]" ?8 {4 K! c1 q/ X2 {! }}
4 J+ N# D# N9 p/ r2 o/ t# G1 ~* V) d: v& E
/****************************************************************************** W! Z' |" f8 r' s% Q
** Activation Methods7 b6 `1 v- y8 E* F" T
*****************************************************************************/5 Q" ~' x0 z% I1 s# K& J
/* Explicit Activation* E; m$ D" L m/ n
** This entry point is used to activate the application explicitly, as in
: z! i1 e: A+ J" w+ }) Z2 l** "File->Execute UG/Open->User Function..." */5 }4 I [4 _% Q5 y" ?# c3 E+ v5 {
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )
5 j. `& K P# c9 `. _6 w{6 ~/ R1 C4 d+ V% O& ^ V& Z2 t+ W
/* Initialize the API environment */
8 r: ]) `$ J# R" X char prompt_string[]="open file";7 c, |) d5 o9 Z, H
char title_string[] = "select file";% b4 e. c7 y+ t2 a: ~8 V# q3 s
char filter_string[] = "*.prt";" [% p1 G; w. X1 w$ T: C* c
char default_name[] = "my file";( o9 w( t5 G, G' h" F3 V
char filename[256];
, l8 M k% T( y int response;, k1 t* Z2 o6 g! @( S H u
if( UF_CALL(UF_initialize()) ) 7 X* K& z+ X" t: G' F+ |3 `
{
8 e/ l6 T, u8 E5 i8 ^ /* Failed to initialize */. _0 l5 y: W* Z- z$ K6 i/ t& z
return;
/ b1 r' F5 [" ^" B& |5 B, T }
s/ y" m/ w8 A* r$ J! }- u3 A. g 2 o/ V% G3 v9 f8 t
/* TODO: Add your application code here */
! i' I: w0 G1 d" `+ S n6 c6 z UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox
# i0 I1 z9 ~ X/ r8 H /* Terminate the API environment */ P1 G) x# \4 ?+ W
UF_CALL(UF_terminate());+ ^, u- h ?- `2 m$ B7 ?
}
( e6 G$ ]" n/ }& f0 w/*****************************************************************************' M1 E0 I+ _" C# b3 c2 [% U4 e
** Utilities* w3 ?$ k1 v3 v: z
*****************************************************************************/, r" `0 V& ]# k N
/* Unload Handler0 A' @5 r: @+ u0 y
** This function specifies when to unload your application from Unigraphics.( U. }) ^7 W1 R* t8 s7 s: i% z; G
** If your application registers a callback (from a MenuScript item or a
1 f* `! \2 c* C8 @4 J; W** User Defined Object for example), this function MUST return
, \/ Q, Y6 h* v/ E0 Q** "UF_UNLOAD_UG_TERMINATE". */; q# `/ W7 ^. b/ p
extern int ufusr_ask_unload( void )
# Q3 L3 g2 D3 ~3 z{
R3 \/ f" V1 f z l! J return( UF_UNLOAD_IMMEDIATELY );9 n8 Y2 t5 ]$ C" B3 V
}
0 [% [8 V' n. K9 K; g2 i0 C' W
# P( l1 v1 J0 \) v) a k |
-
|