|
|
发表于 2026-6-4 08:19:15
|
显示全部楼层
#include <uf.h>
#include <uf_ui.h>
#include <uf_obj.h>
#include <uf_object_types.h>
#include <uf_cambnd.h>
#include <uf_cam.h>
#include <string.h>
#include <stdio.h>
void add_drive_boundary()
{
int count = 0;
tag_t *objects = NULL;
UF_UI_ONT_ask_selected_nodes(&count, &objects);
lw->Open();
if (count <= 0 || objects == NULL)
{
lw->WriteFullline("No object selected in Operation Navigator.");
return;
}
int type = 0;
int subtype = 0;
UF_OBJ_ask_type_and_subtype(objects[0], &type, &subtype);
char info[256];
sprintf(info, "selected object type = %d, subtype = %d", type, subtype);
lw->WriteFullline(info);
if (type != UF_machining_operation_type)
{
lw->WriteFullline("Selected object is not a machining operation.");
UF_free(objects);
return;
}
tag_t oper_tag = objects[0];
int count1 = 1;
tag_t curves[1] = { 45219 };
int curve_type = 0;
int curve_subtype = 0;
UF_OBJ_ask_type_and_subtype(curves[0], &curve_type, &curve_subtype);
char curve_info[256];
sprintf(curve_info, "curve type = %d, subtype = %d", curve_type, curve_subtype);
lw->WriteFullline(curve_info);
UF_CAMBND_boundary_data_t boundary_data;
memset(&boundary_data, 0, sizeof(UF_CAMBND_boundary_data_t));
boundary_data.boundary_type = UF_CAM_boundary_type_closed;
boundary_data.plane_type = 1;
boundary_data.material_side = UF_CAM_material_side_in_left;
boundary_data.origin[0] = 0.0;
boundary_data.origin[1] = 0.0;
boundary_data.origin[2] = 0.0;
boundary_data.matrix[0] = 1.0;
boundary_data.matrix[1] = 0.0;
boundary_data.matrix[2] = 0.0;
boundary_data.matrix[3] = 0.0;
boundary_data.matrix[4] = 1.0;
boundary_data.matrix[5] = 0.0;
boundary_data.matrix[6] = 0.0;
boundary_data.matrix[7] = 0.0;
boundary_data.matrix[8] = 1.0;
boundary_data.ignore_holes = 0;
boundary_data.ignore_islands = 0;
boundary_data.ignore_chamfers = 0;
boundary_data.app_data = NULL;
UF_CAMBND_app_data_t app_data;
memset(&app_data, 0, sizeof(UF_CAMBND_app_data_t));
app_data.has_stock = 0;
app_data.has_tolerances = 0;
app_data.has_feedrate = 0;
app_data.has_blank_distance = 0;
app_data.has_tool_position = 0;
UF_CAMBND_app_data_p_t app_data_ptr = &app_data;
int err = UF_CAMBND_append_bnd_from_curve(
oper_tag,
UF_CAM_drive,
count1,
curves,
&boundary_data,
&app_data_ptr
);
if (err != 0)
{
char message[133] = "";
UF_get_fail_message(err, message);
char err_info[256];
sprintf(err_info, "UF_CAMBND_append_bnd_from_curve failed, err = %d, message = %s", err, message);
lw->WriteFullline(err_info);
}
else
{
lw->WriteFullline("Append drive boundary successfully.");
}
UF_free(objects);
}
|
|