Merge branch 'fix-ifc' of https://github.com/Moult/FreeCAD into Moult-fix-ifc

This commit is contained in:
Yorik van Havre
2019-03-27 11:57:22 -03:00
12 changed files with 5391 additions and 188 deletions

View File

@@ -22,7 +22,7 @@
#* *
#***************************************************************************
import FreeCAD,Draft,ArchCommands,DraftVecUtils,sys
import FreeCAD,Draft,ArchCommands,DraftVecUtils,sys,ArchIFC
if FreeCAD.GuiUp:
import FreeCADGui
from PySide import QtCore, QtGui
@@ -320,6 +320,7 @@ class BuildingPart:
self.setProperties(obj)
def setProperties(self,obj):
ArchIFC.setProperties(obj)
pl = obj.PropertiesList
if not "Height" in pl:
@@ -362,7 +363,7 @@ class BuildingPart:
self.oldPlacement = FreeCAD.Placement(obj.Placement)
def onChanged(self,obj,prop):
ArchIFC.onChanged(obj, prop)
if prop == "Height":
for child in obj.Group:
if Draft.getType(child) in ["Wall","Structure"]:

View File

@@ -25,62 +25,7 @@ __title__="FreeCAD Arch Component"
__author__ = "Yorik van Havre"
__url__ = "http://www.freecadweb.org"
# IFC types
IFCTYPES = ["IfcActuator", "IfcAirTerminal", "IfcAirTerminalBox", "IfcAirToAirHeatRecovery",
"IfcAlarm", "IfcAnnotation", "IfcAudioVisualAppliance", "IfcBeam", "IfcBeamStandardCase",
"IfcBoiler", "IfcBuilding", "IfcBuildingElement", "IfcBuildingElementPart", "IfcBuildingElementProxy",
"IfcBuildingStorey", "IfcBurner", "IfcCableCarrierFitting", "IfcCableCarrierSegment",
"IfcCableFitting", "IfcCableSegment", "IfcChiller", "IfcChimney", "IfcCivilElement",
"IfcCoil", "IfcColumn", "IfcColumnStandardCase", "IfcCommunicationsAppliance", "IfcCompressor",
"IfcCondenser", "IfcController", "IfcCooledBeam", "IfcCoolingTower", "IfcCovering",
"IfcCurtainWall", "IfcDamper", "IfcDiscreteAccessory", "IfcDistributionChamberElement",
"IfcDistributionControlElement", "IfcDistributionElement", "IfcDistributionFlowElement",
"IfcDistributionPort", "IfcDoor", "IfcDoorStandardCase", "IfcDuctFitting", "IfcDuctSegment",
"IfcDuctSilencer", "IfcElectricAppliance", "IfcElectricDistributionBoard", "IfcElectricFlowStorageDevice",
"IfcElectricGenerator", "IfcElectricMotor", "IfcElectricTimeControl",
"IfcElementAssembly", "IfcElementComponent", "IfcEnergyConversionDevice", "IfcEngine",
"IfcEvaporativeCooler", "IfcEvaporator", "IfcExternalSpatialElement", "IfcExternalSpatialStructureElement",
"IfcFan", "IfcFastener", "IfcFeatureElement", "IfcFeatureElementAddition", "IfcFeatureElementSubtraction",
"IfcFilter", "IfcFireSuppressionTerminal", "IfcFlowController", "IfcFlowFitting", "IfcFlowInstrument",
"IfcFlowMeter", "IfcFlowMovingDevice", "IfcFlowSegment", "IfcFlowStorageDevice", "IfcFlowTerminal",
"IfcFlowTreatmentDevice", "IfcFooting", "IfcFurnishingElement", "IfcFurniture", "IfcGeographicElement",
"IfcGrid", "IfcHeatExchanger", "IfcHumidifier", "IfcInterceptor", "IfcJunctionBox", "IfcLamp",
"IfcLightFixture", "IfcMechanicalFastener", "IfcMedicalDevice", "IfcMember", "IfcMemberStandardCase",
"IfcMotorConnection", "IfcOpeningElement", "IfcOpeningStandardCase", "IfcOutlet", "IfcPile",
"IfcPipeFitting", "IfcPipeSegment", "IfcPlate", "IfcPlateStandardCase",
"IfcProjectionElement", "IfcProtectiveDevice", "IfcProtectiveDeviceTrippingUnit",
"IfcProxy", "IfcPump", "IfcRailing", "IfcRamp", "IfcRampFlight", "IfcReinforcingBar",
"IfcReinforcingMesh", "IfcRoof", "IfcSanitaryTerminal",
"IfcSensor", "IfcShadingDevice", "IfcSite", "IfcSlab", "IfcSlabElementedCase", "IfcSlabStandardCase",
"IfcSolarDevice", "IfcSpace", "IfcSpaceHeater",
"IfcSpatialZone", "IfcStackTerminal", "IfcStair", "IfcStairFlight",
"IfcStructuralCurveAction",
"IfcStructuralCurveConnection", "IfcStructuralCurveMember", "IfcStructuralCurveMemberVarying",
"IfcStructuralCurveReaction", "IfcStructuralLinearAction",
"IfcStructuralPlanarAction", "IfcStructuralPointAction",
"IfcStructuralPointConnection", "IfcStructuralPointReaction",
"IfcStructuralSurfaceAction", "IfcStructuralSurfaceConnection", "IfcStructuralSurfaceMember",
"IfcStructuralSurfaceMemberVarying", "IfcStructuralSurfaceReaction", "IfcSurfaceFeature",
"IfcSwitchingDevice", "IfcSystemFurnitureElement", "IfcTank", "IfcTendon", "IfcTendonAnchor",
"IfcTransformer", "IfcTransportElement", "IfcTubeBundle", "IfcUnitaryControlElement",
"IfcUnitaryEquipment", "IfcValve", "IfcVibrationIsolator", "IfcVirtualElement", "IfcVoidingFeature",
"IfcWall", "IfcWallElementedCase", "IfcWallStandardCase", "IfcWasteTerminal", "IfcWindow",
"IfcWindowStandardCase"]
# Possible roles for FreeCAD BIM objects
IfcRoles = ['Undefined']+[''.join(map(lambda x: x if x.islower() else " "+x, t[3:]))[1:] for t in IFCTYPES]
# Property types
SimplePropertyTypes = ["IfcInteger","IfcReal","IfcBoolean","IfcIdentifier","IfcText","IfcLabel","IfcLogical"]
MeasurePropertyTypes = ["IfcVolumeMeasure","IfcTimeMeasure","IfcThermodynamicTemperatureMeasure","IfcSolidAngleMeasure",
"IfcPositiveRatioMeasure","IfcRatioMeasure","IfcPositivePlaneAngleMeasure","IfcPlaneAngleMeasure",
"IfcParameterValue","IfcNumericMeasure","IfcMassMeasure","IfcPositiveLengthMeasure",
"IfcLengthMeasure","IfcElectricCurrentMeasure","IfcDescriptiveMeasure","IfcCountMeasure",
"IfcContextDependentMeasure","IfcAreaMeasure","IfcAmountOfSubstanceMeasure",
"IfcLuminousIntensityMeasure","IfcNormalisedRatioMeasure","IfcComplexNumber"]
import FreeCAD,Draft,ArchCommands,math,sys
import FreeCAD,Draft,ArchCommands,math,sys,json,os,ArchIFC,ArchIFCSchema
from FreeCAD import Vector
if FreeCAD.GuiUp:
import FreeCADGui
@@ -102,7 +47,7 @@ else:
# This module provides the base Arch component class, that
# is shared by all of the Arch BIM objects
IfcRoles = ['Undefined']+[''.join(map(lambda x: x if x.islower() else " "+x, t[3:]))[1:] for t in ArchIFCSchema.IfcProducts.keys()]
def convertOldComponents(objs=[]):
@@ -222,7 +167,7 @@ class Component:
self.Type = "Component"
def setProperties(self,obj):
ArchIFC.setProperties(obj)
pl = obj.PropertiesList
if not "Base" in pl:
obj.addProperty("App::PropertyLink","Base","Component",QT_TRANSLATE_NOOP("App::Property","The base object this component is built upon"))
@@ -238,8 +183,6 @@ class Component:
obj.addProperty("App::PropertyString","Tag","Component",QT_TRANSLATE_NOOP("App::Property","An optional tag for this component"))
if not "StandardCode" in pl:
obj.addProperty("App::PropertyString","StandardCode","Component",QT_TRANSLATE_NOOP("App::Property","An optional standard (OmniClass, etc...) code for this component"))
if not "IfcAttributes" in pl:
obj.addProperty("App::PropertyMap","IfcAttributes","Component",QT_TRANSLATE_NOOP("App::Property","Custom IFC properties and attributes"))
if not "Material" in pl:
obj.addProperty("App::PropertyLink","Material","Component",QT_TRANSLATE_NOOP("App::Property","A material for this object"))
if "BaseMaterial" in pl:
@@ -317,6 +260,7 @@ class Component:
self.oldPlacement = FreeCAD.Placement(obj.Placement)
def onChanged(self,obj,prop):
ArchIFC.onChanged(obj, prop)
if prop == "Placement":
if hasattr(self,"oldPlacement"):
@@ -1255,10 +1199,10 @@ class ComponentTaskPanel:
return
if not isinstance(self.obj.IfcProperties,dict):
return
import Arch_rc,csv,os
import Arch_rc, csv, os, ArchIFCSchema
# get presets
self.ptypes = SimplePropertyTypes + MeasurePropertyTypes
self.ptypes = ArchIFCSchema.IfcTypes.keys()
self.plabels = [''.join(map(lambda x: x if x.islower() else " "+x, t[3:]))[1:] for t in self.ptypes]
self.psetdefs = {}
psetspath = os.path.join(FreeCAD.getResourceDir(),"Mod","Arch","Presets","pset_definitions.csv")
@@ -1286,8 +1230,8 @@ class ComponentTaskPanel:
self.ifcEditor.comboPset.addItems([QtGui.QApplication.translate("Arch", "Add property set...", None),
QtGui.QApplication.translate("Arch", "New...", None)]+self.psetkeys)
# set UUID
if "IfcUID" in self.obj.IfcAttributes:
self.ifcEditor.labelUUID.setText(self.obj.IfcAttributes["IfcUID"])
if "IfcUID" in self.obj.IfcData:
self.ifcEditor.labelUUID.setText(self.obj.IfcData["IfcUID"])
# fill the tree
psets = {}
for pname,value in self.obj.IfcProperties.items():
@@ -1333,10 +1277,10 @@ class ComponentTaskPanel:
QtCore.QObject.connect(self.ifcEditor.buttonDelete, QtCore.SIGNAL("clicked()"), self.removeIfcProperty)
self.ifcEditor.treeProperties.setSortingEnabled(True)
# set checkboxes
if "FlagForceBrep" in self.obj.IfcAttributes:
self.ifcEditor.checkBrep.setChecked(self.obj.IfcAttributes["FlagForceBrep"] == "True")
if "FlagParametric" in self.obj.IfcAttributes:
self.ifcEditor.checkParametric.setChecked(self.obj.IfcAttributes["FlagParametric"] == "True")
if "FlagForceBrep" in self.obj.IfcData:
self.ifcEditor.checkBrep.setChecked(self.obj.IfcData["FlagForceBrep"] == "True")
if "FlagParametric" in self.obj.IfcData:
self.ifcEditor.checkParametric.setChecked(self.obj.IfcData["FlagParametric"] == "True")
self.ifcEditor.show()
def acceptIfcProperties(self):
@@ -1358,16 +1302,16 @@ class ComponentTaskPanel:
else:
# keys cannot be unicode
ifcdict[prop.encode("utf8")] = pset+";;"+ptype+";;"+pvalue
ifcattrs = self.obj.IfcAttributes
ifcattrs["IfcUID"] = self.ifcEditor.labelUUID.text()
ifcattrs["FlagForceBrep"] = str(self.ifcEditor.checkBrep.isChecked())
ifcattrs["FlagParametric"] = str(self.ifcEditor.checkParametric.isChecked())
if (ifcdict != self.obj.IfcProperties) or (ifcattrs != self.obj.IfcAttributes):
ifcData = self.obj.IfcData
ifcData["IfcUID"] = self.ifcEditor.labelUUID.text()
ifcData["FlagForceBrep"] = str(self.ifcEditor.checkBrep.isChecked())
ifcData["FlagParametric"] = str(self.ifcEditor.checkParametric.isChecked())
if (ifcdict != self.obj.IfcProperties) or (ifcData != self.obj.IfcData):
FreeCAD.ActiveDocument.openTransaction("Change Ifc Properties")
if ifcdict != self.obj.IfcProperties:
self.obj.IfcProperties = ifcdict
if ifcattrs != self.obj.IfcAttributes:
self.obj.IfcAttributes = ifcattrs
if ifcData != self.obj.IfcData:
self.obj.IfcData = ifcData
FreeCAD.ActiveDocument.commitTransaction()
del self.ifcEditor
@@ -1531,10 +1475,3 @@ if FreeCAD.GuiUp:
else:
model.setData(index,editor.text())
self.dialog.update()

