NX二次开发-UF函数创建刀具
- 将创建后的刀具放到机床视图的未用项下面,创建之后必须要放到某一个节点之下,不然会报错。
1 tag_t CreateTool(const string& typeName, const string& subtypeName)
2 {
3 tag_t setupTag = NULL_TAG;
4 UF_SETUP_ask_setup(&setupTag);
5 tag_t machineNull = NULL_TAG;
6 UF_SETUP_ask_mct_null(setupTag, &machineNull);
7
8 tag_t tmpTool = NULL_TAG;
9 UF_CUTTER_create(const_cast<char*>(typeName.c_str()), const_cast<char*>(subtypeName.c_str()), &tmpTool);
10 UF_OBJ_set_name(tmpTool, subtypeName.c_str()); //设置刀具的名字
11 logical answer = false;
12 char reason[UF_NCGROUP_MAX_REASON_LEN + 1];
13 UF_NCGROUP_can_accept_member(machineNull, tmpTool, &answer, reason); //判断是否能插入
14 if (answer == true)
15 {
16 UF_NCGROUP_accept_member(machineNull, tmpTool);
17 }
18 else
19 {
20 uc1601("不能接受!", 1);
21 }
22
23 return tmpTool;
24 }