#2224 You can now filter models by type when loading

This commit is contained in:
Dion Moult
2022-06-08 11:32:00 +10:00
parent 4681d3198f
commit d0f38bc919
3 changed files with 19 additions and 2 deletions
@@ -545,6 +545,8 @@ class LoadProjectElements(bpy.types.Operator):
settings.elements = self.get_decomposition_elements()
elif self.props.filter_mode == "IFC_CLASS":
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":
settings.elements = self.get_whitelist_elements()
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))
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):
selector = ifcopenshell.util.selector.Selector()
return set(selector.parse(self.file, self.props.filter_query))