109
src/Mod/Arch/ArchIFC.py Normal file
View File

@@ -0,0 +1,109 @@
import FreeCAD, os, json
if FreeCAD.GuiUp:
from PySide.QtCore import QT_TRANSLATE_NOOP
def setProperties(obj):
if not "IfcData" in obj.PropertiesList:
obj.addProperty("App::PropertyMap","IfcData","Component",QT_TRANSLATE_NOOP("App::Property","IFC data"))
migrateDeprecatedAttributes(obj)
def onChanged(obj, prop):
if prop == "IfcRole":
setupIfcAttributes(obj)
if obj.getGroupOfProperty(prop) == "IFC Attributes":
setObjIfcAttributeValue(obj, prop, obj.getPropertyByName(prop))
def getIfcProduct(IfcRole):
import ArchIFCSchema
name = "Ifc" + IfcRole.replace(" ", "")
if name in ArchIFCSchema.IfcProducts:
return ArchIFCSchema.IfcProducts[name]
def getIfcProductAttribute(ifcProduct, name):
for attribute in ifcProduct["attributes"]:
if attribute["name"].replace(' ', '') == name:
return attribute
return None
def setupIfcAttributes(obj):
ifcProduct = getIfcProduct(obj.IfcRole)
if ifcProduct is None:
return
purgeUnusedIfcAttributesFromPropertiesList(ifcProduct, obj)
addIfcProductAttributesToObj(ifcProduct, obj)
def addIfcProductAttributesToObj(ifcProduct, obj):
for attribute in ifcProduct["attributes"]:
if attribute["name"] in obj.PropertiesList \
or attribute["name"] == "RefLatitude" \
or attribute["name"] == "RefLongitude":
continue
addIfcProductAttribute(obj, attribute)
addIfcAttributeValueExpressions(obj, attribute)
def addIfcProductAttribute(obj, attribute):
IfcData = obj.IfcData
if "attributes" not in IfcData:
IfcData["attributes"] = "{}"
IfcAttributes = json.loads(IfcData["attributes"])
IfcAttributes[attribute["name"]] = attribute
IfcData["attributes"] = json.dumps(IfcAttributes)
obj.IfcData = IfcData
if attribute["is_enum"]:
obj.addProperty("App::PropertyEnumeration", attribute["name"], "IFC Attributes", QT_TRANSLATE_NOOP("App::Property", "Description of IFC attributes are not yet implemented"))
setattr(obj, attribute["name"], attribute["enum_values"])
else:
propertyType = "App::" + ArchIFCSchema.IfcTypes[attribute["type"]]["property"]
obj.addProperty(propertyType, attribute["name"], "IFC Attributes", QT_TRANSLATE_NOOP("App::Property", "Description of IFC attributes are not yet implemented"))
def addIfcAttributeValueExpressions(obj, attribute):
if obj.getGroupOfProperty(attribute["name"]) != "Ifc Attributes":
return
if attribute["name"] == "OverallWidth":
if hasattr(obj, "Length"):
obj.setExpression("OverallWidth", "Length.Value")
elif hasattr(obj, "Width"):
obj.setExpression("OverallWidth", "Width.Value")
elif obj.Shape.BoundBox.XLength > obj.Shape.BoundBox.YLength:
obj.setExpression("OverallWidth", "Shape.BoundBox.XLength")
else:
obj.setExpression("OverallWidth", "Shape.BoundBox.YLength")
elif attribute["name"] == "OverallHeight":
if hasattr(obj, "Height"):
obj.setExpression("OverallHeight", "Height.Value")
else:
obj.setExpression("OverallHeight", "Shape.BoundBox.ZLength")
elif attribute["name"] == "ElevationWithFlooring":
obj.setExpression("ElevationWithFlooring", "Shape.BoundBox.ZMin")
elif attribute["name"] == "Elevation":
obj.setExpression("Elevation", "Placement.Base.z")
elif attribute["name"] == "NominalDiameter":
obj.setExpression("NominalDiameter", "Diameter.Value")
elif attribute["name"] == "BarLength":
obj.setExpression("BarLength", "Length.Value")
elif attribute["name"] == "RefElevation":
obj.setExpression("RefElevation", "Elevation.Value")
def setObjIfcAttributeValue(obj, attributeName, value):
IfcData = obj.IfcData
IfcAttributes = json.loads(IfcData["attributes"])
if isinstance(value, FreeCAD.Units.Quantity):
value = float(value)
IfcAttributes[attributeName]["value"] = value
IfcData["attributes"] = json.dumps(IfcAttributes)
obj.IfcData = IfcData
def purgeUnusedIfcAttributesFromPropertiesList(ifcProduct, obj):
for property in obj.PropertiesList:
if obj.getGroupOfProperty(property) != "IFC Attributes":
continue
ifcProductAttribute = getIfcProductAttribute(ifcProduct, property)
if ifcProductAttribute is None or ifcProductAttribute["is_enum"] is True:
obj.removeProperty(property)
def migrateDeprecatedAttributes(obj):
# FreeCAD <= 0.17 stored IFC data in IfcAttributes
if hasattr(obj, "IfcAttributes"):
obj.IfcData = obj.IfcAttributes
obj.removeProperty("IfcAttributes")

