UG二次开发常用函数模板

更新时间:2023-07-24 05:47:01 阅读量: 实用文档 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

UG二次开发常用函数模板

1、 uc1600 //获取字符串

头文件:#include <uf_ui.h>

2、 uc1603 //

int res = 0; int len = 0; char string[100]=""; res = uc1600( "",string , &len );//string:Input / Output if ( res == 5 || ( res== 3 && len > 0 ) ) { } else { }

头文件:#include <uf_ui.h>

用法1:

char title [100] = "菜单";

char items [3] [ 38 ] = { "选项1","选项2","选项3"};

choice = uc1603(title, 0, items, 3);

if (choice == 1 || choice == 2)

{

UF_terminate();

}

else

{

if (choice == )

{

}

}

用法2:

char items [3] [ 38 ] = { "选项1","选项2","选项3"};

response = uc1603( "菜单", 0, items, 3 );

switch ( response )

{

case 1:

case 2:

break;

case 4:

case 5:

}

3、选择对话框头文件

头文件1: init_proc_face

static int init_proc_face( UF_UI_selection_p_t select, void* user_data )

{

int nums = 1;

UF_UI_mask_t masks[] = {

UF_solid_type, 0, UF_UI_SEL_FEATURE_ANY_FACE};

if((UF_UI_set_sel_mask(select,

UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC,

nums, masks)) == 0)

{

return (UF_UI_SEL_SUCCESS);

}

else

{

return (UF_UI_SEL_FAILURE);

}

}

头文件2: init_proc_body

static int init_proc_body(UF_UI_selection_p_t select, void* user_data)

int num_triples = 1;

UF_UI_mask_t mask_triples[] = { UF_solid_type, 0, UF_UI_SEL_FEATURE_BODY};

/* enable only lines and edges */

if((UF_CALL(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);

}

}

4、UF_UI_select_with_single_dialog

头文件:#include <uf_ui.h>

char title[]="";

char cue[] = "";

int response=0;

double cursor [3];

tag_t face = NULL;

tag_t view = NULL;

if(!UF_CALL(UF_UI_select_with_single_dialog( cue, title, UF_UI_SEL_SCOPE_NO_CHANGE, init_proc_face, NULL,

&response,&face,cursor ,&view)))

{

if (response == UF_UI_OBJECT_SELECTED ||

response == UF_UI_OBJECT_SELECTED_BY_NAME)

{

printf("object tag = %d\n", face);

}

UF_DISP_set_highlight(face, 0);//关高亮

}

5、UF_UI_select_with_class_dialog

头文件:#include <uf_ui.h>

void class_sel_dlg(int *count,tag_p_t *objects)

{

char cue[] = "";

char title[] = "";

int response, sel_count, i;

tag_p_t sel_objects;

if((UF_CALL(UF_UI_select_with_class_dialog(

cue, title, UF_UI_SEL_SCOPE_NO_CHANGE,

init_proc_face, NULL, &response, &sel_count, &sel_objects))) == 0) {

printf("object count = %d\n",sel_count);

if (response == UF_UI_OK && sel_count > 0)

{

*objects=sel_objects;

*count=sel_count;

for (i=0; i<sel_count; i++)

{

printf("object tag = %d\n", sel_objects[i]);

UF_DISP_set_highlight(sel_objects[i], 0);

}

UF_free(objects);

}

}

}

6、UF_MODL_delete_object_parms//消参

头文件:

#include < uf_modl.h>

#include < uf_modl_utilities.h >

uf_list_p_t obj_list;

UF_CALL(UF_MODL_create_list(&obj_list));

UF_CALL(UF_MODL_put_list_item(obj_list, ));

UF_CALL(UF_MODL_put_list_item(obj_list, ));

UF_MODL_delete_object_parms(obj_list);

UF_MODL_delete_list(&obj_list);

UF_OBJ_delete_object();

7、UF_CURVE_create_arc//通过圆心,半径画圆

头文件:

#include < uf_csys.h>

#include < uf_curve.h>

tag_t arc, wcs_tag;

UF_CSYS_ask_wcs(&wcs_tag);

UF_CURVE_arc_t arc_coords;

UF_CSYS_ask_matrix_of_object(wcs_tag,&wcs_tag);

arc_coords.matrix_tag=wcs_tag;

arc_coords.start_angle = 0.0;

arc_coords.end_angle =360.0 * DEGRA;

arc_coords.arc_center[0] = center[0];//

arc_coords.arc_center[1] = center[1];//

arc_coords.arc_center[2] = center[2];//

arc_coords.radius = 500;

UF_CURVE_create_arc(&arc_coords,&arc_id);

8、UF_OBJ_set_name(tag,name); //设置名字

头文件#include <uf_obj.h>

9、name开关

int name_status ;

UF_DISP_ask_name_display_status(&name_status);

if (name_status==UF_DISP_NAME_DISPLAY_OFF )

{

name_status=UF_DISP_NAME_DISPLAY_ON;

}

else

{

name_status=UF_DISP_NAME_DISPLAY_OFF;

}

UF_DISP_set_name_display_status(name_status);

10、UF_OBJ_set_color(tag, color); //设置颜色

头文件#include <uf_obj.h>

11,UF_OBJ_set_layer (tag,layer); //设置层

头文件#include <uf_obj.h>

12,UF_CALL

头文件#include <uf.h>

int UF_CALL ( int errorCode )

{

if ( errorCode )

{

char message [133] = "";

UF_get_fail_message( errorCode, message );

uc1601 ( message, 1);

}

return (errorCode);

}

13, UF_PART_ask_display_part

头文件#include <uf_part.h>

tag_t part = UF_PART_ask_display_part ( );

if ( NULL == part )

{

uc1601( "", 1 );

return;

}

14, UF_OPER_create

头文件#include <uf_oper.h>

tag_t Oper_id = NULL;

UF_OPER_create ( "mill_contour", "ZLEVEL_PROFILE_YBC", &GZM_Oper_id );

15,UF_MODL_ask_face_data//查询面的信息

头文件#include <uf_modl.h>

tag_t face;//面的ID

int type; //面的类型

double box[6];//x,y,z向最大,最小值

double radius;

double rad_data;

int norm_dir ;//法向

UF_MODL_ask_face_data(face,&type,center,

dir,box,&radius,&rad_data,&norm_dir);

16,UF_MODL_ask_minimum_dist_2//查询两物体间距离

double dis,accuracy;// accuracy:准确度

double point1[ 3 ]={0};

double point2[ 3 ]={0};

UF_CALL(UF_MODL_ask_minimum_dist_2 ( obj1, obj2, 0, NULL, 0, NULL,

& dis, point1, point1, &accuracy ));

本文来源:https://www.bwwdw.com/article/9xkm.html

Top