You can now select all COBie defined assets and types using the selector

This commit is contained in:
Dion Moult
2020-07-16 11:37:56 +10:00
parent e3de339ab2
commit 4d30be716e
@@ -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])