View File

@@ -0,0 +1,12 @@
import FreeCAD, os, json
ifcVersions = ["IFC4", "IFC2X3"]
IfcVersion = ifcVersions[FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch").GetInt("IfcVersion",0)]
with open(os.path.join(FreeCAD.getResourceDir(), "Mod", "Arch", "Presets",
"ifc_products_" + IfcVersion + ".json")) as f:
IfcProducts = json.load(f)
with open(os.path.join(FreeCAD.getResourceDir(), "Mod", "Arch", "Presets",
"ifc_types_" + IfcVersion + ".json")) as f:
IfcTypes = json.load(f)

View File

@@ -23,7 +23,7 @@
#* *
#***************************************************************************
import FreeCAD,Draft,ArchCommands,ArchFloor,math,re,datetime
import FreeCAD,Draft,ArchCommands,ArchFloor,math,re,datetime,ArchIFC
if FreeCAD.GuiUp:
import FreeCADGui
from PySide import QtCore, QtGui
@@ -324,7 +324,7 @@ class _Site(ArchFloor._Floor):
obj.IfcRole = "Site"
def setProperties(self,obj):
ArchIFC.setProperties(obj)
pl = obj.PropertiesList
if not "Terrain" in pl:
obj.addProperty("App::PropertyLink","Terrain","Site",QT_TRANSLATE_NOOP("App::Property","The base terrain of this site"))
@@ -424,6 +424,7 @@ class _Site(ArchFloor._Floor):
self.computeAreas(obj)
def onChanged(self,obj,prop):
ArchIFC.onChanged(obj, prop)
ArchFloor._Floor.onChanged(self,obj,prop)
if prop == "Terrain":

View File

@@ -6,6 +6,7 @@ SET(Arch_SRCS
Init.py
InitGui.py
ArchComponent.py
ArchIFC.py
ArchWall.py
importIFC.py
importIFClegacy.py
@@ -53,6 +54,10 @@ SET(Dice3DS_SRCS
SET(Arch_presets
Presets/profiles.csv
Presets/pset_definitions.csv
Presets/ifc_products_IFC2X3.json
Presets/ifc_products_IFC4.json
Presets/ifc_types_IFC2X3.json
Presets/ifc_types_IFC4.json
)
SOURCE_GROUP("" FILES ${Arch_SRCS})

View File

@@ -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": [] }
}

File diff suppressed because it is too large Load Diff

View File

@@ -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": {}
}

View File

@@ -0,0 +1,558 @@
{
"IfcBSplineCurveForm": {
"base": "xs:string",
"property": "PropertyString"
},
"IfcBSplineSurfaceForm": {
"base": "xs:string",
"property": "PropertyString"
},
"IfcBooleanOperator": {
"base": "xs:string",
"property": "PropertyString"
},
"IfcKnotType": {
"base": "xs:string",
"property": "PropertyString"
},
"IfcNullStyle": {
"base": "xs:string",
"property": "PropertyString"
},
"IfcPreferredSurfaceCurveRepresentation": {
"base": "xs:string",
"property": "PropertyString"
},
"IfcSIPrefix": {
"base": "xs:string",
"property": "PropertyString"
},
"IfcSIUnitName": {
"base": "xs:string",
"property": "PropertyString"
},
"IfcSurfaceSide": {
"base": "xs:string",
"property": "PropertyString"
},
"IfcTextPath": {
"base": "xs:string",
"property": "PropertyString"
},
"IfcTransitionCode": {
"base": "xs:string",
"property": "PropertyString"
},
"IfcTrimmingPreference": {
"base": "xs:string",
"property": "PropertyString"
},
"IfcAbsorbedDoseMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcAccelerationMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcAmountOfSubstanceMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcAngularVelocityMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcAreaDensityMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcAreaMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcBoolean": {
"base": "xs:boolean",
"property": "PropertyBool"
},
"IfcBoxAlignment": {
"base": "ifc:IfcLabel",
"property": "PropertyString"
},
"IfcCardinalPointReference": {
"base": "xs:long",
"property": "PropertyFloat"
},
"IfcContextDependentMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcCountMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcCurvatureMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcDate": {
"base": "xs:normalizedString",
"property": "PropertyString"
},
"IfcDateTime": {
"base": "xs:normalizedString",
"property": "PropertyString"
},
"IfcDayInMonthNumber": {
"base": "xs:long",
"property": "PropertyFloat"
},
"IfcDayInWeekNumber": {
"base": "xs:long",
"property": "PropertyFloat"
},
"IfcDescriptiveMeasure": {
"base": "xs:normalizedString",
"property": "PropertyString"
},
"IfcDimensionCount": {
"base": "xs:long",
"property": "PropertyFloat"
},
"IfcDoseEquivalentMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcDuration": {
"base": "xs:normalizedString",
"property": "PropertyString"
},
"IfcDynamicViscosityMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcElectricCapacitanceMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcElectricChargeMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcElectricConductanceMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcElectricCurrentMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcElectricResistanceMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcElectricVoltageMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcEnergyMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcFontStyle": {
"base": "xs:normalizedString",
"property": "PropertyString"
},
"IfcFontVariant": {
"base": "xs:normalizedString",
"property": "PropertyString"
},
"IfcFontWeight": {
"base": "xs:normalizedString",
"property": "PropertyString"
},
"IfcForceMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcFrequencyMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcGloballyUniqueId": {
"base": "xs:normalizedString",
"property": "PropertyString"
},
"IfcHeatFluxDensityMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcHeatingValueMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcIdentifier": {
"base": "xs:normalizedString",
"property": "PropertyString"
},
"IfcIlluminanceMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcInductanceMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcInteger": {
"base": "xs:long",
"property": "PropertyFloat"
},
"IfcIntegerCountRateMeasure": {
"base": "xs:long",
"property": "PropertyFloat"
},
"IfcIonConcentrationMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcIsothermalMoistureCapacityMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcKinematicViscosityMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcLabel": {
"base": "xs:normalizedString",
"property": "PropertyString"
},
"IfcLanguageId": {
"base": "ifc:IfcIdentifier",
"property": "PropertyString"
},
"IfcLengthMeasure": {
"base": "xs:double",
"property": "PropertyLength"
},
"IfcLinearForceMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcLinearMomentMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcLinearStiffnessMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcLinearVelocityMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcLogical": {
"base": "ifc:logical",
"property": "PropertyBool"
},
"IfcLuminousFluxMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcLuminousIntensityDistributionMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcLuminousIntensityMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcMagneticFluxDensityMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcMagneticFluxMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcMassDensityMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcMassFlowRateMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcMassMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcMassPerLengthMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcModulusOfElasticityMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcModulusOfLinearSubgradeReactionMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcModulusOfRotationalSubgradeReactionMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcModulusOfSubgradeReactionMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcMoistureDiffusivityMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcMolecularWeightMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcMomentOfInertiaMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcMonetaryMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcMonthInYearNumber": {
"base": "xs:long",
"property": "PropertyFloat"
},
"IfcNonNegativeLengthMeasure": {
"base": "ifc:IfcLengthMeasure",
"property": "PropertyLength"
},
"IfcNormalisedRatioMeasure": {
"base": "ifc:IfcRatioMeasure",
"property": "PropertyFloat"
},
"IfcNumericMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcPHMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcParameterValue": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcPlanarForceMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcPlaneAngleMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcPositiveInteger": {
"base": "ifc:IfcInteger",
"property": "PropertyInteger"
},
"IfcPositiveLengthMeasure": {
"base": "ifc:IfcLengthMeasure",
"property": "PropertyLength"
},
"IfcPositivePlaneAngleMeasure": {
"base": "ifc:IfcPlaneAngleMeasure",
"property": "PropertyFloat"
},
"IfcPositiveRatioMeasure": {
"base": "ifc:IfcRatioMeasure",
"property": "PropertyFloat"
},
"IfcPowerMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcPresentableText": {
"base": "xs:normalizedString",
"property": "PropertyString"
},
"IfcPressureMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcRadioActivityMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcRatioMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcReal": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcRotationalFrequencyMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcRotationalMassMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcRotationalStiffnessMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcSectionModulusMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcSectionalAreaIntegralMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcShearModulusMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcSolidAngleMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcSoundPowerLevelMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcSoundPowerMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcSoundPressureLevelMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcSoundPressureMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcSpecificHeatCapacityMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcSpecularExponent": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcSpecularRoughness": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcTemperatureGradientMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcTemperatureRateOfChangeMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcText": {
"base": "xs:normalizedString",
"property": "PropertyString"
},
"IfcTextAlignment": {
"base": "xs:normalizedString",
"property": "PropertyString"
},
"IfcTextDecoration": {
"base": "xs:normalizedString",
"property": "PropertyString"
},
"IfcTextFontName": {
"base": "xs:normalizedString",
"property": "PropertyString"
},
"IfcTextTransformation": {
"base": "xs:normalizedString",
"property": "PropertyString"
},
"IfcThermalAdmittanceMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcThermalConductivityMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcThermalExpansionCoefficientMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcThermalResistanceMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcThermalTransmittanceMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcThermodynamicTemperatureMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcTime": {
"base": "xs:normalizedString",
"property": "PropertyString"
},
"IfcTimeMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcTimeStamp": {
"base": "xs:long",
"property": "PropertyFloat"
},
"IfcTorqueMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcURIReference": {
"base": "xs:normalizedString",
"property": "PropertyString"
},
"IfcVaporPermeabilityMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcVolumeMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcVolumetricFlowRateMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcWarpingConstantMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"IfcWarpingMomentMeasure": {
"base": "xs:double",
"property": "PropertyFloat"
},
"aggregateType": {
"base": "xs:normalizedString",
"property": "PropertyString"
},
"logical": {
"base": "xs:normalizedString",
"property": "PropertyString"
},
"List-IfcCompoundPlaneAngleMeasure": {
"base": "xs:string",
"property": "PropertyString"
}
}

