diff --git a/src/Mod/Arch/ArchComponent.py b/src/Mod/Arch/ArchComponent.py index 0fc0ff8cce..96a6fd9cc3 100644 --- a/src/Mod/Arch/ArchComponent.py +++ b/src/Mod/Arch/ArchComponent.py @@ -25,9 +25,8 @@ __title__="FreeCAD Arch Component" __author__ = "Yorik van Havre" __url__ = "http://www.freecadweb.org" -import FreeCAD,Draft,ArchCommands,math,sys,json,os,ifcopenshell,ArchIFC +import FreeCAD,Draft,ArchCommands,math,sys,json,os,ArchIFC,ArchIFCSchema from FreeCAD import Vector -from ArchIFC import ifcProducts, ifcTypes if FreeCAD.GuiUp: import FreeCADGui from PySide import QtGui,QtCore @@ -48,8 +47,7 @@ else: # This module provides the base Arch component class, that # is shared by all of the Arch BIM objects -# Possible roles for FreeCAD BIM objects -IfcRoles = ['Undefined']+[''.join(map(lambda x: x if x.islower() else " "+x, t[3:]))[1:] for t in ifcProducts.keys()] +IfcRoles = ['Undefined']+[''.join(map(lambda x: x if x.islower() else " "+x, t[3:]))[1:] for t in ArchIFCSchema.IfcProducts.keys()] def convertOldComponents(objs=[]): @@ -1183,10 +1181,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 = ifcTypes.keys() + 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") diff --git a/src/Mod/Arch/ArchIFC.py b/src/Mod/Arch/ArchIFC.py index 0fba391f02..15d025b8d1 100644 --- a/src/Mod/Arch/ArchIFC.py +++ b/src/Mod/Arch/ArchIFC.py @@ -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): diff --git a/src/Mod/Arch/ArchIFCSchema.py b/src/Mod/Arch/ArchIFCSchema.py new file mode 100644 index 0000000000..98eabcde87 --- /dev/null +++ b/src/Mod/Arch/ArchIFCSchema.py @@ -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) diff --git a/src/Mod/Arch/Resources/ui/preferences-arch.ui b/src/Mod/Arch/Resources/ui/preferences-arch.ui index ba6e397315..6db7cad467 100644 --- a/src/Mod/Arch/Resources/ui/preferences-arch.ui +++ b/src/Mod/Arch/Resources/ui/preferences-arch.ui @@ -17,7 +17,16 @@ 6 - + + 9 + + + 9 + + + 9 + + 9 @@ -198,6 +207,69 @@ + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + IFC version + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + The IFC version will change which attributes and products are supported + + + Mod/Arch + + + IfcVersion + + + + IFC4 + + + + + IFC2X3 + + + + + + @@ -690,6 +762,11 @@ QDoubleSpinBox
Gui/PrefWidgets.h
+ + Gui::PrefComboBox + QComboBox +
Gui/PrefWidgets.h
+