/*ARGUSED*/是什么功能.
这是我的程序,在成功create 了一个零件之后.我想用 UF_UI_select_with_class_dialog 和 UF_MODL_create_chamfer来给某些边导角,但加了以后.不成功. 我猜是后面有些问题,请大家给看看:
我选择了call Open++....
//////////////////////////////////////////////////////////////////////////////
//
// piston1.cpp
//
// Description:
// Contains Unigraphics entry points for the application.
//
//////////////////////////////////////////////////////////////////////////////
// Include files
#include <uf.h>
#include <uf_exit.h>
#include <uf_ui.h>
#include <stdio.h>
#include <uf_modl.h>
#include <uf_disp.h>
#include <uf_part.h>
#include <uf_object_types.h>
#include <uf_styler.h>
#include <ug_session.hxx>
#include <ug_line.hxx>
#include <ug_arc.hxx>
#include <ug_edge.hxx>
#include <ug_orientable.hxx>
#include <ug_exception.hxx>
#include <ug_info_window.hxx>
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
# include <strstream>
using std:strstream;
using std::endl;
using std::ends;
#else
# include <strstream.h>
#endif
#include <iostream.h>
#include "piston2.h"
static int init_proc(UF_UI_selection_p_t select,
void *user_data);
#define UF_CALL(X) (report( __FILE__, __LINE__, #X, (X)))
//----------------------------------------------------------------------------
// Activation Methods
//----------------------------------------------------------------------------
// Unigraphics Startup
// This entry point activates the application at Unigraphics startup
static int report( char *file, int line, char *call, int irc)
{
if (irc)
{
char messg[133];
printf("%s, line %d: %s\n", file, line, call);
(UF_get_fail_message(irc, messg)) ?
printf(" returned a %d\n", irc) :
printf(" returned error %d: %s\n", irc, messg);
}
return(irc);
}
extern "C" DllExport void ufsta( char *param, int *returnCode, int rlen )
{
// Initialize the API environment
UgSession session( true );
try
{
// TODO: Add your application code here
//----------------------------------------------
//SHELL
.....................................................................................
此处省略了实体的创建程序
..................................................................................
}
// Handle errors
catch ( const UgException &exception )
{
processException( exception );
}
}
//DIALOG-CHAMFER
static void do_ugopen_api(void)
{
char cue[] = "Select Objects";
char title[] = "User Title";
int response, count, i;
tag_t chamfers;
int subtype = 2;
char *offset1 ="0.5";
char *offset2 ="0.5";
char *theta ="";
tag_p_t edges;
uf_list_p_t edge_list;
/* Use multiple class selection with scope set to any object
in the work part and without using an initialization
procedure.
*/
if((UF_CALL(UF_UI_select_with_class_dialog(
cue, title, UF_UI_SEL_SCOPE_WORK_PART,
NULL, NULL, &response, &count, &edges))) == 0)
{
printf("object count = %d\n",count);
if (response == UF_UI_OK && count > 0)
{
for (i=0; i<count; i++)
{
printf("object tag = %d\n", edges);
UF_DISP_set_highlight(edges, 0);
UF_MODL_put_list_item (edge_list,edges );
UF_MODL_create_chamfer (subtype,offset1,offset2,theta,edge_list,[$chamfers)]
}
}
}
UF_free(edges);
UF_CALL(UF_MODL_delete_list([$edge_list))]
}
/*ARGUSED*/
void ufusr(char *param, int *retcode, int param_len)
{
if (!UF_CALL(UF_initialize()))
{
do_ugopen_api();
UF_CALL(UF_terminate());
}
}
int ufusr_ask_unload(void)
{
return (UF_UNLOAD_IMMEDIATELY);
}
//----------------------------------------------------------------------------
// 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 "C" int ufusr_ask_unload( void )
{
return( UF_UNLOAD_UG_TERMINATE );
}
// processException
//
// Prints error messages to standard error and a Unigraphics
// information window.
void processException( const UgException &exception )
{
// Construct a buffer to hold the text.
ostrstream error_message;
// Initialize the buffer with the required text.
error_message << endl
<< "Error:" << endl
<< ( exception.askErrorText() ).c_str()
<< endl << endl << ends;
// Open the UgInfoWindow
UgInfoWindow:pen ( );
// Write the message to the UgInfoWindow. The str method
// freezes the buffer, so it must be unfrozen afterwards.
UgInfoWindow::write( error_message.str() );
// Write the message to standard error
cerr << error_message.str();
error_message.rdbuf()->freeze( 0 );
} |