源玛:$ z$ M K- U3 B0 j. \6 a7 v
0 h* w4 Z/ Y6 Z/ b& y//////////////////////////////////////////////////////////////////////////////* a8 g* }+ s4 r+ c" Z+ J8 l
//
# H- N" T- L) j) N. Y7 i// create_oper.cpp
( I; p/ k8 Z( f$ @# |- A1 U S//5 q0 j5 {$ k2 ]; Q
// Description:' O; e+ Q# A5 ?* N
// Contains Unigraphics entry points for the application.
8 q: o( N3 j: g//) E3 p Y2 Y- H$ F3 g0 Z
//////////////////////////////////////////////////////////////////////////////5 ?5 r; {5 p8 {3 b$ L9 p2 s5 K
5 \9 j0 ]* ~6 F2 W( k* o, P7 a9 X// Include files2 v) r4 L; ~3 a, N( U
#include <uf.h>+ r8 Q% E& |. j0 \ i& y) N @
#include <uf_exit.h>
. V) Z7 {0 H. T. a0 o#include <uf_ui.h>
& P9 Q' ~2 [+ f9 s$ a#include <uf_oper.h>, W8 O6 _( c$ i! u
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
0 Y- r& J1 i& I5 T# include <strstream>
6 Z9 W. N. x8 l$ n; ?# include <iostream>
! D0 Q% O1 F! c* P using std:strstream;
1 j* y& \: ~1 Z3 L+ i8 q$ e1 @9 S using std::endl; " Z' |4 X2 J# k5 G/ S. i
using std::ends;
' Z$ ]! ~& N, s6 g# ~ using std::cerr;
/ u; L Y# H; B9 T#else, i% w, H* {- E s1 j. U# q( n
# include <strstream.h>
x& f2 D* y, V0 b0 O# include <iostream.h>
4 w3 m4 i! [2 u#endif
) B; X" a: H- z9 C) x- w' h& r#include "create_oper.h": u9 t3 r6 p1 U% R, ] L, {
+ i) V3 V/ L' v+ k) T//----------------------------------------------------------------------------
, M1 m) J9 u/ M3 ?7 h2 o: H// Activation Methods
2 W" G2 v3 n0 ]+ `8 N1 S& z//----------------------------------------------------------------------------- M$ |3 l. R! y5 {
, Q) w5 ^- H: V6 h* C5 a1 H6 v1 u" S
// Unigraphics Startup
7 W& v1 a& q& W0 E2 F3 f// This entry point activates the application at Unigraphics startup
+ k/ z5 ^; G5 Aextern "C" DllExport void ufsta( char *param, int *returnCode, int rlen )5 g4 b6 Z; e' k+ R- l( y
{/ D$ \0 l# p0 U5 _, f* S
/* Initialize the API environment */
, `' l- }4 v* ~ int errorCode = UF_initialize();
2 a; x% i: C* D2 ]! k: Z5 A" w2 v. @
/ {* y' n. |, ` if ( 0 == errorCode )
' `# ^) w$ W, A5 [$ ?. |+ u {! V* L W5 C/ ^( i$ E$ I; y6 I2 z
/* TODO: Add your application code here */' c% h) M6 S3 Y9 a$ r. t& J
2 B2 }3 E, |' w$ u: @% y: u( d" Y
char *type_name="mill_planar";
8 n. z4 k5 }- Y% \, [ char *subtype_name="FACE_MILLING_AREA";
# g0 o; K& u3 \+ b tag_t oper_tag;
l. h/ f7 |1 a% p) A* W, g8 d
2 q: K1 s0 e7 L1 r4 O UF_OPER_create(type_name,subtype_name,&oper_tag);
$ |' ~* _3 [# w) I* ?; v7 | V" u& Y# j% T! ?; L1 f
g+ }+ i" ]- F
2 [1 i& a4 v/ O
% @/ I2 J4 Z% r9 w
/* Terminate the API environment */
3 L# k5 x7 X, Q2 P3 ~$ O* ^6 S errorCode = UF_terminate();
9 ~- C& A* K6 }; n }
- g$ {2 m6 z) ?* } S8 X1 v: x
2 I" V" E2 u. l! Z /* Print out any error messages */
1 O0 {! V" K6 H5 K% n" I Y PrintErrorMessage( errorCode );3 b# r; q$ @4 Q* f( w
}
- `& g; f* `& I; s' @6 [+ \% {
h" }3 T6 D( x" I! F S e6 o8 M# M( G//----------------------------------------------------------------------------
$ j( H4 Z! M( o// Utilities
5 ~+ J: I2 j" H) K. L% ^//----------------------------------------------------------------------------$ }6 n5 W. @/ w
1 B7 }) ]. n' _// Unload Handler
; i# @4 l" M3 d% {// This function specifies when to unload your application from Unigraphics.7 p0 t" _) v P ^. S( Q
// If your application registers a callback (from a MenuScript item or a# e [% p' u& J1 a* B( `% F" u
// User Defined Object for example), this function MUST return
5 g# R4 I9 o+ l, y// "UF_UNLOAD_UG_TERMINATE".
2 A8 E: L6 \- f! O: Uextern "C" int ufusr_ask_unload( void )
" `1 M/ R. e1 @9 g+ f{& \! ~! D- G4 X0 W: h
return( UF_UNLOAD_UG_TERMINATE );7 b/ P8 D+ x& P9 f* l6 A( j) v
}
8 @. `. F7 x( q% ]4 G t8 K/ V Y' z# N, {8 X7 M4 ^, Y* R
/* PrintErrorMessage0 S& n" A7 _% I9 A$ T* N/ z& l
*** N# J: A' y) k) H C" @
** Prints error messages to standard error and the Unigraphics status, n1 o* y P* I# ~2 K" G
** line. */
" V+ N2 V- b$ H9 \) A( d; dstatic void PrintErrorMessage( int errorCode )
! |4 c' p) @; r' g% n{
. K" c2 B' F0 {0 E, f& d! H F3 Y3 ` if ( 0 != errorCode )
2 G1 _& L+ ^5 y2 v {
4 ?+ `9 p) N' D# d /* Retrieve the associated error message */, a2 ]0 R: [$ H) {
char message[133];$ e" e$ B+ ` l2 n% d4 g6 ^8 w
UF_get_fail_message( errorCode, message );
( g2 @ ]" F8 ^8 f4 T7 F8 Q- H _2 x% g; @* @& z! y: B
/* Print out the message */1 \7 B" O1 b6 w9 f7 z1 J. \; \
UF_UI_set_status( message );
3 f) x* ]% [$ s2 C7 h v8 L+ ?5 E: U
// Construct a buffer to hold the text.
" ]9 ?" ?- k7 A ostrstream error_message;
) b6 r. Y' ] _+ ?
- r* k5 v0 N) D' I- s( v // Initialize the buffer with the required text.2 q- m5 |) b: M3 d1 u: B' [' y) y
error_message << endl
5 G5 _1 E a+ r3 q8 ~1 M( N << "Error:" << endl
) n7 c- R, Y( A << message
x+ S7 \3 o& q << endl << endl << ends;/ k! _& f3 G) i9 R- M
' |; f# H# c& n8 Q8 h
// Write the message to standard error
+ C# D6 C/ Z0 r3 [; T8 V" ? cerr << error_message.str();
& c. g/ ~4 z4 Z2 s g) q }
0 m3 K8 h- q$ L# b* ~+ v0 s- F B} |