NX CAM二次开发-UF_NCPROG_create创建程序组

NX9+VS2012

#include <uf.h>
#include <uf_setup.h>
#include <uf_ncgroup.h>
#include <uf_ui_ont.h>
#include <uf_obj.h>
#include <uf_ui.h>


UF_initialize();

//获取加工设置
tag_t setup_tag = NULL_TAG;
UF_SETUP_ask_setup(&setup_tag);
if (setup_tag == NULL_TAG)
{
    uc1601("提示:请先初始化加工环境", 1);
    return;
}

//创建程序组
tag_t new_object = NULL_TAG;
UF_NCPROG_create("mill_planar", "PROGRAM", &new_object);

//获得加工几何视图的根节点
tag_t program_group = NULL_TAG;
UF_SETUP_ask_program_root(setup_tag, &program_group);

//往程序组里添加成员
UF_NCGROUP_accept_member(program_group, new_object);

//设置名字
UF_OBJ_set_name(new_object, "LSY");

//刷新当前操作导视器
UF_UI_ONT_refresh();

UF_terminate();

Caesar卢尚宇
2020年5月3日

1.往根节点里创建程序组

2.往选中的程序组里创建程序组

UF_initialize();

//获取加工设置
tag_t setup_tag = NULL_TAG;
UF_SETUP_ask_setup(&setup_tag);
if (setup_tag == NULL_TAG)
{
    uc1601("提示:请先初始化加工环境", 1);
    return;
}

//获取当前加工导航器选中的对象数量和TAG
int count = 0;
tag_t* objects = NULL_TAG;
UF_UI_ONT_ask_selected_nodes(&count, &objects);
for (int i = 0; i < count; i++)
{

    //创建程序组
    tag_t new_object = NULL_TAG;
    UF_NCPROG_create("mill_planar", "PROGRAM", &new_object);

    //往程序组里添加成员
    UF_NCGROUP_accept_member(objects[i], new_object);

    //设置名字
    UF_OBJ_set_name(new_object, "LSY1");
}

//刷新当前操作导视器
UF_UI_ONT_refresh();

//释放
UF_free(objects);

UF_terminate();

Caesar卢尚宇
2020年5月3日

3.删除程序组

UF_initialize();

//获取加工设置
tag_t setup_tag = NULL_TAG;
UF_SETUP_ask_setup(&setup_tag);
if (setup_tag == NULL_TAG)
{
    uc1601("提示:请先初始化加工环境", 1);
    return;
}

//获取当前加工导航器选中的对象数量和TAG
int count = 0;
tag_t* objects = NULL_TAG;
UF_UI_ONT_ask_selected_nodes(&count, &objects);
for (int i = 0; i < count; i++)
{
    //删除程序组
    UF_OBJ_delete_object(objects[i]);
}

//刷新当前操作导视器
UF_UI_ONT_refresh();

//释放
UF_free(objects);

UF_terminate();

Caesar卢尚宇
2020年5月3日

作者: 阿飞

出处: https://www.cnblogs.com/nxopen2018/>

关于作者:......

如有问题, 可在底部(留言)咨询.

原文地址:https://www.cnblogs.com/nxopen2018/p/12823439.html