1 double XX = expression0->Value(); 2 double YY = expression01->Value(); 3 double ZZ = expression02->Value(); 4 5 UF_initialize(); 6 tag_t ObjectTag = NULL_TAG; 7 int Type, SubType, pp = 0; 8 UF_OBJ_cycle_objs_in_part(UF_PART_ask_display_part(), UF_solid_type, &ObjectTag); 9 UF_LAYER_set_status(1, 1); 10 while (ObjectTag != NULL_TAG) 11 { 12 UF_OBJ_set_blank_status(ObjectTag, UF_OBJ_BLANKED); 13 UF_OBJ_ask_type_and_subtype(ObjectTag, &Type, &SubType); 14 if (SubType == UF_solid_body_subtype) 15 { 16 //测量 17 double min_corner[3] = { 0,0,0 }; 18 double directions[3][3]; 19 double distances[3] = { 0,0,0 }; 20 UF_MODL_ask_bounding_box_exact( 21 ObjectTag, //输入实体 22 NULL_TAG, //输入坐标 【NULL_TAG=默认工作坐标】 23 min_corner, //输出 x,y,z 最小值【最小坐标】 24 directions, //输出 边界框的方向向量 25 distances); //输出 大小 26 if ( distances[0] <= XX + 0.1&&distances[0] >= XX - 0.1 && distances[1] <= YY + 0.1&&distances[1] >= YY - 0.1 && distances[2] <= ZZ + 0.1&&distances[2] >= ZZ - 0.1 || 27 distances[0] <= YY + 0.1&&distances[0] >= YY - 0.1 && distances[1] <= ZZ + 0.1&&distances[1] >= ZZ - 0.1 && distances[2] <= XX + 0.1&&distances[2] >= XX - 0.1 || 28 distances[0] <= ZZ + 0.1&&distances[0] >= ZZ - 0.1 && distances[1] <= XX + 0.1&&distances[1] >= XX - 0.1 && distances[2] <= YY + 0.1&&distances[2] >= YY - 0.1 || 29 distances[0] <= ZZ + 0.1&&distances[0] >= ZZ - 0.1 && distances[1] <= YY + 0.1&&distances[1] >= YY - 0.1 && distances[2] <= XX + 0.1&&distances[2] >= XX - 0.1 || 30 distances[0] <= XX + 0.1&&distances[0] >= XX - 0.1 && distances[1] <= ZZ + 0.1&&distances[1] >= ZZ - 0.1 && distances[2] <= YY + 0.1&&distances[2] >= YY - 0.1 || 31 distances[0] <= YY + 0.1&&distances[0] >= YY - 0.1 && distances[1] <= XX + 0.1&&distances[1] >= XX - 0.1 && distances[2] <= ZZ + 0.1&&distances[2] >= ZZ - 0.1 32 ) 33 { 34 UF_OBJ_set_blank_status(ObjectTag, UF_OBJ_NOT_BLANKED); 35 pp++; 36 } 37 } 38 UF_OBJ_cycle_objs_in_part(UF_PART_ask_display_part(), UF_solid_type, &ObjectTag); 39 } 40 if (pp) 41 { 42 char msg[256]; 43 sprintf(msg, "找到%d个体!", pp); 44 uc1601(msg, 1); 45 } 46 else 47 { 48 uc1601("没有找到!", 1); 49 } 50 UF_terminate();
1 #include <uf.h> 2 #include <uf_ui.h> 3 #include <uf_obj.h> 4 #include <uf_modl_primitives.h> 5 #include <uf_csys.h> 6 #include <uf_layer.h> 7 #include <uf_object_types.h> 8 #include <uf_modl_utilities.h> 9 #include <uf_part.h> 10 #include <uf_modl.h> 11 #include <uf_group.h> 12 #include <uf_ui.h> 13 #include <uf_layer.h> 14 #include <uf_obj.h> 15 #include <uf_object_types.h> 16 #include <uf_defs.h>