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 */
//代码放置区
//新建部件
char part_name1[132]= "E:\\UG-TD\\123.prt"; //可以自由更改存放位置和部件名字
int units =1; /* 单位 1=毫米 2=英寸*/
tag_t part_t;
UF_PART_new(part_name1,units,&part_t);//新建部件
extern void ufusr(char *param, int *retcod, int param_len);
{
/* 对话框设置*/
char * cp1 = "请选择";
int ip2 = 0;
char cp3[4][38] = {
"创建一个块(Block)",
"创建一个圆柱(Cylinder)",
"创建一个圆锥(Cone)",
"创建一球体(Sphere)"
};
int ip4 = 4;
int value;
tag_t view_tag = NULL_TAG;
UF_FEATURE_SIGN sign=UF_NULLSIGN;
/* Block的变量声明区*/
double blk_corner[ 3 ] = { 0.0,0.0,0.0};
char *blk_edge_len[ 3 ] = { "10","20","30"};
tag_t blk_obj_id;
/* Cylinder的变量声明区*/
double cyl_origin[ 3 ]= {0.0,0.0,0.0}; //圆心
char *cyl_height="50"; //高度
char *cyl_diam="30"; //直径
double cyl_direction[ 3 ]={0,0,1}; //轴方向
tag_t cyl_obj_id;
/* Cone的变量声明区*/
double cone_orgin[ 3 ] = { 0.0, 0.0, 0.0};
char *cone_height = "20";
char *cone_diam [ 2 ] = {"30","20"};
double cone_direction[ 3 ] = {0.0, 0.0, 1.0};
tag_t cone_obj_id;
/* Sphere的变量声明区*/
double spahere_center[ 3 ] = { 0.0, 0.0, 0.0};
char *sphere_diam = "30";
tag_t sphere_obj_id;
if( ! UF_initialize())
{
/* 显示菜单*/
value = uc1603( cp1, ip2, cp3, ip4 );
switch(value)
{
case 5:
UF_MODL_create_block1(sign,blk_corner,blk_edge_len,&blk_obj_id);
break;
case 6:
UF_MODL_create_cyl1(sign,cyl_origin,cyl_height,cyl_diam,cyl_direction,&cyl_obj_id);
break;
case 7:
UF_MODL_create_cone1(sign,cone_orgin,cone_height,cone_diam, cone_direction, &cone_obj_id);
break;
case 8:
UF_MODL_create_sphere1(sign,spahere_center, sphere_diam, &sphere_obj_id);
break;
default:
uc1601("发生了错误",0);
}
/* 调整视图到合适的大小*/
UF_VIEW_ask_work_view( &view_tag);
UF_VIEW_fit_view(view_tag,0.7);
/* 保存文件*/
UF_PART_save();
UF_terminate();
DLL插件下载,运行方法:
在UG上创建新的部件及源代码.zip
(196.31 KB, 下载次数: 14, 售价: 10 多墨币)
|
|