mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 06:58:56 +00:00
You can now filter spatial containers by name, long name, or class
This commit is contained in:
@@ -115,6 +115,7 @@ class Element(PropertyGroup):
|
|||||||
|
|
||||||
|
|
||||||
class BIMSpatialDecompositionProperties(PropertyGroup):
|
class BIMSpatialDecompositionProperties(PropertyGroup):
|
||||||
|
container_filter: StringProperty(name="Container Filter", default="", options={"TEXTEDIT_UPDATE"})
|
||||||
containers: CollectionProperty(name="Containers", type=BIMContainer)
|
containers: CollectionProperty(name="Containers", type=BIMContainer)
|
||||||
contracted_containers: StringProperty(name="Contracted containers", default="[]")
|
contracted_containers: StringProperty(name="Contracted containers", default="[]")
|
||||||
expanded_containers: StringProperty(name="Expanded containers", default="[]")
|
expanded_containers: StringProperty(name="Expanded containers", default="[]")
|
||||||
|
|||||||
@@ -184,6 +184,9 @@ class BIM_PT_spatial_decomposition(Panel):
|
|||||||
|
|
||||||
|
|
||||||
class BIM_UL_containers_manager(UIList):
|
class BIM_UL_containers_manager(UIList):
|
||||||
|
def __init__(self):
|
||||||
|
self.use_filter_show = True
|
||||||
|
|
||||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||||
if item:
|
if item:
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
@@ -214,16 +217,42 @@ class BIM_UL_containers_manager(UIList):
|
|||||||
row.label(text="", icon="BLANK1")
|
row.label(text="", icon="BLANK1")
|
||||||
if item.has_children:
|
if item.has_children:
|
||||||
if item.is_expanded:
|
if item.is_expanded:
|
||||||
row.operator("bim.contract_container", text="", emboss=False, icon="DISCLOSURE_TRI_DOWN").container = (
|
row.operator(
|
||||||
item.ifc_definition_id
|
"bim.contract_container", text="", emboss=False, icon="DISCLOSURE_TRI_DOWN"
|
||||||
)
|
).container = item.ifc_definition_id
|
||||||
else:
|
else:
|
||||||
row.operator("bim.expand_container", text="", emboss=False, icon="DISCLOSURE_TRI_RIGHT").container = (
|
row.operator(
|
||||||
item.ifc_definition_id
|
"bim.expand_container", text="", emboss=False, icon="DISCLOSURE_TRI_RIGHT"
|
||||||
)
|
).container = item.ifc_definition_id
|
||||||
else:
|
else:
|
||||||
row.label(text="", icon="BLANK1")
|
row.label(text="", icon="BLANK1")
|
||||||
|
|
||||||
|
def draw_filter(self, context, layout):
|
||||||
|
row = layout.row()
|
||||||
|
row.prop(context.scene.BIMSpatialDecompositionProperties, "container_filter", text="", icon="VIEWZOOM")
|
||||||
|
|
||||||
|
def filter_items(self, context, data, propname):
|
||||||
|
items = getattr(data, propname)
|
||||||
|
filter_name = context.scene.BIMSpatialDecompositionProperties.container_filter.lower()
|
||||||
|
filter_flags = [self.bitflag_filter_item] * len(items)
|
||||||
|
|
||||||
|
for idx, item in enumerate(items):
|
||||||
|
if (
|
||||||
|
filter_name in item.name.lower()
|
||||||
|
or filter_name in item.long_name.lower()
|
||||||
|
or filter_name in item.ifc_class.lower()
|
||||||
|
):
|
||||||
|
filter_flags[idx] |= self.bitflag_filter_item
|
||||||
|
else:
|
||||||
|
filter_flags[idx] &= ~self.bitflag_filter_item
|
||||||
|
|
||||||
|
return filter_flags, []
|
||||||
|
|
||||||
|
items = getattr(data, propname)
|
||||||
|
filter_name = context.scene.BIMSpatialDecompositionProperties.container_filter
|
||||||
|
filtered = bpy.types.UI_UL_list.filter_items_by_name(filter_name, self.bitflag_filter_item, items, "name")
|
||||||
|
return filtered, []
|
||||||
|
|
||||||
|
|
||||||
class BIM_UL_elements(UIList):
|
class BIM_UL_elements(UIList):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user