2217231767 发表于 2026-5-29 08:48:49

UF_UI_PARAM_edit_object 使用方法求助

下面这段代码,是想先用鼠标选择工序, 通过UF_UI_PARAM_edit_object弹出工序的对话框,但是没有反应, 请问这个函数如何使用?

                UF_initialize();
               
                intcount = 0;
                tag_t * objects = NULL;


                UF_UI_ONT_ask_selected_nodes(&count, &objects);
               


                int dialog_response=0;


                UF_UI_PARAM_edit_object(objects, &dialog_response);




                UF_UI_ONT_refresh();


                UF_free(objects);
                UF_terminate();

不小明我们不约 发表于 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, &type, &subtype);
                        if (type == UF_machining_operation_type)
                        {
                                int dialog_response = 0;
                                UF_UI_PARAM_edit_object(objects, &dialog_response);
                        }
                        else
                        {
                                return;
                        }
                }
        }

2217231767 发表于 2026-5-29 15:55:58

不小明我们不约 发表于 2026-5-29 13:50
我试了下,没问题啊,可以弹出参数编辑界面,NX8/NX12都可以,这是我试的代码
        int count = 0;
        tag_t * ob ...

感谢回复,谢谢

2217231767 发表于 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 = {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;
      boundary_data.origin = 0.0;
      boundary_data.origin = 0.0;


      boundary_data.matrix = 1.0;
      boundary_data.matrix = 0.0;
      boundary_data.matrix = 0.0;


      boundary_data.matrix = 0.0;
      boundary_data.matrix = 1.0;
      boundary_data.matrix = 0.0;


      boundary_data.matrix = 0.0;
      boundary_data.matrix = 0.0;
      boundary_data.matrix = 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, UF_CAM_drive, count1, curves,&boundary_data, &dates);
      
      char message;
      UF_get_fail_message(1345005, message);




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


      UF_free(objects);

f3634861 发表于 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;

    char cam_type = "";
    char cam_subtype = "";

    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;
    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;
    curves = 45219;

    int curve_type = 0;
    int curve_subtype = 0;

    UF_OBJ_ask_type_and_subtype(curves, &curve_type, &curve_subtype);

    char curve_info;
    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;
    boundary_data.origin = 0.0;
    boundary_data.origin = 0.0;

    boundary_data.matrix = 1.0;
    boundary_data.matrix = 0.0;
    boundary_data.matrix = 0.0;

    boundary_data.matrix = 0.0;
    boundary_data.matrix = 1.0;
    boundary_data.matrix = 0.0;

    boundary_data.matrix = 0.0;
    boundary_data.matrix = 0.0;
    boundary_data.matrix = 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 = "";
      UF_get_fail_message(err, message);

      char err_msg;
      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);
}

2217231767 发表于 2026-6-3 18:27:07

f3634861 发表于 2026-6-3 16:17
给你一个参考下:
#include
#include


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

f3634861 发表于 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, &type, &subtype);

    char info;
    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;

    int count1 = 1;
    tag_t curves = { 45219 };

    int curve_type = 0;
    int curve_subtype = 0;

    UF_OBJ_ask_type_and_subtype(curves, &curve_type, &curve_subtype);

    char curve_info;
    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;
    boundary_data.origin = 0.0;
    boundary_data.origin = 0.0;

    boundary_data.matrix = 1.0;
    boundary_data.matrix = 0.0;
    boundary_data.matrix = 0.0;

    boundary_data.matrix = 0.0;
    boundary_data.matrix = 1.0;
    boundary_data.matrix = 0.0;

    boundary_data.matrix = 0.0;
    boundary_data.matrix = 0.0;
    boundary_data.matrix = 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 = "";
      UF_get_fail_message(err, message);

      char err_info;
      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);
}
页: [1]
查看完整版本: UF_UI_PARAM_edit_object 使用方法求助