|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
6 r+ F' {' C3 w- w5 `/*****************************************************************************$ y& d% W+ J) D% W3 [% ?7 u0 Q
**
* ?6 Y, M: A8 z5 e* Y% _** createfilebox.cpp7 C" ]6 M V" t" i
**7 r. v0 ^8 O' m% ?% C& d
** Description:5 v/ Y# }2 f+ I# [) y* U) s' Z
** Contains Unigraphics entry points for the application." f/ }0 l% U1 O5 C0 f3 F3 _" h% n
**
* @# z- v6 ~+ @7 g7 k# h' g8 b*****************************************************************************/6 Q, T U! ~! E" {) c9 o& J2 d6 a
/* Include files */0 l; U+ ]. A, r
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )5 Q% {% a( L, A5 i: D4 l3 j9 c
# include <strstream>. x5 `, z( \& b9 e: K5 b* D' ~
# include <iostream>8 ?8 {' d5 x7 l
using std: strstream;; G/ q0 K- x T! y0 Q
using std::endl; . X5 r' r! z6 H" `$ M+ j' T
using std::ends;4 L# C+ Y' G, y: E, d) f
using std::cerr;/ B6 A/ i: Q6 N2 k
#else+ M( t6 @+ c# O& S: Z, e7 Z
# include <strstream.h>( }5 Z% u$ a# p) C
# include <iostream.h>
$ A W3 H% Z7 E$ f# H+ [#endif
" f# e! r+ q8 W9 }; o/ q; R8 h#include <uf.h>
" U7 {% H5 }/ F8 H! |#include <uf_ui.h>( u; c% @+ ~& W+ O6 v
#include <uf_exit.h>- b/ J, D; ]3 U1 k
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
3 C3 g8 i6 w) M4 o" q* O& ?( |% H, gstatic int report_error( char *file, int line, char *call, int irc)* J. u" W$ [ R
{$ @% l7 G! s% q( C
if (irc)% Q( s; v; `# }- S( @! s# B
{' u1 v& K" }: P8 a
char err[133],
3 u! F* w3 j5 \ h+ y msg[133];
1 y5 x" T0 e% p% l L! i6 `% J sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
# v' j* h* V1 Z8 o, R irc, line, file);. J1 F# a$ a/ }2 }& G/ E
UF_get_fail_message(irc, err);
4 Z+ |7 n. b5 r5 B8 l% e; L UF_print_syslog(msg, FALSE);! a u0 Z& W: E0 ~5 O. G. r7 q2 a
UF_print_syslog(err, FALSE);& j3 Q0 Y2 J& \ f2 f8 L* K* i+ C
UF_print_syslog("\n", FALSE);5 N" \) G0 B* N: [2 M( r# h
UF_print_syslog(call, FALSE);% W3 {, y. q {: B- g1 L
UF_print_syslog(";\n", FALSE);
1 R: W! s' {' k! K( F if (!UF_UI_open_listing_window())/ e4 z6 N- {$ C7 M
{
7 \' ?' }" Y' s- H UF_UI_write_listing_window(msg);* [# k: |, u8 T# P1 Y8 j
UF_UI_write_listing_window(err);
b: A9 E& ?* q UF_UI_write_listing_window("\n");6 r `8 X0 o# B/ l. z; w
UF_UI_write_listing_window(call);3 X5 f& N2 ]1 q1 B. ~
UF_UI_write_listing_window(";\n");: I9 p7 l! U$ y& r
}3 h9 k9 y1 H6 h3 j
}
+ k2 I% Y# X: P! P! _! l, o6 ^ return(irc);2 y5 \* G; ^9 @2 y
}
' j/ v; |9 _ }, Q. M8 o3 @( r5 N4 |# i! i% q% e3 [. y
/*****************************************************************************
! u- h; s0 |; y) P8 ~** Activation Methods
' {1 M& ^4 n& F" {) n*****************************************************************************/- a- G2 Z" S( l9 y
/* Explicit Activation
; V' S& I9 v4 F' q3 ?- r" w** This entry point is used to activate the application explicitly, as in5 Y2 O0 w% j& i" z; I
** "File->Execute UG/Open->User Function..." */: S) G5 e/ j1 C- C4 r) U T3 l
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )& t" A; k: Y$ W2 c
{
0 B$ d" k8 }3 v" j& A4 M /* Initialize the API environment */
5 A2 ?* G( i; G. l$ y char prompt_string[]="open file";6 S' d6 D2 V2 Q2 @: I8 |
char title_string[] = "select file";
& e. \7 W5 F, h: _7 D" X/ D char filter_string[] = "*.prt";+ Z2 m; g8 u) ^ k# L' O! u) g
char default_name[] = "my file";
" Q1 M# m) g2 [+ f( d char filename[256];9 M- L. I# {3 q V; F" O
int response;
9 u3 i5 k, z: z1 J" x" {$ X% P5 C$ m if( UF_CALL(UF_initialize()) )
! z/ A% D, |0 i4 l/ e) J2 H5 M' A {
1 h. d5 @& y0 }* x' d; k! r /* Failed to initialize */1 t7 w$ S" U; }* C# w: X# ^; @# ?
return;- n7 V E b+ M" }: t
}
# e z& O6 |9 N u/ [ 7 `2 G' X" G: t
/* TODO: Add your application code here */: o/ D) p# t9 `* A9 `
UF_UI_create_filebox(prompt_string,title_string,filter_string,default_name,filename,&response);//UF_UI_create_filebox! K, q& p b3 L4 M% Z0 x
/* Terminate the API environment */
1 h9 B. H; n' d0 i u: e* w UF_CALL(UF_terminate());" t$ g7 @ @* R9 g, v2 x
}
- E( Q: |( ^2 w, a. Y) J" j. v+ X/*****************************************************************************$ B% C8 }, G/ V8 i' |, e! v
** Utilities+ b8 h$ e9 r) u
*****************************************************************************/. Y% T9 V6 d3 v3 \' m3 U5 Y: q/ R
/* Unload Handler
; f# j4 w% B& c. Y" `/ {; D& r** This function specifies when to unload your application from Unigraphics.
8 P$ A' S1 o8 u** If your application registers a callback (from a MenuScript item or a
8 d3 n2 v: O3 V6 w8 k** User Defined Object for example), this function MUST return- l6 ^4 M! ~+ T S6 N8 T2 G1 o& D
** "UF_UNLOAD_UG_TERMINATE". */5 q6 g7 @ G7 @1 S2 i
extern int ufusr_ask_unload( void )
^6 i5 i3 ]$ F- `{
$ w& q" s6 ~* q; X6 R return( UF_UNLOAD_IMMEDIATELY );; b F2 Q% c; d& l
}9 D# z$ J; G+ h M: B
1 e& Q [8 g' f+ }6 G& I, ~4 o |
-
|