找回密码
 立即注册

QQ登录

只需一步,快速开始

微信扫码登录

搜索
查看: 238|回复: 6

[已解决] UF_UI_PARAM_edit_object 使用方法求助

[复制链接]

6

主题

22

回帖

1122

积分

六级士官

积分
1122
发表于 2026-5-29 08:48:49 | 显示全部楼层 |阅读模式
下面这段代码,是想先用鼠标选择工序, 通过UF_UI_PARAM_edit_object弹出工序的对话框,但是没有反应, 请问这个函数如何使用?

                UF_initialize();
               
                int  count = 0;
                tag_t * objects = NULL;


                UF_UI_ONT_ask_selected_nodes(&count, &objects);
               


                int dialog_response=0;


                UF_UI_PARAM_edit_object(objects[0], &dialog_response);




                UF_UI_ONT_refresh();


                UF_free(objects);
                UF_terminate();

5

主题

53

回帖

2860

积分

少尉

积分
2860
发表于 2026-5-29 13:50:22 | 显示全部楼层
我试了下,没问题啊,可以弹出参数编辑界面,NX8/NX12都可以,这是我试的代码
        int count = 0;
        tag_t * objects = NULL;
        UF_UI_ONT_ask_selected_nodes(&count, &objects);
        if (count <= 0)
        {
                uc1601("未选择对象", 1);
        }
        else
        {
                for (int i = 0; i < count; i++)
                {
                        int type = 0;
                        int subtype = 0;
                        UF_OBJ_ask_type_and_subtype(objects[i], &type, &subtype);
                        if (type == UF_machining_operation_type)
                        {
                                int dialog_response = 0;
                                UF_UI_PARAM_edit_object(objects[0], &dialog_response);
                        }
                        else
                        {
                                return;
                        }
                }
        }

6

主题

22

回帖

1122

积分

六级士官

积分
1122
 楼主| 发表于 2026-5-29 15:55:58 | 显示全部楼层
不小明我们不约 发表于 2026-5-29 13:50
我试了下,没问题啊,可以弹出参数编辑界面,NX8/NX12都可以,这是我试的代码
        int count = 0;
        tag_t * ob ...

感谢回复,谢谢

6

主题

22

回帖

1122

积分

六级士官

积分
1122
 楼主| 发表于 2026-6-2 16:45:25 | 显示全部楼层
不小明我们不约 发表于 2026-5-29 13:50
我试了下,没问题啊,可以弹出参数编辑界面,NX8/NX12都可以,这是我试的代码
        int count = 0;
        tag_t * ob ...

您好, 由于我权限不够,无法给你发送私信, 在这里向您请教个问题, 二次开发中, 可变轮廓铣或者固定轴轮廓铣,, 如何设置边界驱动,下面的代码, message返回信息是   Object is not the desired type    应该如何设置, 网上找了很久, 也没有找到相关资料

int count = 0;
        tag_t *objects = NULL;


        UF_UI_ONT_ask_selected_nodes(&count, &objects);
        
        int count1 =1;
        tag_t curves[1] = {45219};




        UF_CAMBND_boundary_data_t boundary_data;
        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;
        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 dates = &app_data;


        int err = UF_CAMBND_append_bnd_from_curve(objects[0], UF_CAM_drive, count1, curves,&boundary_data, &dates);
        
        char message[133];
        UF_get_fail_message(1345005, message);




        lw->Open();
       lw->WriteFullline(message);


        UF_free(objects);

1

主题

319

回帖

2356

积分

少尉

积分
2356
发表于 2026-6-3 16:17:47 | 显示全部楼层
给你一个参考下:
#include <uf.h>
#include <uf_ui.h>
#include <uf_obj.h>
#include <uf_cam.h>
#include <uf_cambnd.h>
#include <uf_defs.h>
#include <string.h>
#include <stdio.h>

void test_add_drive_boundary()
{
    int count = 0;
    tag_t *objects = NULL;

    UF_UI_ONT_ask_selected_nodes(&count, &objects);

    ListingWindow *lw = Session::GetSession()->ListingWindow();
    lw->Open();

    if (count <= 0 || objects == NULL)
    {
        lw->WriteFullline("No CAM object selected.");
        return;
    }

    tag_t oper_tag = objects[0];

    char cam_type[133] = "";
    char cam_subtype[133] = "";

    int status = UF_CAM_ask_object_type(oper_tag, cam_type, cam_subtype);

    if (status != 0)
    {
        lw->WriteFullline("Selected object is not a valid CAM object.");
        UF_free(objects);
        return;
    }

    char info[256];
    sprintf(info, "Selected CAM object type = %s, subtype = %s", cam_type, cam_subtype);
    lw->WriteFullline(info);

    /*
        这里需要确认 oper_tag 是 Operation。
        如果选中的是 Program、Tool、Method、Geometry 等对象,
        UF_CAMBND_append_bnd_from_curve 会报 Object is not the desired type。
    */

    int count1 = 1;

    tag_t curves[1];
    curves[0] = 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 object 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_msg[256];
        sprintf(err_msg, "UF_CAMBND_append_bnd_from_curve failed. err = %d, message = %s", err, message);
        lw->WriteFullline(err_msg);
    }
    else
    {
        lw->WriteFullline("Drive boundary added successfully.");
    }

    UF_free(objects);
}

6

主题

22

回帖

1122

积分

六级士官

积分
1122
 楼主| 发表于 2026-6-3 18:27:07 | 显示全部楼层
f3634861 发表于 2026-6-3 16:17
给你一个参考下:
#include
#include

你好,你这个是AI写的吧, 没有UF_CAM_ask_object_type这个函数

1

主题

319

回帖

2356

积分

少尉

积分
2356
发表于 2026-6-4 08:19:15 | 显示全部楼层
2217231767 发表于 2026-6-3 18:27
你好,你这个是AI写的吧, 没有UF_CAM_ask_object_type这个函数

#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);
}
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

咨询QQ:1359218528|发帖须知!|Archiver|手机版|UG爱好者论坛 ( 京ICP备10217105号-2 )

GMT+8, 2026-7-19 03:10

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表