- 积分
- 10
- 注册时间
- 2007-10-5
- 仿真币
-
- 最后登录
- 1970-1-1
|
Function:ask blank offset distance
Description:
Contains Unigraphics entry points for the application.
The ONT needs a previously created Workpiece.
Highlight the Worpiece and execute this program
----------------------------
#include <stdio.h>
#include <uf.h>
#include <uf_ui.h>
#include <uf_cam.h>
#include <uf_lib.h>
#include <uf_param.h>
#include <uf_param_indices.h>
#include <uf_part.h>
#include <uf_obj.h>
#include <uf_obj_types.h>
#include <uf_ui_ont.h>
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
static int report_error( char *file, int line, char *call, int irc)
{
if (irc)
{
char err[133],
msg[133];
sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
irc, line, file);
UF_get_fail_message(irc, err);
UF_print_syslog(msg, FALSE);
UF_print_syslog(err, FALSE);
UF_print_syslog("\n", FALSE);
UF_print_syslog(call, FALSE);
UF_print_syslog(";\n", FALSE);
if (!UF_UI_open_listing_window())
{
UF_UI_write_listing_window(msg);
UF_UI_write_listing_window(err);
UF_UI_write_listing_window("\n");
UF_UI_write_listing_window(call);
UF_UI_write_listing_window(";\n");
}
}
return(irc);
}
#define WRITE(X) UF_UI_open_listing_window(); UF_UI_write_listing_window(X)
#define WRITE_S(X) (write_string_to_listing_window(#X, X))
void write_string_to_listing_window(char *title, char *string)
{
char
msg[MAX_LINE_SIZE+1];
UF_CALL(UF_UI_open_listing_window());
sprintf(msg, "%s = %s\n", title, string);
UF_CALL(UF_UI_write_listing_window(msg));
}
static void do_it(void)
{
logical
is_initialized;
int
object_count,
type,
subtype,
attributes=2;
double blank_dist;
tag_t
*objects;
char
msg[200];
if (UF_CALL(UF_CAM_is_session_initialized(&is_initialized)) ||
(is_initialized == FALSE)) return;
/* Get the highlighted/selected objects from Navigation Tool. */
UF_CALL(UF_UI_ONT_ask_selected_nodes( &object_count, &objects ));
if (object_count == 1)
{
UF_CALL( UF_OBJ_ask_type_and_subtype (objects[0],&type,&subtype));
if ((type == UF_machining_geometry_grp_type) &&
(subtype == UF_mill_geom_featr_subtype ))
{
// get the blank distance
// Note that the uf_param_indices.h file is wrong - it shows
//#define UF_PARAM_BLANK_DIST 266 /* UF_PARAM_type_double_length */
// see PR6076897
UF_CALL(UF_PARAM_ask_double_value(objects[0],381,&blank_dist));
sprintf(msg,"Blank distance is %f\n",blank_dist);
WRITE(msg);
}
else
{
WRITE("type is not UF_machining_geometry_grp_type");
WRITE(" or subtype is not UF_mill_geom_featr_subtyp");
}
UF_free(objects);
}
else
{
WRITE("objects selected in ONT is not equal to 1");
}
}
/*ARGSUSED*/
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )
{
if (UF_CALL(UF_initialize())) return;
do_it();
UF_CALL(UF_terminate());
}
extern int ufusr_ask_unload( void )
{
return( UF_UNLOAD_IMMEDIATELY );
} |
|