NX二次开发-获取NX自带的所有模板的类型和子类型字符串名字
1 void NXCommon::GetTemplateTypeAndSubtypeName() 2 { 3 int typeCount = 0; 4 const char** typeNames = NULL; 5 char msg[256], msg1[256]; 6 UF_CAM_opt_ask_types(&typeCount, &typeNames); 7 UF_UI_open_listing_window(); 8 for (int i = 0; i < typeCount; ++i) 9 { 10 int subtypeCount = 0; 11 const char** subtypeNames = NULL; 12 //此处UF_CAM_OPT_STYPE_CLS_TOOL为获取模板中刀具的子类型名字,也可获取模板中程序组等的子类型名字,修改UF_CAM_opt_ask_subtypes函数第二个参数即可 13 UF_CAM_opt_ask_subtypes(typeNames[i], UF_CAM_OPT_STYPE_CLS_TOOL, &subtypeCount, &subtypeNames); 14 for (int j = 0; j < subtypeCount; ++j) 15 { 16 sprintf_s(msg, "类型:%s, 子类型:%s\n", typeNames[i], subtypeNames[j]); 17 UF_UI_write_listing_window(msg); 18 } 19 20 UF_free_string_array(subtypeCount, (char **)subtypeNames); 21 } 22 23 UF_free_string_array(typeCount, (char **)typeNames); 24 }