@@ -321,29 +321,35 @@ def execute(self, context):
321321
322322
323323class ToggleFilterSelection (bpy .types .Operator ):
324- "Click to select/deselect all ifctype "
324+ "Click to select/deselect current selection "
325325 bl_idname = "bim.toggle_filter_selection"
326326 bl_label = "Toggle Filter Selection"
327327 action : bpy .props .EnumProperty (items = (("SELECT" , "Select" , "" ), ("DESELECT" , "Deselect" , "" )))
328328
329329 def execute (self , context ):
330+ props = bpy .context .scene .BIMSearchProperties
330331 if self .action == "SELECT" :
331332 self .selecting_actionbool = True
332333 else :
333334 self .selecting_actionbool = False
334- for ifcelement in bpy .context .scene .BIMSearchProperties .filter_classes :
335- ifcelement .is_selected = self .selecting_actionbool
335+ if props .filter_type == "CLASSES" :
336+ for ifc_class in props .filter_classes :
337+ ifc_class .is_selected = self .selecting_actionbool
338+ elif props .filter_type == "BUILDINGSTOREYS" :
339+ for building_storey in props .filter_building_storeys :
340+ building_storey .is_selected = self .selecting_actionbool
336341 return {"FINISHED" }
337342
338343
339- class ActivateIfcTypeFilter (bpy .types .Operator ):
340- "It helps you to filter your selection by IFC class"
341- bl_idname = "bim.activate_ifc_type_filter"
342- bl_label = "Activate IfcType Filter"
344+ class ActivateIfcClassFilter (bpy .types .Operator ):
345+ """Filter the current selection by IFC class"""
343346
344- def invoke ( self , context , event ):
345- bpy . context . scene . BIMSearchProperties . filter_classes . clear ()
347+ bl_idname = "bim.activate_ifc_class_filter"
348+ bl_label = "Filter by Class"
346349
350+ def invoke (self , context , event ):
351+ props = bpy .context .scene .BIMSearchProperties
352+ props .filter_classes .clear ()
347353 ifc_types = {}
348354 for obj in context .selected_objects :
349355 element = tool .Ifc .get_entity (obj )
@@ -353,9 +359,10 @@ def invoke(self, context, event):
353359 ifc_types [element .is_a ()] += 1
354360
355361 for name , total in dict (sorted (ifc_types .items ())).items ():
356- new = context . scene . BIMSearchProperties .filter_classes .add ()
362+ new = props .filter_classes .add ()
357363 new .name = name
358364 new .total = total
365+ props .filter_type = "CLASSES"
359366
360367 return context .window_manager .invoke_props_dialog (self , width = 250 )
361368
@@ -365,7 +372,7 @@ def execute(self, context):
365372
366373 def draw (self , context ):
367374 self .layout .template_list (
368- "BIM_UL_ifctype_filter " ,
375+ "BIM_UL_ifc_class_filter " ,
369376 "" ,
370377 context .scene .BIMSearchProperties ,
371378 "filter_classes" ,
@@ -378,3 +385,51 @@ def draw(self, context):
378385 row = self .layout .row (align = True )
379386 row .operator ("bim.toggle_filter_selection" , text = "Select All" ).action = "SELECT"
380387 row .operator ("bim.toggle_filter_selection" , text = "Deselect All" ).action = "DESELECT"
388+
389+
390+ class ActivateIfcBuildingStoreyFilter (bpy .types .Operator ):
391+ """Filter the current selection by Building Storey"""
392+
393+ bl_idname = "bim.activate_ifc_building_storey_filter"
394+ bl_label = "Filter by Building Storey"
395+
396+ def invoke (self , context , event ):
397+ props = bpy .context .scene .BIMSearchProperties
398+ props .filter_building_storeys .clear ()
399+
400+ ifc_building_storeys = {}
401+ for obj in context .selected_objects :
402+ storey = tool .Misc .get_object_storey (obj )
403+ if not storey :
404+ continue
405+ ifc_building_storeys .setdefault (storey .Name , 0 )
406+ ifc_building_storeys [storey .Name ] += 1
407+
408+ for name , total in dict (sorted (ifc_building_storeys .items ())).items ():
409+ new = props .filter_building_storeys .add ()
410+ new .name = name
411+ new .total = total
412+
413+ props .filter_type = "BUILDINGSTOREYS"
414+
415+ return context .window_manager .invoke_props_dialog (self , width = 250 )
416+
417+ def execute (self , context ):
418+ bpy .context .scene .BIMSearchProperties .filter_building_storeys .clear ()
419+ return {"FINISHED" }
420+
421+ def draw (self , context ):
422+ self .layout .template_list (
423+ "BIM_UL_ifc_building_storey_filter" ,
424+ "" ,
425+ context .scene .BIMSearchProperties ,
426+ "filter_building_storeys" ,
427+ context .scene .BIMSearchProperties ,
428+ "filter_building_storeys_index" ,
429+ rows = 20
430+ if len (bpy .context .scene .BIMSearchProperties .filter_building_storeys ) > 20
431+ else len (bpy .context .scene .BIMSearchProperties .filter_building_storeys ),
432+ )
433+ row = self .layout .row (align = True )
434+ row .operator ("bim.toggle_filter_selection" , text = "Select All" ).action = "SELECT"
435+ row .operator ("bim.toggle_filter_selection" , text = "Deselect All" ).action = "DESELECT"
0 commit comments