|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
+ M7 y; B/ j+ k
/*****************************************************************************
2 t5 O8 H& F+ v* h( T6 y# a# A**2 d! O; D& B+ B) L# |3 a( B
** createfilebox.cpp6 h! S7 @- \$ f0 w* m
**
) \" h( i j0 o7 ?- d0 A3 f" m** Description:
, V, Y2 ^( o' `** Contains Unigraphics entry points for the application.
" }* W8 `" e9 w" w9 |4 O8 d5 C**
; S9 ]& Z, a3 t. t+ f*****************************************************************************/) q7 H% `8 M, }2 g0 N
/* Include files */
) E1 w' t$ w n8 T- N0 s#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
5 g4 G. @! W/ x s7 ^# include <strstream>6 C, Q% {' \; x3 n q
# include <iostream>- f# J* I; a* W Y( @5 p6 P
using std: strstream;- _5 `* q9 z% u5 X
using std::endl; " k( i$ M4 O4 u" q% I. y% J7 r+ m
using std::ends;2 v5 \& f# F! w# @( x: ]
using std::cerr;
, _' f4 L8 n% e+ }( K* K#else5 w. Q7 @- o* P0 e
# include <strstream.h>$ |3 W0 ]9 z' F# ~* P
# include <iostream.h>7 ^! T# V% L" x; `0 {5 k. v$ \
#endif, S1 |. A' z8 [9 T# P( W
#include <uf.h>
2 N/ D8 w4 F# F0 l o#include <uf_ui.h>( E& h( d: r3 e8 R+ u( x8 D- z0 Z
#include <uf_exit.h>
. n3 v2 h) ?5 r#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
) { X2 R) W c# v3 K7 @# [( Ustatic int report_error( char *file, int line, char *call, int irc)
J, j) j( Y8 S8 V{* K" n. {3 T; m
if (irc)
5 V, C9 x5 o, W$ ~9 s$ { {; ?3 B9 C7 ]# e% l" g+ R* L1 B
char err[133],
$ y! Y3 [1 Q3 f( n" Y5 l msg[133];
& H/ J; t5 s6 O( Y I8 s1 m% ]- ^ sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",8 H& O' v6 `$ L( |' a `
irc, line, file);9 x. f8 b( B' H: ?; ^
UF_get_fail_message(irc, err);2 B. c3 K/ k( k0 h" p
UF_print_syslog(msg, FALSE);
8 S$ i( x) A k6 o UF_print_syslog(err, FALSE);; f/ i+ c' {% j
UF_print_syslog("\n", FALSE);
1 L; J- r% r1 ^2 S" ?6 V" g UF_print_syslog(call, FALSE);9 K" z0 E3 W0 i- ~0 G
UF_print_syslog(";\n", FALSE);
4 z z1 m) L* c( E+ F" ^% u if (!UF_UI_open_listing_window())
" T/ d2 w. n, T4 ^5 |9 k. ` {, I6 u' h% J9 f& \9 q @
UF_UI_write_listing_window(msg);
; l3 `5 z4 a) ` UF_UI_write_listing_window(err);
" X/ a* J" p" ?6 C+ N6 q# \ UF_UI_write_listing_window("\n");
, K! S; ~9 v) z: s UF_UI_write_listing_window(call);4 [0 F0 P9 g* m2 ~3 p/ a
UF_UI_write_listing_window(";\n");
/ q7 }; V4 {) w, j) j( c8 {% q }' [! m+ N$ M% |
}
, x; B5 W; I8 t- T! t return(irc);
; m. j" U) A1 t- D' ]9 e$ q2 ^}$ @" R* b+ A* s4 Y2 A
9 {, X% G/ o3 d/ e! F/ d/*****************************************************************************( K% P6 t" h! u9 x0 l3 B- p7 V" N
** Activation Methods
7 u9 R+ m. Q+ }( J*****************************************************************************/
( n3 P8 Y3 }% j7 e/* Explicit Activation
, K7 s" s7 Z7 V0 r% m/ Q$ K** This entry point is used to activate the application explicitly, as in
/ t( y- E8 X( s* _4 x) `** "File->Execute UG/Open->User Function..." */: w8 Y: e, G4 }+ r1 t) W, c) Y* C
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )# E$ k/ j6 t! _0 i% g. n( [
{6 _8 C+ ]% \4 c* o! R3 G
/* Initialize the API environment */- q- K: C W5 S- [1 v7 f! K0 u. i
char prompt_string[]="open file";
4 x- F) u/ u5 C2 j char title_string[] = "select file";; i! Q! X$ t8 e S
char filter_string[] = "*.prt";2 \6 ]! u4 ^4 Y' @
char default_name[] = "my file";
+ q2 Q! R$ d+ ?+ M6 D/ r3 A char filename[256];
& e7 n1 N/ T- d( y1 t& z+ i int response;' Q3 f0 l* o9 d1 l" `
if( UF_CALL(UF_initialize()) )
d. M2 U6 o+ K3 d {/ u# }0 E7 W; m6 u- Z
/* Failed to initialize */
+ Y5 a3 W) l3 y+ R# @* W return;
1 a* {$ ^& e8 _- Z }! B/ @# G+ O! I& C( P
5 w3 B# M U6 k; Z$ c/ b" r( B /* TODO: Add your application code here */
! x2 }' t: O- e" ]" S2 o UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox
: V+ M0 I+ e4 b0 a& v /* Terminate the API environment */# T- l" Q9 W* d3 b4 B% @
UF_CALL(UF_terminate());0 A) P' I/ M8 F- W* P
}+ @9 G1 R$ t' W1 [0 q3 ?; Z K
/*****************************************************************************+ T" N6 O. e: A2 G& Y
** Utilities
: p" l* m3 y6 i$ v4 y*****************************************************************************/
4 {, x: U \/ ]5 L) h6 |/* Unload Handler
* y5 [3 S# q2 m( g2 o5 S( k# G** This function specifies when to unload your application from Unigraphics. a4 |6 n0 J. a/ f) K' l
** If your application registers a callback (from a MenuScript item or a
. c2 ?* G% g9 S( s% {% o** User Defined Object for example), this function MUST return! I! F3 _: m7 @5 E5 I
** "UF_UNLOAD_UG_TERMINATE". */
+ P* |5 F' N( B' T- M& uextern int ufusr_ask_unload( void )% L( @' Y8 @* `
{6 m5 A1 Y3 L u# U$ b" @
return( UF_UNLOAD_IMMEDIATELY );( J+ Z0 L+ o% s+ I8 q; b! o
}
0 _4 C5 |1 p0 \0 @* B) L
8 V5 c$ l$ z+ k5 g2 |9 R4 @8 i5 a5 } |
-
|