|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
' s0 [6 ~& u4 ~* W/*****************************************************************************1 a2 @- b8 f4 k+ G: E
**
9 f% g P3 N: X" x0 G** createfilebox.cpp
, m: ]! C4 C. O+ A# V$ Z4 \' N**( r6 q* D* y2 r+ }
** Description:
7 `/ C- ^2 |/ T2 z$ h** Contains Unigraphics entry points for the application.
K& d. V+ n. I2 M**" S3 F! ^( V/ B- R0 r
*****************************************************************************/
8 c% n( m2 \" k; \# y/* Include files */
/ w1 }$ U5 e% h& O. J/ G#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
. }5 i1 }8 L6 \3 E& J# include <strstream>9 b1 i7 b ` h L/ P
# include <iostream>
6 z; m( O5 {/ n1 r% d' R' R2 z using std:strstream;$ e% h$ i0 j) K$ B! X8 ~
using std::endl; 3 T1 I5 |( r0 u( V0 S' c* H
using std::ends;
$ I7 U0 S& n I: o using std::cerr;
; r/ p8 M3 \- R# `" x# \( d#else
5 O2 M! R$ @& w, c* B# include <strstream.h>
3 A$ ?" D$ g+ D" _( e& H; T# include <iostream.h>
# _! }7 R3 [ M3 t1 Q#endif: d% S* {. P3 M7 |4 B$ o
#include <uf.h>
% U8 p' f$ `: p4 h* s8 x) U9 p0 @#include <uf_ui.h>
) e5 b# P( |8 ~# f#include <uf_exit.h>
0 X& w) l8 s* d#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))$ B f+ H! ]+ H
static int report_error( char *file, int line, char *call, int irc)
. C. B# k" C1 e! y( H{ G6 D/ }( Y# t7 M ^3 F
if (irc)4 V/ w2 q5 H9 C7 Y1 z, [
{
6 L3 ~- T$ G) H. f; X* O* S6 q char err[133],' _! K! h L8 ]5 a# k. U& ^
msg[133];/ K3 g( i) f$ q, O3 _$ L, ^7 |
sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
2 L* p" p, Z, o# m) p# C- i! Y irc, line, file);% n0 N5 l( e4 f8 Q
UF_get_fail_message(irc, err);" N7 z% m. K, }& t0 b# O
UF_print_syslog(msg, FALSE);
5 R" @8 c! n2 U, ~% H UF_print_syslog(err, FALSE);; _5 E, G( \$ u% q
UF_print_syslog("\n", FALSE);! C" s& ^. q- w4 v/ `6 h
UF_print_syslog(call, FALSE);
2 S/ z) f6 I M+ U4 t UF_print_syslog(";\n", FALSE);
3 W M* \4 q8 c" b F, k- ~ if (!UF_UI_open_listing_window())
7 i7 c5 p6 Q, b: l( O {
# |7 {2 J. J- H) ` UF_UI_write_listing_window(msg);. a K5 y3 \% f% H
UF_UI_write_listing_window(err);8 ^0 ^) g: ^$ ?7 f! a# T0 n
UF_UI_write_listing_window("\n");. m# v5 M2 c, q% {6 i p) {
UF_UI_write_listing_window(call);
6 f8 s; J0 r- V; d. w1 W! b8 e. a UF_UI_write_listing_window(";\n");
8 J8 D g# Z' O- [: O+ x2 U* I }8 m3 P2 \* p O! B9 M O' o. B
}
o2 B7 n- V1 G' ~ return(irc);
* Q/ @ Z O2 G$ j5 I/ x1 i' s}
- p- `9 [8 [; d- G0 R1 s& g& w H
/*****************************************************************************3 [) Z0 h" d# I H/ P( y1 o- C; L/ w
** Activation Methods
1 i0 @: e# i5 a" c2 j1 |*****************************************************************************/
, P$ h6 w5 _# T0 P2 a/* Explicit Activation
" ?7 H6 ~3 n# L# Z2 i8 I% J& B4 q** This entry point is used to activate the application explicitly, as in" ^! ~& w. R2 B* \7 q! v
** "File->Execute UG/Open->User Function..." */
# Z5 z5 G5 B0 x2 j: j+ Cextern DllExport void ufusr( char *parm, int *returnCode, int rlen )
, E/ M7 X: |5 R! [4 d{( H- y3 N8 w' g% b: [
/* Initialize the API environment */
* D# _. t$ ]: d# i char prompt_string[]="open file";
+ [/ y6 b5 n0 T char title_string[] = "select file";
. k0 i7 V8 `: }) P% v char filter_string[] = "*.prt";6 v: l( G R/ w
char default_name[] = "my file";6 G# ?4 q- [# \# n2 W
char filename[256];
$ t+ e: Q" Z W1 f int response;4 O6 Z1 t R9 j n% S7 F$ |4 t
if( UF_CALL(UF_initialize()) ) 8 R( g3 h) H4 n7 R5 Y
{7 N. z) x& E5 W; m0 x
/* Failed to initialize */
T% i+ A% R7 ]% M return;
- Q' {% q8 G# ]7 t }4 u8 i6 r, O) |6 V8 H# ^
$ w6 A: `7 W8 V8 F8 z# d
/* TODO: Add your application code here */
. |& G3 G* b) l& g9 [, l UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox+ q+ d( \: n7 S3 ^! O$ U
/* Terminate the API environment */
9 o' Q, W# O" \; l" d) [ UF_CALL(UF_terminate());
. m( S+ b* Q% v' ~( p0 M& a% ^}
% ~! n- O. ]" f/*****************************************************************************
( O5 h# E( L: A2 ^ h" L** Utilities
i# h, \% z- e5 R# R3 ]*****************************************************************************/
% l* q% v) K" c$ z6 F# ]/* Unload Handler
# F" ?2 k; H2 t/ C4 R** This function specifies when to unload your application from Unigraphics.
2 K7 V- A) Y2 j** If your application registers a callback (from a MenuScript item or a
4 l6 F$ ~7 m$ M/ g# D7 r3 o5 ]** User Defined Object for example), this function MUST return
. d6 c6 ^- D t& ]: W! Y** "UF_UNLOAD_UG_TERMINATE". */( Z) g0 j( G6 D8 l5 Y3 a
extern int ufusr_ask_unload( void )2 E/ Q1 c0 U7 z/ g7 _; D, |& X9 S
{
4 q5 I1 s% i0 t! [! H9 A3 S return( UF_UNLOAD_IMMEDIATELY );3 O. Z, v1 N x) B
}
$ A! }* {8 D2 A8 a2 `% I: F$ s: s, p5 _& M2 p
|
-
|