View File

@@ -17,16 +17,7 @@
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>9</number>
</property>
<item>
@@ -226,6 +217,69 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer_11">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>IFC version</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_12">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Gui::PrefComboBox" name="comboBox">
<property name="toolTip">
<string>The IFC version will change which attributes and products are supported</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>IfcVersion</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Arch</cstring>
</property>
<item>
<property name="text">
<string>IFC4</string>
</property>
</item>
<item>
<property name="text">
<string>IFC2X3</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
@@ -708,6 +762,11 @@
<extends>QCheckBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefComboBox</class>
<extends>QComboBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefLineEdit</class>
<extends>QLineEdit</extends>

View File

@@ -31,6 +31,7 @@ import six
import os,time,tempfile,uuid,FreeCAD,Part,Draft,Arch,math,DraftVecUtils,sys
from DraftGeomUtils import vec
from ArchIFC import ifcProducts
## @package importIFC
# \ingroup ARCH
@@ -842,10 +843,13 @@ def insert(filename,docname,skip=[],only=[],root=None):
# setting uid
if hasattr(obj,"IfcAttributes"):
a = obj.IfcAttributes
if hasattr(obj,"IfcData"):
a = obj.IfcData
a["IfcUID"] = str(guid)
obj.IfcAttributes = a
obj.IfcData = a
for attribute in ifcProducts[product.is_a()]["attributes"]:
if hasattr(product, attribute["name"]) and getattr(product, attribute["name"]):
setattr(obj, attribute["name"], getattr(product, attribute["name"]))
if obj:
s = ""
@@ -888,10 +892,10 @@ def insert(filename,docname,skip=[],only=[],root=None):
obj.Role = r
except:
print("Unable to give IFC role ",ptype," to object ",obj.Label)
if hasattr(obj,"IfcAttributes"):
a = obj.IfcAttributes
if hasattr(obj,"IfcData"):
a = obj.IfcData
a["IfcUID"] = str(guid)
obj.IfcAttributes = a
obj.IfcData = a
elif (MERGE_MODE_ARCH == 2 and archobj) or (MERGE_MODE_STRUCT == 1 and not archobj):
@@ -993,17 +997,17 @@ def insert(filename,docname,skip=[],only=[],root=None):
#print("adding property: ",pname,ptype,pvalue," pset ",psetname)
obj.IfcProperties = d
elif hasattr(obj,"IfcAttributes"):
elif hasattr(obj,"IfcData"):
# 0.17: properties are saved as type(value) in IfcAttributes
# 0.17: properties are saved as type(value) in IfcData
a = obj.IfcAttributes
a = obj.IfcData
for c in properties[pid].keys():
for p in properties[pid][c]:
l = ifcfile[p]
if l.is_a("IfcPropertySingleValue"):
a[l.Name.encode("utf8")] = str(l.NominalValue) # no py3 support here
obj.IfcAttributes = a
obj.IfcData = a
# color
@@ -1664,37 +1668,22 @@ def export(exportList,filename):
# getting uid
uid = None
if hasattr(obj,"IfcAttributes"):
if "IfcUID" in obj.IfcAttributes.keys():
uid = str(obj.IfcAttributes["IfcUID"])
if hasattr(obj,"IfcData"):
if "IfcUID" in obj.IfcData.keys():
uid = str(obj.IfcData["IfcUID"])
if not uid:
uid = ifcopenshell.guid.compress(uuid.uuid1().hex)
# storing the uid for further use
if STORE_UID and hasattr(obj,"IfcAttributes"):
d = obj.IfcAttributes
if STORE_UID and hasattr(obj,"IfcData"):
d = obj.IfcData
d["IfcUID"] = uid
obj.IfcAttributes = d
obj.IfcData = d
# setting the IFC type + name conversions
ifctype = getIfcRoleFromObj(obj)
if hasattr(obj,"IfcRole"):
ifctype = obj.IfcRole.replace(" ","")
elif hasattr(obj,"Role"):
ifctype = obj.Role.replace(" ","")
else:
ifctype = Draft.getType(obj)
if ifctype in translationtable.keys():
ifctype = translationtable[ifctype]
ifctype = "Ifc" + ifctype
if ifctype == "IfcVisGroup":
ifctype = "IfcGroup"
if ifctype == "IfcGroup":
groups[obj.Name] = [o.Name for o in obj.Group]
continue
if (Draft.getType(obj) == "BuildingPart") and hasattr(obj,"IfcRole") and (obj.IfcRole == "Undefined"):
ifctype = "IfcBuildingStorey" # export BuildingParts as Storeys if their type wasn't explicitly set
if (Draft.getType(obj) == "BuildingPart") and hasattr(obj,"IfcRole") and (obj.IfcRole == "Building"):
ifctype = "IfcBuilding"
# export grids
@@ -1755,16 +1744,15 @@ def export(exportList,filename):
count += 1
continue
from ArchComponent import IFCTYPES
if ifctype not in IFCTYPES:
if ifctype not in ifcProducts.keys():
ifctype = "IfcBuildingElementProxy"
# getting the "Force BREP" flag
brepflag = False
if hasattr(obj,"IfcAttributes"):
if "FlagForceBrep" in obj.IfcAttributes.keys():
if obj.IfcAttributes["FlagForceBrep"] == "True":
if hasattr(obj,"IfcData"):
if "FlagForceBrep" in obj.IfcData.keys():
if obj.IfcData["FlagForceBrep"] == "True":
brepflag = True
# getting the representation
@@ -1777,53 +1765,15 @@ def export(exportList,filename):
kwargs = {"GlobalId": uid, "OwnerHistory": history, "Name": name,
"Description": description, "ObjectPlacement": placement, "Representation": representation}
if ifctype in ["IfcSlab","IfcFooting","IfcRoof"]:
kwargs.update({"PredefinedType": "NOTDEFINED"})
elif ifctype in ["IfcWindow","IfcDoor"]:
if hasattr(obj,"Width") and hasattr(obj,"Height"):
kwargs.update({"OverallHeight": obj.Width.Value/1000.0,
"OverallWidth": obj.Height.Value/1000.0})
else:
if obj.Shape.BoundBox.XLength > obj.Shape.BoundBox.YLength:
l = obj.Shape.BoundBox.XLength
else:
l = obj.Shape.BoundBox.YLength
kwargs.update({"OverallHeight": l/1000.0,
"OverallWidth": obj.Shape.BoundBox.ZLength/1000.0})
elif ifctype == "IfcSpace":
internal = "NOTDEFINED"
if hasattr(obj,"Internal"):
if obj.Internal:
internal = "INTERNAL"
else:
internal = "EXTERNAL"
if schema == "IFC2X3":
kwargs.update({"CompositionType": "ELEMENT",
"InteriorOrExteriorSpace": internal,
"ElevationWithFlooring": obj.Shape.BoundBox.ZMin/1000.0})
else:
kwargs.update({"CompositionType": "ELEMENT",
"PredefinedType": internal,
"ElevationWithFlooring": obj.Shape.BoundBox.ZMin/1000.0})
elif ifctype == "IfcBuildingElementProxy":
if schema == "IFC4":
kwargs.update({"PredefinedType": "ELEMENT"})
else:
kwargs.update({"CompositionType": "ELEMENT"})
elif ifctype == "IfcSite":
if ifctype == "IfcSite":
kwargs.update({"RefLatitude":dd2dms(obj.Latitude),
"RefLongitude":dd2dms(obj.Longitude),
"RefElevation":obj.Elevation.Value/1000.0,
"SiteAddress":buildAddress(obj,ifcfile),
"CompositionType": "ELEMENT"})
elif ifctype == "IfcBuilding":
kwargs.update({"CompositionType": "ELEMENT"})
elif ifctype == "IfcBuildingStorey":
kwargs.update({"CompositionType": "ELEMENT",
"Elevation": obj.Placement.Base.z/1000.0})
elif ifctype == "IfcReinforcingBar":
kwargs.update({"NominalDiameter": obj.Diameter.Value,
"BarLength": obj.Length.Value})
if ifcopenshell.schema_identifier == "IFC2X3":
kwargs = exportIFC2X3Attributes(obj, kwargs)
kwargs = exportIfcAttributes(obj, kwargs)
# creating the product
@@ -1987,18 +1937,18 @@ def export(exportList,filename):
pset = ifcfile.createIfcPropertySet(ifcopenshell.guid.compress(uuid.uuid1().hex),history,cat,None,props)
ifcfile.createIfcRelDefinesByProperties(ifcopenshell.guid.compress(uuid.uuid1().hex),history,None,None,[product],pset)
if hasattr(obj,"IfcAttributes"):
if hasattr(obj,"IfcData"):
if obj.IfcAttributes:
if obj.IfcData:
ifcprop = True
#if DEBUG : print(" adding ifc attributes")
props = []
for key in obj.IfcAttributes:
for key in obj.IfcData:
if not (key in ["IfcUID","FlagForceBrep"]):
# (deprecated) properties in IfcAttributes dict are stored as "key":"type(value)"
# (deprecated) properties in IfcData dict are stored as "key":"type(value)"
r = obj.IfcAttributes[key].strip(")").split("(")
r = obj.IfcData[key].strip(")").split("(")
if len(r) == 1:
tp = "IfcText"
val = r[0]
@@ -2031,19 +1981,19 @@ def export(exportList,filename):
# Quantities
if hasattr(obj,"IfcAttributes"):
if hasattr(obj,"IfcData"):
quantities = []
if ("ExportHeight" in obj.IfcAttributes) and obj.IfcAttributes["ExportHeight"] and hasattr(obj,"Height"):
if ("ExportHeight" in obj.IfcData) and obj.IfcData["ExportHeight"] and hasattr(obj,"Height"):
quantities.append(ifcfile.createIfcQuantityLength('Height',None,None,obj.Height.Value/1000.0))
if ("ExportWidth" in obj.IfcAttributes) and obj.IfcAttributes["ExportWidth"] and hasattr(obj,"Width"):
if ("ExportWidth" in obj.IfcData) and obj.IfcData["ExportWidth"] and hasattr(obj,"Width"):
quantities.append(ifcfile.createIfcQuantityLength('Width',None,None,obj.Width.Value/1000.0))
if ("ExportLength" in obj.IfcAttributes) and obj.IfcAttributes["ExportLength"] and hasattr(obj,"Length"):
if ("ExportLength" in obj.IfcData) and obj.IfcData["ExportLength"] and hasattr(obj,"Length"):
quantities.append(ifcfile.createIfcQuantityLength('Length',None,None,obj.Length.Value/1000.0))
if ("ExportHorizontalArea" in obj.IfcAttributes) and obj.IfcAttributes["ExportHorizontalArea"] and hasattr(obj,"HorizontalArea"):
if ("ExportHorizontalArea" in obj.IfcData) and obj.IfcData["ExportHorizontalArea"] and hasattr(obj,"HorizontalArea"):
quantities.append(ifcfile.createIfcQuantityArea('HorizontalArea',None,None,obj.HorizontalArea.Value/1000000.0))
if ("ExportVerticalArea" in obj.IfcAttributes) and obj.IfcAttributes["ExportVerticalArea"] and hasattr(obj,"VerticalArea"):
if ("ExportVerticalArea" in obj.IfcData) and obj.IfcData["ExportVerticalArea"] and hasattr(obj,"VerticalArea"):
quantities.append(ifcfile.createIfcQuantityArea('VerticalArea',None,None,obj.VerticalArea.Value/1000000.0))
if ("ExportVolume" in obj.IfcAttributes) and obj.IfcAttributes["ExportVolume"] and obj.isDerivedFrom("Part::Feature"):
if ("ExportVolume" in obj.IfcData) and obj.IfcData["ExportVolume"] and obj.isDerivedFrom("Part::Feature"):
quantities.append(ifcfile.createIfcQuantityVolume('Volume',None,None,obj.Shape.Volume/1000000000.0))
if quantities:
eltq = ifcfile.createIfcElementQuantity(ifcopenshell.guid.compress(uuid.uuid1().hex),history,"ElementQuantities",None,"FreeCAD",quantities)
@@ -2068,7 +2018,7 @@ def export(exportList,filename):
for realm,ctx in sets:
if ctx:
for prop in ctx.PropertiesList:
if not(prop in ["IfcProperties","IfcAttributes","Shape","Proxy","ExpressionEngine","AngularDeflection","BoundingBox"]):
if not(prop in ["IfcProperties","IfcData","Shape","Proxy","ExpressionEngine","AngularDeflection","BoundingBox"]):
try:
ptype = ctx.getTypeIdOfProperty(prop)
except AttributeError:
@@ -2417,6 +2367,59 @@ def export(exportList,filename):
print("Compression ratio:",int((float(ifcbin.spared)/(s+ifcbin.spared))*100),"%")
del ifcbin
def getIfcRoleFromObj(obj):
if (Draft.getType(obj) == "BuildingPart") and hasattr(obj,"IfcRole") and (obj.IfcRole == "Undefined"):
ifctype = "IfcBuildingStorey" # export BuildingParts as Storeys if their type wasn't explicitly set
elif hasattr(obj,"IfcRole"):
ifctype = obj.IfcRole.replace(" ","")
elif hasattr(obj,"Role"):
ifctype = obj.Role.replace(" ","")
else:
ifctype = Draft.getType(obj)
if ifctype in translationtable.keys():
ifctype = translationtable[ifctype]
if ifctype == "VisGroup":
ifctype = "Group"
return "Ifc" + ifctype
def exportIFC2X3Attributes(obj, kwargs):
role = getIfcRoleFromObj(obj)
if role in ["IfcSlab", "IfcFooting", "IfcRoof"]:
kwargs.update({"PredefinedType": "NOTDEFINED"})
elif role == "IfcBuilding":
kwargs.update({"CompositionType": "ELEMENT"})
elif role == "IfcBuildingStorey":
kwargs.update({"CompositionType": "ELEMENT"})
elif role == "IfcBuildingElementProxy":
kwargs.update({"CompositionType": "ELEMENT"})
elif role == "IfcSpace":
internal = "NOTDEFINED"
if hasattr(obj,"Internal"):
if obj.Internal:
internal = "INTERNAL"
else:
internal = "EXTERNAL"
kwargs.update({"CompositionType": "ELEMENT",
"InteriorOrExteriorSpace": internal,
"ElevationWithFlooring": obj.Shape.BoundBox.ZMin/1000.0})
elif role == "IfcReinforcingBar":
kwargs.update({"NominalDiameter": obj.Diameter.Value,
"BarLength": obj.Length.Value})
elif role == "IfcBuildingStorey":
kwargs.update({"Elevation": obj.Placement.Base.z/1000.0})
return kwargs
def exportIfcAttributes(obj, kwargs):
for property in obj.PropertiesList:
if obj.getGroupOfProperty(property) == "IFC Attributes" and obj.getPropertyByName(property):
value = obj.getPropertyByName(property)
if isinstance(value, FreeCAD.Units.Quantity):
value = float(value)
kwargs.update({ property: value })
return kwargs
def buildAddress(obj,ifcfile):