UG NX二次开发Ufun关于对话框UI的使用案例大全
UG NX二次开发Ufun关于对话框UI的使用案例大全NX二次开发ufun中的基本对话框使用案例大全... 1 1. //测试 uc1600 和 uc1601. 1 2. //测试uc1603 --》用来创建带有button的系列按钮... 2 3. //测试uc1605--》用来创建复选框... 3 4. //测试uc1607. 3 5. //测试uc1608-->用来获取int 或者 real类型的输入框... 4 6. //测试uc1609 -->用来获取real类型的输入框... 4 7. //测试uc1613 -->用来获取int,real,string类型的输入框... 5 8. 源码分享:... 5
**** Hidden Message *****
源码分享:
/*****************************************************************************
**
** ufuitest.cpp
**
** Description:
** Contains Unigraphics entry points for the application.
**
*****************************************************************************/
/* Include files */
#if ! defined ( __hp9000s800 ) && ! defined ( __sgi ) && ! defined ( __sun )
# include <strstream>
# include <iostream>
using std::ostrstream;
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>
#include <sstream>
#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,
msg;
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);
}
/*****************************************************************************
**Activation Methods
*****************************************************************************/
/*Unigraphics Startup
** This entry point activates the application at Unigraphics startup */
extern DllExport void ufsta( char *param, int *returnCode, int rlen )
{
/* Initialize the API environment */
if( UF_CALL(UF_initialize()) )
{
/* Failed to initialize */
return;
}
/* TODO: Add your application code here */
//测试 uc1600 和 uc1601
std::stringstreamss;
char *cue = "PLM之家测试ufun常用的UI";
char str = "输入字符串";
char msg;
int length,result;
result = uc1600(cue,str,&length); //获取输入的字符串
sprintf(msg,"%d",length);
if(result == 3)
{
uc1601(msg,1); //弹出消息对话框,1代表是对话框,0 代表在消息显示在状态行上
}
//测试uc1603 --》用来创建带有button的系列按钮
char *title = "测试uc1603";
char items[]={{"创建block"},{"-"},{"创建Cylinder"},{"创建sphere"}};
result = uc1603(title,1, items,4);
if(result ==5)
{
uc1601("这个是对应的第一个选项,创建block",1);
}
if(result ==6)
{
uc1601("这个是对应的第二个选项,此处是一个分割线",1);
}
if(result ==7)
{
uc1601("这个是对应的第三个选项,创建Cylinder",1);
}
if(result ==8)
{
uc1601("这个是对应的第四个选项,创建sphere",1);
}
//测试uc1605--》用来创建复选框
int selected;
uc1605(cue,0,items,4,selected);
//测试uc1607
char *cp1="测试1607";
char cp2[] = {{"Length"},{"Width"},{"Height"}};
intia4={100,200,300};
uc1607(cp1,cp2,3,ia4,0);
//测试uc1608-->用来获取int 或者 real类型的输入框
char *cp11="测试1608";
char cp21[] = {{"integer1"},{"double1"},{"integer2"}};
intia41={100,200,300}; //ip6 的值为0的适合选取int
double ra5 = {30.5,50.8,100.3}; // ip6 的值为1的适合选取double
int ip6={0,1,0};
uc1608(cp11,cp21,3,ia41,ra5,ip6);
//测试uc1609 -->用来获取real类型的输入框
char *cp12="测试1609";
char cp22[] = {{"double1"},{"double2"},{"double3"}};
double ra42 = {30.5,50.8,100.3};
uc1609(cp12,cp22,3,ra42,NULL);
//测试uc1613 -->用来获取int,real,string类型的输入框
char *cp13="测试1613";
char cp23[] = {{"integer"},{"Double"},{"String"}};
int a3 ={10,20,30};
double ra53={11.23,12.45,12.67};
char ca63[] ={"string1","string2","string3"};
int ip73 = {100,200,300}; //指定对应类型的范围
uc1613(cp13,cp23,3,a3,ra53,ca63,ip73);
/* 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_IMMEDIATELY );
}
先顶一个 谢谢,这是好东西:) 好资料,谢谢啦 看看,学习了 PLM之家PLM之家 无数个赞 :)谢谢高手分享 多谢分享,辛苦了 我来看看了