1 NX11+VS2013 2 3 #include <uf.h> 4 #include <uf_modl.h> 5 #include <uf_part.h> 6 #include <uf_obj.h> 7 8 9 UF_initialize(); 10 11 //遍历当前part所有body 12 lw->Open(); 13 int type, subtype, body_type = 0; 14 tag_t BodyTag = NULL_TAG; 15 UF_OBJ_cycle_objs_in_part(UF_PART_ask_display_part(), UF_solid_type, &BodyTag); 16 while (BodyTag != NULL_TAG) 17 { 18 //获的显示的体 19 UF_OBJ_disp_props_t Bodydisp_props; 20 UF_OBJ_ask_display_properties(BodyTag, &Bodydisp_props); 21 int BodyBlank = Bodydisp_props.blank_status; 22 if (BodyBlank == UF_OBJ_NOT_BLANKED) 23 { 24 //获取子类型 25 UF_OBJ_ask_type_and_subtype(BodyTag, &type, &subtype); 26 if (subtype == UF_solid_body_subtype) 27 { 28 //判断实体还是片体 29 UF_MODL_ask_body_type(BodyTag, &body_type); 30 if (body_type == UF_MODL_SOLID_BODY) 31 { 32 //由体获得part的tag 33 tag_t part_tag = NULL_TAG; 34 UF_OBJ_ask_owning_part(BodyTag, &part_tag); 35 36 //获取part的名字 37 char part_fspec[MAX_FSPEC_BUFSIZE]; 38 UF_PART_ask_part_name(part_tag, part_fspec); 39 lw->WriteLine(part_fspec); 40 41 } 42 } 43 } 44 45 UF_OBJ_cycle_objs_in_part(UF_PART_ask_display_part(), UF_solid_type, &BodyTag); 46 } 47 48 UF_terminate();