From 4d30be716eecae512efe8f34fa0dba4459bc1db9 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Thu, 16 Jul 2020 11:37:56 +1000 Subject: [PATCH] You can now select all COBie defined assets and types using the selector --- .../ifcopenshell/util/selector.py | 72 ++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/src/ifcopenshell-python/ifcopenshell/util/selector.py b/src/ifcopenshell-python/ifcopenshell/util/selector.py index 3ad3b683ec..19bc307af1 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/selector.py +++ b/src/ifcopenshell-python/ifcopenshell/util/selector.py @@ -5,6 +5,61 @@ import lark class Selector(): def parse(self, ifc_file, query): self.file = ifc_file + self.cobie_type_assets = [ + 'IfcDoorStyle', + 'IfcBuildingElementProxyType', + 'IfcChimneyType', + 'IfcCoveringType', + 'IfcDoorType', + 'IfcFootingType', + 'IfcPileType', + 'IfcRoofType', + 'IfcShadingDeviceType', + 'IfcWindowType', + 'IfcDistributionControlElementType', + 'IfcDistributionChamberElementType', + 'IfcEnergyConversionDeviceType', + 'IfcFlowControllerType', + 'IfcFlowMovingDeviceType', + 'IfcFlowStorageDeviceType', + 'IfcFlowTerminalType', + 'IfcFlowTreatmentDeviceType', + 'IfcElementAssemblyType', + 'IfcBuildingElementPartType', + 'IfcDiscreteAccessoryType', + 'IfcMechanicalFastenerType', + 'IfcReinforcingElementType', + 'IfcVibrationIsolatorType', + 'IfcFurnishingElementType', + 'IfcGeographicElementType', + 'IfcTransportElementType', + 'IfcSpatialZoneType', + 'IfcWindowStyle', + ] + self.cobie_component_assets = [ + 'IfcBuildingElementProxy', + 'IfcChimney', + 'IfcCovering', + 'IfcDoor', + 'IfcShadingDevice', + 'IfcWindow', + 'IfcDistributionControlElement', + 'IfcDistributionChamberElement', + 'IfcEnergyConversionDevice', + 'IfcFlowController', + 'IfcFlowMovingDevice', + 'IfcFlowStorageDevice', + 'IfcFlowTerminal', + 'IfcFlowTreatmentDevice', + 'IfcDiscreteAccessory', + 'IfcTendon', + 'IfcTendonAnchor', + 'IfcVibrationIsolator', + 'IfcFurnishingElement', + 'IfcGeographicElement', + 'IfcTransportElement', + ] + l = lark.Lark('''start: query (lfunction query)* query: selector | group group: "(" query (lfunction query)* ")" @@ -115,7 +170,22 @@ class Selector(): return results def get_class_selector(self, class_selector): - elements = self.file.by_type(class_selector.children[0]) + if class_selector.children[0] == 'COBie': + elements = [] + for ifc_class in self.cobie_component_assets: + try: + elements += self.file.by_type(ifc_class) + except: + pass + elif class_selector.children[0] == 'COBieType': + elements = [] + for ifc_class in self.cobie_type_assets: + try: + elements += self.file.by_type(ifc_class) + except: + pass + else: + elements = self.file.by_type(class_selector.children[0]) if len(class_selector.children) > 1 \ and class_selector.children[1].data == 'filter': return self.filter_elements(elements, class_selector.children[1])