From f0e03c79df4fe2ee4d4a778bc0402258871426b9 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Fri, 15 Sep 2023 11:24:57 +1000 Subject: [PATCH] Project advanced mode filtering now uses new filter syntax --- src/blenderbim/blenderbim/bim/import_ifc.py | 13 ------------ .../blenderbim/bim/module/project/operator.py | 21 ++++++++++++------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/import_ifc.py b/src/blenderbim/blenderbim/bim/import_ifc.py index f235f652d0..ecfff3bcf0 100644 --- a/src/blenderbim/blenderbim/bim/import_ifc.py +++ b/src/blenderbim/blenderbim/bim/import_ifc.py @@ -21,9 +21,7 @@ import re import bpy import time import bmesh -import shutil import logging -import threading import mathutils import numpy as np import multiprocessing @@ -31,7 +29,6 @@ import ifcopenshell import ifcopenshell.geom import ifcopenshell.util.unit import ifcopenshell.util.element -import ifcopenshell.util.selector import ifcopenshell.util.geolocation import blenderbim.tool as tool from itertools import chain, accumulate @@ -39,16 +36,6 @@ from blenderbim.bim.ifc import IfcStore from blenderbim.bim.module.drawing.prop import ANNOTATION_TYPES_DATA -class FileCopy(threading.Thread): - def __init__(self, file_path, destination): - threading.Thread.__init__(self) - self.file_path = file_path - self.destination = destination - - def run(self): - shutil.copy(self.file_path, self.destination) - - class MaterialCreator: def __init__(self, ifc_import_settings, ifc_importer): self.mesh = None diff --git a/src/blenderbim/blenderbim/bim/module/project/operator.py b/src/blenderbim/blenderbim/bim/module/project/operator.py index 0ee0ac2d58..ec431b80bb 100644 --- a/src/blenderbim/blenderbim/bim/module/project/operator.py +++ b/src/blenderbim/blenderbim/bim/module/project/operator.py @@ -355,8 +355,8 @@ class AppendEntireLibrary(bpy.types.Operator): self.file = IfcStore.get_file() self.library = IfcStore.library_file - lib_elements = ifcopenshell.util.selector.Selector().parse( - self.library, ".IfcTypeProduct | .IfcMaterial | .IfcCostSchedule| .IfcProfileDef" + lib_elements = ifcopenshell.util.selector.filter_elements( + self.library, "IfcTypeProduct, IfcMaterial, IfcCostSchedule, IfcProfileDef" ) for element in lib_elements: bpy.ops.bim.append_library_element(definition=element.id()) @@ -768,12 +768,12 @@ class LoadProjectElements(bpy.types.Operator): return elements def get_whitelist_elements(self): - selector = ifcopenshell.util.selector.Selector() - return set(selector.parse(self.file, self.props.filter_query)) + return set(ifcopenshell.util.selector.filter_elements(self.file, self.props.filter_query)) def get_blacklist_elements(self): - selector = ifcopenshell.util.selector.Selector() - return set(self.file.by_type("IfcElement")) - set(selector.parse(self.file, self.props.filter_query)) + return set(self.file.by_type("IfcElement")) - set( + ifcopenshell.util.selector.filter_elements(self.file, self.props.filter_query) + ) class ToggleFilterCategories(bpy.types.Operator): @@ -895,6 +895,7 @@ class ReloadLink(bpy.types.Operator): for c in bpy.data.collections if "IfcProject" in c.name and c.library and os.path.basename(c.library.filepath) == selected_filename ] + for library in get_linked_ifcs() or []: library.reload() return {"FINISHED"} @@ -920,7 +921,9 @@ class ToggleLinkSelectability(bpy.types.Operator): def get_linked_collections(self): return [ - c for c in bpy.data.collections if "IfcProject" in c.name and c.library and c.library.filepath == self.filepath + c + for c in bpy.data.collections + if "IfcProject" in c.name and c.library and c.library.filepath == self.filepath ] @@ -974,7 +977,9 @@ class ToggleLinkVisibility(bpy.types.Operator): def get_linked_collections(self): return [ - c for c in bpy.data.collections if "IfcProject" in c.name and c.library and c.library.filepath == self.filepath + c + for c in bpy.data.collections + if "IfcProject" in c.name and c.library and c.library.filepath == self.filepath ]