// Unigraphics Startup
// This entry point activates the application at Unigraphics startup
extern "C" DllExport void ufsta( char *param, int *returnCode, int rlen )
{
/* Initialize the API environment */
int errorCode = UF_initialize();
if ( 0 == errorCode )
{
/* TODO: Add your application code here */
char drawing_name [30] = "SHT1";
char view_name[30] = "ES@4";
char view_name2[30] = "MF@9";
char view_name3[30] = "MT@8";
char view_name4[30] = "R@7";
// char view_name5[30] = "T@5";
char view_name6[30] = " F@6";
char error_message[30] = "";
tag_t view_tag;
tag_t view_tag2 ;
tag_t view_tag3;
tag_t view_tag4;
// tag_t view_tag5;
tag_t view_tag6;
tag_t drawing_tag = NULL_TAG;
int ifail=0,ifail2=0,ifail3=0,ifail4=0,ifail5=0,ifail6=0;
tag_t exp_tag ;
tag_t exp_tag2;
tag_t exp_tag3 ;
tag_t exp_tag4 ;
//tag_t exp_tag5 ;
tag_t exp_tag6 ;
double scale;
ifail = UF_initialize();
if (!ifail)
{
/* Get the tag of drawing. */
ifail = UF_DRAW_ask_current_drawing (&drawing_tag);
}
if (!ifail)
{
/* Get the name of first drawing. */
ifail = UF_OBJ_ask_name(drawing_tag, drawing_name);
}
if (!ifail)
{
/* Get the name of the drawing's first view. */
ifail = uc6499 (drawing_name, view_name);
ifail2= uc6499 (drawing_name, view_name2);
ifail3= uc6499 (drawing_name, view_name3);
ifail4= uc6499 (drawing_name, view_name4);
// ifail5= uc6499 (drawing_name, view_name5);
ifail5= uc6499 (drawing_name, view_name6);
}
if (!ifail)
{
/* Get the view's tag. */
ifail = UF_VIEW_ask_tag_of_view_name (view_name,
&view_tag);
ifail2 = UF_VIEW_ask_tag_of_view_name (view_name2,
&view_tag2);
ifail3 = UF_VIEW_ask_tag_of_view_name (view_name3,
&view_tag3);
ifail4 = UF_VIEW_ask_tag_of_view_name (view_name4,
&view_tag4);
/* ifail5 = UF_VIEW_ask_tag_of_view_name (view_name5,
&view_tag5);*/
ifail6 = UF_VIEW_ask_tag_of_view_name (view_name6,
&view_tag6);
}
if (!ifail)
{
ifail = UF_DRAW_ask_view_scale (view_tag, &exp_tag,&scale);
ifail2 = UF_DRAW_ask_view_scale (view_tag2, &exp_tag2,&scale);
ifail3 = UF_DRAW_ask_view_scale (view_tag3, &exp_tag3,&scale);
ifail4 = UF_DRAW_ask_view_scale (view_tag4, &exp_tag4,&scale);
// ifail5 = UF_DRAW_ask_view_scale (view_tag5, &exp_tag5,&scale);
ifail6 = UF_DRAW_ask_view_scale (view_tag6, &exp_tag6,&scale);
}
if (!ifail)
{
/* Set the parametric view scale. */
ifail = UF_DRAW_set_view_scale (view_tag,0.9);
ifail2 = UF_DRAW_set_view_scale (view_tag2,0.9);
ifail3 = UF_DRAW_set_view_scale (view_tag3,0.9);
ifail4 = UF_DRAW_set_view_scale (view_tag4,0.9);
// ifail5 = UF_DRAW_set_view_scale (view_tag5,0.9);
ifail6 = UF_DRAW_set_view_scale (view_tag6,0.9);
}
printf ("UF_DRAW_set_view_scale sample ");
if (ifail)
{
ifail = UF_get_fail_message( ifail, error_message );
printf( "fails.\nError is: %s\n", error_message );
}
else
/* Terminate the API environment */
errorCode = UF_terminate();
}
/* Print out any error messages */
PrintErrorMessage( errorCode );
}
// Unload Handler
// This function specifies when to unload your application from Unigraphics.
// If your application registers a callback (from a MenuScript item or a
// User Defined Object for example), this function MUST return
// "UF_UNLOAD_UG_TERMINATE".
extern "C" int ufusr_ask_unload( void )
{
return( UF_UNLOAD_UG_TERMINATE );
}
/* PrintErrorMessage
**
** Prints error messages to standard error and the Unigraphics status
** line. */
static void PrintErrorMessage( int errorCode )
{
if ( 0 != errorCode )
{
/* Retrieve the associated error message */
char message[133];
UF_get_fail_message( errorCode, message );
/* Print out the message */
UF_UI_set_status( message );
// Construct a buffer to hold the text.
ostrstream error_message;
// Initialize the buffer with the required text.
error_message << endl
<< "Error:" << endl
<< message
<< endl << endl << ends;