|
马上注册登录,享用更多网站功能!
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
#include <uf.h>
#include <uf_ui.h>
#include <uf_exit.h>
#include <uf_assem.h>
#include <uf_part.h>
#include <uf_layer.h>
#include <uf_modl.h>
#include <uf_obj.h>
#include <stdio.h>
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
# include <strstream>
# include <iostream>
using std:strstream;
using std::endl;
using std::ends;
using std::cerr;
#else
# include <strstream.h>
# include <iostream.h>
#endif
#include <uf.h>
#include <uf_ui.h>
#include <uf_exit.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);
}
static int init_proc( UF_UI_selection_p_t select, void *user_data )
{
int num_triples = 3 ; //可选类型的数量
//仅body可选
UF_UI_mask_t mask_triples[] = {
//{ UF_solid_type, UF_solid_body_subtype, 0} };
// UF_solid_type, 0, UF_UI_SEL_FEATURE_ANY_FACE
UF_feature_type, 0, UF_UI_SEL_FEATURE_ANY_EDGE,
UF_solid_type,UF_solid_body_subtype,UF_UI_SEL_FEATURE_BODY,
UF_datum_plane_type,0,UF_UI_SEL_NOT_A_FEATURE
};
if ( UF_UI_set_sel_mask( select, UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC, num_triples, mask_triples ) == 0 )
{
return UF_UI_SEL_SUCCESS;
}
else
{
return UF_UI_SEL_FAILURE;
}
}
static void do_ugopen_api()
{
tag_t body_tag=NULL_TAG;
tag_t face_tag=NULL_TAG;
uf_list_p_t object_list;
int count = 0;
char sCue1[]="选择特征面";
char sTitle1[] = "选择特征面";
int iScope = UF_UI_SEL_SCOPE_NO_CHANGE ;
int iResponse;
tag_t tObject1;
tag_t tView;
double adCursor[ 3 ] ;
char sCue2[]="选择剖切定位面";
char sTitle2[] = "选择剖切定位面";
tag_t tObject2;
UF_UI_select_with_single_dialog( sCue1, sTitle1, iScope, init_proc, NULL, &iResponse, &tObject1, adCursor, &tView ) ;
if ((iResponse == UF_UI_OBJECT_SELECTED) && (tObject1 != NULL_TAG))
{
UF_MODL_ask_feat_body (tObject1, &body_tag);
UF_UI_select_with_single_dialog( sCue2, sTitle2, iScope, init_proc, NULL, &iResponse, &tObject2, adCursor, &tView ) ;
if ((iResponse == UF_UI_OBJECT_SELECTED) && (tObject2 != NULL_TAG))
{
UF_MODL_ask_feat_faces(tObject2, &object_list);
//获得feature中face的个数
UF_MODL_ask_list_count(object_list,&count);
if(count >= 1)
{
//取出face list中第一个face的tag
UF_MODL_ask_list_item(object_list, 0, &face_tag);
}
int direction_flag = 0;
tag_t trim_feature;
UF_MODL_trim_body (body_tag,face_tag,direction_flag,&trim_feature);
}
} ;
}
/*****************************************************************************
** Activation Methods
*****************************************************************************/
/* Explicit Activation
** This entry point is used to activate the application explicitly, as in
** "File->Execute UG/Open->User Function..." */
extern DllExport void ufusr( char *parm, int *returnCode, int rlen )
{
/* Initialize the API environment */
if( UF_CALL(UF_initialize()) )
{
/* Failed to initialize */
return;
}
/* TODO: Add your application code here */
do_ugopen_api();
/* Terminate the API environment */
UF_CALL(UF_terminate());
}
/*****************************************************************************
** Utilities
*****************************************************************************/
/* 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 int ufusr_ask_unload( void )
{
return( UF_UNLOAD_UG_TERMINATE );
}
|
|