diff --git a/src/ifcopenshell-python/ifcopenshell/util/brick.py b/src/ifcopenshell-python/ifcopenshell/util/brick.py new file mode 100644 index 0000000000..0516abc737 --- /dev/null +++ b/src/ifcopenshell-python/ifcopenshell/util/brick.py @@ -0,0 +1,20 @@ +import os +import json + + +cwd = os.path.dirname(os.path.realpath(__file__)) + +ifc4_to_brick_map = {} + +with open(os.path.join(cwd, "ifc4_to_brick.json")) as f: + ifc4_to_brick_map = json.load(f) + + +def get_brick_type(element): + predefined_type = getattr(element, "PredefinedType", None) + result = None + if predefined_type: + result = ifc4_to_brick_map.get(f"{element.is_a()}.{predefined_type}", None) + if not result: + result = ifc4_to_brick_map.get(element.is_a(), None) + return result diff --git a/src/ifcopenshell-python/ifcopenshell/util/ifc4_to_brick.json b/src/ifcopenshell-python/ifcopenshell/util/ifc4_to_brick.json new file mode 100644 index 0000000000..5c07e00bf7 --- /dev/null +++ b/src/ifcopenshell-python/ifcopenshell/util/ifc4_to_brick.json @@ -0,0 +1,36 @@ +{ + "IfcAudioVisualAppliance.CAMERA": "Camera", + "IfcUnitaryEquipment.AIRHANDLER": "AHU", + "IfcBoiler": "Boiler", + "IfcUnitaryEquipment.AIRCONDITIONINGUNIT": "CRAC", + "IfcChiller": "Chiller", + "IfcCompressor": "Compressor", + "IfcCondenser": "Condenser", + "IfcCoolingTower": "Cooling_Tower", + "IfcDamper": "Damper", + "IfcFan": "Fan", + "IfcFilter": "Filter", + "IfcHeatExchanger": "Heat_Exchanger", + "IfcHumidifier": "Humidifier", + "IfcPump": "Pump", + "IfcAirTerminalBox": "TerminalUnit", + "IfcAirTerminalBox.CONSTANTFLOW": "CAV", + "IfcAirTerminalBox.VARIABLEFLOWPRESSUREDEPENDANT": "VAV", + "IfcAirTerminalBox.VARIABLEFLOWPRESSUREINDEPENDANT": "VAV", + "IfcValve": "Valve", + "IfcUnitaryControlElement.THERMOSTAT": "Thermostat", + "IfcUnitaryControlElement.WEATHERSTATION": "Weather_Station", + "IfcLightFixture": "Luminaire", + "IfcFlowMeter": "Meter", + "IfcFlowMeter.ENERGYMETER": "Electric_Meter", + "IfcFlowMeter.GASMETER": "Gas_Meter", + "IfcFlowMeter.WATERMETER": "Water_Meter", + "IfcElectricMotor": "Motor", + "IfcSolarDevice.SOLARPANEL": "PV_Panel", + "IfcBuilding": "Building", + "IfcBuildingStorey": "Floor", + "IfcSpace": "Space", + "IfcSpatialZone": "Zone", + "IfcSpatialZone.THERMAL": "HVAC_Zone", + "IfcSpatialZone.LIGHTING": "Lighting_Zone" +} diff --git a/src/ifcopenshell-python/test/util/test_brick.py b/src/ifcopenshell-python/test/util/test_brick.py new file mode 100644 index 0000000000..5c4e8f010c --- /dev/null +++ b/src/ifcopenshell-python/test/util/test_brick.py @@ -0,0 +1,11 @@ +import pytest +import test.bootstrap +import ifcopenshell.util.brick as subject + + +class TestGetBrickTypeIFC4(test.bootstrap.IFC4): + def test_run(self): + element = self.file.createIfcAirTerminalBox() + assert subject.get_brick_type(element) == "TerminalUnit" + element.PredefinedType = "CONSTANTFLOW" + assert subject.get_brick_type(element) == "CAV"