NX11+VS2013 #include <uf.h> #include <uf_assem.h> #include <uf_obj.h> #include <uf_ui.h> static int select_filter_proc_fn(tag_t object, int type[3], void* user_data, UF_UI_selection_p_t select) { if (object == NULL) { return UF_UI_SEL_REJECT; } else { return UF_UI_SEL_ACCEPT; } } static int init_proc(UF_UI_selection_p_t select, void* user_data) { int num_triples = 1;//可选类型的数量 UF_UI_mask_t mask_triples[] = { UF_component_type, UF_component_subtype, 0//过滤器为组件 };//可选对象类型 UF_UI_set_sel_mask(select, UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC, num_triples, mask_triples); if ((UF_UI_set_sel_procs(select, select_filter_proc_fn, NULL, user_data)) == 0) { return UF_UI_SEL_SUCCESS; } else { return UF_UI_SEL_FAILURE; } } UF_initialize(); //单对象选择对话框 char sCue[] = "单对象选择对话框"; char sTitle[] = "单对象选择对话框"; int iScope = UF_UI_SEL_SCOPE_NO_CHANGE; int iResponse; tag_t tObject; tag_t tView; double adCursor[3]; UF_UI_select_with_single_dialog(sCue, sTitle, iScope, init_proc, NULL, &iResponse, &tObject, adCursor, &tView); //获取某个部件或对象事例的父部件或对象事例(PartOcc) tag_t PartOccTag = UF_ASSEM_ask_part_occurrence(tObject);//传入组件的tag //partocc转instance tag_t instanceTag = UF_ASSEM_ask_inst_of_part_occ(PartOccTag); //组件抑制 tag_t instances[] = { instanceTag }; int failures[] = { 0 }; UF_ASSEM_suppress_instances(1, instances, failures); UF_terminate(); Caesar卢尚宇 2020年10月8日