From 33078844e6722ee5ae877096f67a702545fd1afc Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Sun, 27 Jan 2019 18:30:20 +1100 Subject: [PATCH] Load JSON based on ifcopenshell schema version This allows us to support more than one ifc version. The 2X3 jsons cannot be autogenerated and have been manually written based on the hardcoded values in the old codebase. --- src/Mod/Arch/ArchComponent.py | 8 +- src/Mod/Arch/Presets/ifc_products_IFC2X3.json | 163 ++++++++++++++++++ ...c_products.json => ifc_products_IFC4.json} | 0 src/Mod/Arch/Presets/ifc_types_IFC2X3.json | 31 ++++ .../{ifc_types.json => ifc_types_IFC4.json} | 0 5 files changed, 199 insertions(+), 3 deletions(-) create mode 100644 src/Mod/Arch/Presets/ifc_products_IFC2X3.json rename src/Mod/Arch/Presets/{ifc_products.json => ifc_products_IFC4.json} (100%) create mode 100644 src/Mod/Arch/Presets/ifc_types_IFC2X3.json rename src/Mod/Arch/Presets/{ifc_types.json => ifc_types_IFC4.json} (100%) diff --git a/src/Mod/Arch/ArchComponent.py b/src/Mod/Arch/ArchComponent.py index ce8d27d5a7..9f895c8e20 100644 --- a/src/Mod/Arch/ArchComponent.py +++ b/src/Mod/Arch/ArchComponent.py @@ -25,7 +25,7 @@ __title__="FreeCAD Arch Component" __author__ = "Yorik van Havre" __url__ = "http://www.freecadweb.org" -import FreeCAD,Draft,ArchCommands,math,sys,json,os +import FreeCAD,Draft,ArchCommands,math,sys,json,os,ifcopenshell from FreeCAD import Vector if FreeCAD.GuiUp: import FreeCADGui @@ -47,10 +47,12 @@ else: # This module provides the base Arch component class, that # is shared by all of the Arch BIM objects -with open(os.path.join(FreeCAD.getResourceDir(),"Mod","Arch","Presets","ifc_products.json")) as f: +with open(os.path.join(FreeCAD.getResourceDir(), "Mod", "Arch", "Presets", + "ifc_products_" + ifcopenshell.schema_identifier + ".json")) as f: ifcProducts = json.load(f) -with open(os.path.join(FreeCAD.getResourceDir(),"Mod","Arch","Presets","ifc_types.json")) as f: +with open(os.path.join(FreeCAD.getResourceDir(), "Mod", "Arch", "Presets", + "ifc_types_" + ifcopenshell.schema_identifier + ".json")) as f: ifcTypes = json.load(f) # Possible roles for FreeCAD BIM objects diff --git a/src/Mod/Arch/Presets/ifc_products_IFC2X3.json b/src/Mod/Arch/Presets/ifc_products_IFC2X3.json new file mode 100644 index 0000000000..915389672f --- /dev/null +++ b/src/Mod/Arch/Presets/ifc_products_IFC2X3.json @@ -0,0 +1,163 @@ +{ +"IfcActuator": { "attributes": [] }, +"IfcAirTerminal": { "attributes": [] }, +"IfcAirTerminalBox": { "attributes": [] }, +"IfcAirToAirHeatRecovery": { "attributes": [] }, +"IfcAlarm": { "attributes": [] }, +"IfcAnnotation": { "attributes": [] }, +"IfcAudioVisualAppliance": { "attributes": [] }, +"IfcBeam": { "attributes": [] }, +"IfcBeamStandardCase": { "attributes": [] }, +"IfcBoiler": { "attributes": [] }, +"IfcBuilding": { "attributes": [] }, +"IfcBuildingElement": { "attributes": [] }, +"IfcBuildingElementPart": { "attributes": [] }, +"IfcBuildingElementProxy": { "attributes": [] }, +"IfcBuildingStorey": { "attributes": [] }, +"IfcBurner": { "attributes": [] }, +"IfcCableCarrierFitting": { "attributes": [] }, +"IfcCableCarrierSegment": { "attributes": [] }, +"IfcCableFitting": { "attributes": [] }, +"IfcCableSegment": { "attributes": [] }, +"IfcChiller": { "attributes": [] }, +"IfcChimney": { "attributes": [] }, +"IfcCivilElement": { "attributes": [] }, +"IfcCoil": { "attributes": [] }, +"IfcColumn": { "attributes": [] }, +"IfcColumnStandardCase": { "attributes": [] }, +"IfcCommunicationsAppliance": { "attributes": [] }, +"IfcCompressor": { "attributes": [] }, +"IfcCondenser": { "attributes": [] }, +"IfcController": { "attributes": [] }, +"IfcCooledBeam": { "attributes": [] }, +"IfcCoolingTower": { "attributes": [] }, +"IfcCovering": { "attributes": [] }, +"IfcCurtainWall": { "attributes": [] }, +"IfcDamper": { "attributes": [] }, +"IfcDiscreteAccessory": { "attributes": [] }, +"IfcDistributionChamberElement": { "attributes": [] }, +"IfcDistributionControlElement": { "attributes": [] }, +"IfcDistributionElement": { "attributes": [] }, +"IfcDistributionFlowElement": { "attributes": [] }, +"IfcDistributionPort": { "attributes": [] }, +"IfcDoor": { "attributes": [] }, +"IfcDoorStandardCase": { "attributes": [] }, +"IfcDuctFitting": { "attributes": [] }, +"IfcDuctSegment": { "attributes": [] }, +"IfcDuctSilencer": { "attributes": [] }, +"IfcElectricAppliance": { "attributes": [] }, +"IfcElectricDistributionBoard": { "attributes": [] }, +"IfcElectricFlowStorageDevice": { "attributes": [] }, +"IfcElectricGenerator": { "attributes": [] }, +"IfcElectricMotor": { "attributes": [] }, +"IfcElectricTimeControl": { "attributes": [] }, +"IfcElementAssembly": { "attributes": [] }, +"IfcElementComponent": { "attributes": [] }, +"IfcEnergyConversionDevice": { "attributes": [] }, +"IfcEngine": { "attributes": [] }, +"IfcEvaporativeCooler": { "attributes": [] }, +"IfcEvaporator": { "attributes": [] }, +"IfcExternalSpatialElement": { "attributes": [] }, +"IfcExternalSpatialStructureElement": { "attributes": [] }, +"IfcFan": { "attributes": [] }, +"IfcFastener": { "attributes": [] }, +"IfcFeatureElement": { "attributes": [] }, +"IfcFeatureElementAddition": { "attributes": [] }, +"IfcFeatureElementSubtraction": { "attributes": [] }, +"IfcFilter": { "attributes": [] }, +"IfcFireSuppressionTerminal": { "attributes": [] }, +"IfcFlowController": { "attributes": [] }, +"IfcFlowFitting": { "attributes": [] }, +"IfcFlowInstrument": { "attributes": [] }, +"IfcFlowMeter": { "attributes": [] }, +"IfcFlowMovingDevice": { "attributes": [] }, +"IfcFlowSegment": { "attributes": [] }, +"IfcFlowStorageDevice": { "attributes": [] }, +"IfcFlowTerminal": { "attributes": [] }, +"IfcFlowTreatmentDevice": { "attributes": [] }, +"IfcFooting": { "attributes": [] }, +"IfcFurnishingElement": { "attributes": [] }, +"IfcFurniture": { "attributes": [] }, +"IfcGeographicElement": { "attributes": [] }, +"IfcGrid": { "attributes": [] }, +"IfcHeatExchanger": { "attributes": [] }, +"IfcHumidifier": { "attributes": [] }, +"IfcInterceptor": { "attributes": [] }, +"IfcJunctionBox": { "attributes": [] }, +"IfcLamp": { "attributes": [] }, +"IfcLightFixture": { "attributes": [] }, +"IfcMechanicalFastener": { "attributes": [] }, +"IfcMedicalDevice": { "attributes": [] }, +"IfcMember": { "attributes": [] }, +"IfcMemberStandardCase": { "attributes": [] }, +"IfcMotorConnection": { "attributes": [] }, +"IfcOpeningElement": { "attributes": [] }, +"IfcOpeningStandardCase": { "attributes": [] }, +"IfcOutlet": { "attributes": [] }, +"IfcPile": { "attributes": [] }, +"IfcPipeFitting": { "attributes": [] }, +"IfcPipeSegment": { "attributes": [] }, +"IfcPlate": { "attributes": [] }, +"IfcPlateStandardCase": { "attributes": [] }, +"IfcProjectionElement": { "attributes": [] }, +"IfcProtectiveDevice": { "attributes": [] }, +"IfcProtectiveDeviceTrippingUnit": { "attributes": [] }, +"IfcProxy": { "attributes": [] }, +"IfcPump": { "attributes": [] }, +"IfcRailing": { "attributes": [] }, +"IfcRamp": { "attributes": [] }, +"IfcRampFlight": { "attributes": [] }, +"IfcReinforcingBar": { "attributes": [] }, +"IfcReinforcingMesh": { "attributes": [] }, +"IfcRoof": { "attributes": [] }, +"IfcSanitaryTerminal": { "attributes": [] }, +"IfcSensor": { "attributes": [] }, +"IfcShadingDevice": { "attributes": [] }, +"IfcSite": { "attributes": [] }, +"IfcSlab": { "attributes": [] }, +"IfcSlabElementedCase": { "attributes": [] }, +"IfcSlabStandardCase": { "attributes": [] }, +"IfcSolarDevice": { "attributes": [] }, +"IfcSpace": { "attributes": [] }, +"IfcSpaceHeater": { "attributes": [] }, +"IfcSpatialZone": { "attributes": [] }, +"IfcStackTerminal": { "attributes": [] }, +"IfcStair": { "attributes": [] }, +"IfcStairFlight": { "attributes": [] }, +"IfcStructuralCurveAction": { "attributes": [] }, +"IfcStructuralCurveConnection": { "attributes": [] }, +"IfcStructuralCurveMember": { "attributes": [] }, +"IfcStructuralCurveMemberVarying": { "attributes": [] }, +"IfcStructuralCurveReaction": { "attributes": [] }, +"IfcStructuralLinearAction": { "attributes": [] }, +"IfcStructuralPlanarAction": { "attributes": [] }, +"IfcStructuralPointAction": { "attributes": [] }, +"IfcStructuralPointConnection": { "attributes": [] }, +"IfcStructuralPointReaction": { "attributes": [] }, +"IfcStructuralSurfaceAction": { "attributes": [] }, +"IfcStructuralSurfaceConnection": { "attributes": [] }, +"IfcStructuralSurfaceMember": { "attributes": [] }, +"IfcStructuralSurfaceMemberVarying": { "attributes": [] }, +"IfcStructuralSurfaceReaction": { "attributes": [] }, +"IfcSurfaceFeature": { "attributes": [] }, +"IfcSwitchingDevice": { "attributes": [] }, +"IfcSystemFurnitureElement": { "attributes": [] }, +"IfcTank": { "attributes": [] }, +"IfcTendon": { "attributes": [] }, +"IfcTendonAnchor": { "attributes": [] }, +"IfcTransformer": { "attributes": [] }, +"IfcTransportElement": { "attributes": [] }, +"IfcTubeBundle": { "attributes": [] }, +"IfcUnitaryControlElement": { "attributes": [] }, +"IfcUnitaryEquipment": { "attributes": [] }, +"IfcValve": { "attributes": [] }, +"IfcVibrationIsolator": { "attributes": [] }, +"IfcVirtualElement": { "attributes": [] }, +"IfcVoidingFeature": { "attributes": [] }, +"IfcWall": { "attributes": [] }, +"IfcWallElementedCase": { "attributes": [] }, +"IfcWallStandardCase": { "attributes": [] }, +"IfcWasteTerminal": { "attributes": [] }, +"IfcWindow": { "attributes": [] }, +"IfcWindowStandardCase": { "attributes": [] } +} diff --git a/src/Mod/Arch/Presets/ifc_products.json b/src/Mod/Arch/Presets/ifc_products_IFC4.json similarity index 100% rename from src/Mod/Arch/Presets/ifc_products.json rename to src/Mod/Arch/Presets/ifc_products_IFC4.json diff --git a/src/Mod/Arch/Presets/ifc_types_IFC2X3.json b/src/Mod/Arch/Presets/ifc_types_IFC2X3.json new file mode 100644 index 0000000000..dc13d74bff --- /dev/null +++ b/src/Mod/Arch/Presets/ifc_types_IFC2X3.json @@ -0,0 +1,31 @@ +{ +"IfcInteger": {}, +"IfcReal": {}, +"IfcBoolean": {}, +"IfcIdentifier": {}, +"IfcText": {}, +"IfcLabel": {}, +"IfcLogical": {}, +"IfcVolumeMeasure": {}, +"IfcTimeMeasure": {}, +"IfcThermodynamicTemperatureMeasure": {}, +"IfcSolidAngleMeasure": {}, +"IfcPositiveRatioMeasure": {}, +"IfcRatioMeasure": {}, +"IfcPositivePlaneAngleMeasure": {}, +"IfcPlaneAngleMeasure": {}, +"IfcParameterValue": {}, +"IfcNumericMeasure": {}, +"IfcMassMeasure": {}, +"IfcPositiveLengthMeasure": {}, +"IfcLengthMeasure": {}, +"IfcElectricCurrentMeasure": {}, +"IfcDescriptiveMeasure": {}, +"IfcCountMeasure": {}, +"IfcContextDependentMeasure": {}, +"IfcAreaMeasure": {}, +"IfcAmountOfSubstanceMeasure": {}, +"IfcLuminousIntensityMeasure": {}, +"IfcNormalisedRatioMeasure": {}, +"IfcComplexNumber": {} +} diff --git a/src/Mod/Arch/Presets/ifc_types.json b/src/Mod/Arch/Presets/ifc_types_IFC4.json similarity index 100% rename from src/Mod/Arch/Presets/ifc_types.json rename to src/Mod/Arch/Presets/ifc_types_IFC4.json