Remove dependency on ifcopenshell at runtime and introduce new IfcVersion config

This commit is contained in:
Dion Moult
2019-01-29 21:14:35 +11:00
parent 471eb4cad3
commit c9d08b7311
4 changed files with 100 additions and 19 deletions

View File

@@ -1,15 +1,8 @@
import FreeCAD, os, ifcopenshell, json
import FreeCAD, os, json
if FreeCAD.GuiUp:
from PySide.QtCore import QT_TRANSLATE_NOOP
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_" + ifcopenshell.schema_identifier + ".json")) as f:
ifcTypes = json.load(f)
def setProperties(obj):
if not "IfcData" in obj.PropertiesList:
obj.addProperty("App::PropertyMap","IfcData","Component",QT_TRANSLATE_NOOP("App::Property","IFC data"))
@@ -22,9 +15,10 @@ def onChanged(obj, prop):
setObjIfcAttributeValue(obj, prop, obj.getPropertyByName(prop))
def getIfcProduct(IfcRole):
import ArchIFCSchema
name = "Ifc" + IfcRole.replace(" ", "")
if name in ifcProducts:
return ifcProducts[name]
if name in ArchIFCSchema.IfcProducts:
return ArchIFCSchema.IfcProducts[name]
def getIfcProductAttribute(ifcProduct, name):
for attribute in ifcProduct["attributes"]:
@@ -60,7 +54,7 @@ def addIfcProductAttribute(obj, attribute):
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::" + ifcTypes[attribute["type"]]["property"]
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):