uf选择对象另存为x_t
//////////////////////////////////////////////////////////////////////////////
//
// m_daochux_t.cpp
//
// Description:
// Contains Unigraphics entry points for the application.
//
//////////////////////////////////////////////////////////////////////////////
// Include files
#include <uf.h>
#include <uf_exit.h>
#include <uf_ui.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 "m_daochux_t.h"
#include <string>
#include <uf_modl.h>
#include <uf_ps.h>
#include <uf_obj.h>
using namespace std;
//----------------------------------------------------------------------------
// Activation Methods
//----------------------------------------------------------------------------
// 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 */
// 选择一个对象 导出 *.x_t
char *message="请选择对象:";
char *title="请选择对象:";
int scope=UF_UI_SEL_SCOPE_NO_CHANGE;
int response;
tag_t object_tag;
double cursor[3];
tag_t view;
UF_UI_select_with_single_dialog(message,title,scope,NULL,NULL,&response,&object_tag,cursor,&view); //选择框】
UF_DISP_set_highlight(object_tag,0); //1高亮显示 0不高亮显示
//UF_OBJ_set_color(object_tag,20); //改颜色
uf_list_p_t body_list; // 变量body_list为 对象列表
UF_MODL_create_list(&body_list); // 必须写上不然下一条代码不成立
UF_MODL_put_list_item(body_list, object_tag); // object_tag对象加入到body_list对象列表尾部
uf_list_p_t body_list; // 变量body_list为 对象列表
UF_MODL_create_list(&body_list); // 必须写上不然下一条代码不成立
UF_MODL_put_list_item(body_list, object); // object_tag对象加入到body_list对象列表尾部
char x_t[132]="C:\\m1.x_t";
UF_PS_export_data(body_list, x_t ); //导出x_t
/* Terminate the API environment */
errorCode = UF_terminate();
}
/* Print out any error messages */
PrintErrorMessage( errorCode );
}
//----------------------------------------------------------------------------
// 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 );
}
/* 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;
// Write the message to standard error
cerr << error_message.str();
}
}
_____________________________________________________________________________ _
中磊UG二次开发教程 梅雷著 qq1821117007
学UG就上UG网 http://www.9sug.com/ |