mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +00:00
#2224 You can now filter models by type when loading
This commit is contained in:
@@ -545,6 +545,8 @@ class LoadProjectElements(bpy.types.Operator):
|
|||||||
settings.elements = self.get_decomposition_elements()
|
settings.elements = self.get_decomposition_elements()
|
||||||
elif self.props.filter_mode == "IFC_CLASS":
|
elif self.props.filter_mode == "IFC_CLASS":
|
||||||
settings.elements = self.get_ifc_class_elements()
|
settings.elements = self.get_ifc_class_elements()
|
||||||
|
elif self.props.filter_mode == "IFC_TYPE":
|
||||||
|
settings.elements = self.get_ifc_type_elements()
|
||||||
elif self.props.filter_mode == "WHITELIST":
|
elif self.props.filter_mode == "WHITELIST":
|
||||||
settings.elements = self.get_whitelist_elements()
|
settings.elements = self.get_whitelist_elements()
|
||||||
elif self.props.filter_mode == "BLACKLIST":
|
elif self.props.filter_mode == "BLACKLIST":
|
||||||
@@ -595,6 +597,14 @@ class LoadProjectElements(bpy.types.Operator):
|
|||||||
elements.update(self.file.by_type(filter_category.name, include_subtypes=False))
|
elements.update(self.file.by_type(filter_category.name, include_subtypes=False))
|
||||||
return elements
|
return elements
|
||||||
|
|
||||||
|
def get_ifc_type_elements(self):
|
||||||
|
elements = set()
|
||||||
|
for filter_category in self.props.filter_categories:
|
||||||
|
if not filter_category.is_selected:
|
||||||
|
continue
|
||||||
|
elements.update(ifcopenshell.util.element.get_types(self.file.by_id(filter_category.ifc_definition_id)))
|
||||||
|
return elements
|
||||||
|
|
||||||
def get_whitelist_elements(self):
|
def get_whitelist_elements(self):
|
||||||
selector = ifcopenshell.util.selector.Selector()
|
selector = ifcopenshell.util.selector.Selector()
|
||||||
return set(selector.parse(self.file, self.props.filter_query))
|
return set(selector.parse(self.file, self.props.filter_query))
|
||||||
|
|||||||
@@ -63,10 +63,16 @@ def update_filter_mode(self, context):
|
|||||||
new.ifc_definition_id = element.id()
|
new.ifc_definition_id = element.id()
|
||||||
new.total_elements = sum([len(r.RelatedElements) for r in element.ContainsElements])
|
new.total_elements = sum([len(r.RelatedElements) for r in element.ContainsElements])
|
||||||
elif self.filter_mode == "IFC_CLASS":
|
elif self.filter_mode == "IFC_CLASS":
|
||||||
for ifc_class in sorted(list(set([e.is_a() for e in file.by_type("IfcElement")]))):
|
for ifc_class in sorted(list({e.is_a() for e in file.by_type("IfcElement")})):
|
||||||
new = self.filter_categories.add()
|
new = self.filter_categories.add()
|
||||||
new.name = ifc_class
|
new.name = ifc_class
|
||||||
new.total_elements = len(file.by_type(ifc_class, include_subtypes=False))
|
new.total_elements = len(file.by_type(ifc_class, include_subtypes=False))
|
||||||
|
elif self.filter_mode == "IFC_TYPE":
|
||||||
|
for ifc_type in sorted(file.by_type("IfcElementType"), key=lambda e: e.Name or "Unnamed"):
|
||||||
|
new = self.filter_categories.add()
|
||||||
|
new.name = ifc_type.is_a() + "/" + (ifc_type.Name or "Unnamed")
|
||||||
|
new.ifc_definition_id = ifc_type.id()
|
||||||
|
new.total_elements = len(ifcopenshell.util.element.get_types(ifc_type))
|
||||||
|
|
||||||
|
|
||||||
class LibraryElement(PropertyGroup):
|
class LibraryElement(PropertyGroup):
|
||||||
@@ -117,6 +123,7 @@ class BIMProjectProperties(PropertyGroup):
|
|||||||
("NONE", "None", "No filtering is performed"),
|
("NONE", "None", "No filtering is performed"),
|
||||||
("DECOMPOSITION", "Decomposition", "Filter objects by decomposition"),
|
("DECOMPOSITION", "Decomposition", "Filter objects by decomposition"),
|
||||||
("IFC_CLASS", "IFC Class", "Filter objects by class"),
|
("IFC_CLASS", "IFC Class", "Filter objects by class"),
|
||||||
|
("IFC_TYPE", "IFC Type", "Filter objects by type"),
|
||||||
("WHITELIST", "Whitelist", "Filter objects using a custom whitelist query"),
|
("WHITELIST", "Whitelist", "Filter objects using a custom whitelist query"),
|
||||||
("BLACKLIST", "Blacklist", "Filter objects using a custom blacklist query"),
|
("BLACKLIST", "Blacklist", "Filter objects using a custom blacklist query"),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class BIM_PT_project(Panel):
|
|||||||
row.prop(pprops, "collection_mode")
|
row.prop(pprops, "collection_mode")
|
||||||
row = self.layout.row()
|
row = self.layout.row()
|
||||||
row.prop(pprops, "filter_mode")
|
row.prop(pprops, "filter_mode")
|
||||||
if pprops.filter_mode in ["DECOMPOSITION", "IFC_CLASS"]:
|
if pprops.filter_mode in ["DECOMPOSITION", "IFC_CLASS", "IFC_TYPE"]:
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.alignment = "RIGHT"
|
row.alignment = "RIGHT"
|
||||||
row.operator("bim.toggle_filter_categories", text="", icon="CHECKBOX_HLT").should_select = True
|
row.operator("bim.toggle_filter_categories", text="", icon="CHECKBOX_HLT").should_select = True
|
||||||
|
|||||||
Reference in New Issue
Block a user