NX9+VS2012 #include <uf.h> #include <uf_ui.h> #include <uf_ncgroup.h> #include <uf_setup.h> #include <uf_ui_ont.h> #include <uf_obj.h> #include <uf_param.h> #include <uf_param_indices.h> #include <uf_oper.h> UF_initialize(); //获取当前NX的加工设置TAG tag_t setup_tag = NULL_TAG; UF_SETUP_ask_setup(&setup_tag); if (setup_tag == NULL_TAG) { uc1601("提示:请先初始化加工环境!", 1); return; } //获得当前程序视图的根节点 tag_t programRootGroup=NULL_TAG; UF_SETUP_ask_program_root(setup_tag, &programRootGroup); //创建程序组 tag_t newProgTag=NULL_TAG; UF_NCPROG_create("mill_planar" ,"PROGRAM", &newProgTag); UF_OBJ_set_name(newProgTag, "newProg"); UF_NCGROUP_accept_member(programRootGroup, newProgTag); //获得机床视图的根节点 tag_t mctRootgroup=NULL_TAG; UF_SETUP_ask_mct_root(setup_tag, &mctRootgroup); //创建新的刀具 tag_t newToolTag=NULL_TAG; UF_CUTTER_create("mill_planar", "MILL", &newToolTag); UF_OBJ_set_name(newToolTag, "D16"); UF_NCGROUP_accept_member(mctRootgroup, newToolTag); //修改刀具的直径 UF_PARAM_set_double_value(newToolTag, UF_PARAM_TL_DIAMETER, 16.0); //获得几何视图下的根节点 tag_t geomRootgroup=NULL_TAG; UF_SETUP_ask_geom_root(setup_tag, &geomRootgroup); //创建加工坐标系几何 tag_t newMcsTag=NULL_TAG; UF_NCGEOM_create("mill_planar", "MCS", &newMcsTag); UF_OBJ_set_name(newMcsTag, "newMcs"); UF_NCGROUP_accept_member(geomRootgroup, newMcsTag); //获得加工方法视图的根节点 tag_t mthdRootgroup=NULL_TAG; UF_SETUP_ask_mthd_root(setup_tag, &mthdRootgroup); //创建操作 tag_t newOperTag=NULL_TAG; UF_OPER_create("mill_planar", "PLANAR_MILL", &newOperTag); //插入操作得到4个组里面 UF_NCGROUP_accept_member(newProgTag, newOperTag); UF_NCGROUP_accept_member(newToolTag, newOperTag); UF_NCGROUP_accept_member(newMcsTag, newOperTag); UF_NCGROUP_accept_member(mthdRootgroup, newOperTag); //刷新加工导航器 UF_UI_ONT_refresh(); UF_terminate(); Caesar卢尚宇 2020年5月12日