From 3003f1638949a018596a16e9e8eea7f237e1d94d Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Sun, 3 Apr 2016 13:05:30 -0300 Subject: [PATCH] Arch: fixed wrong storing of IFC uid in FreeCAD objects --- src/Mod/Arch/Resources/ui/preferences-ifc.ui | 33 +++++++++++++++++--- src/Mod/Arch/importIFC.py | 16 ++++++++-- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/Mod/Arch/Resources/ui/preferences-ifc.ui b/src/Mod/Arch/Resources/ui/preferences-ifc.ui index 999058c2d..67fbf6600 100644 --- a/src/Mod/Arch/Resources/ui/preferences-ifc.ui +++ b/src/Mod/Arch/Resources/ui/preferences-ifc.ui @@ -7,7 +7,7 @@ 0 0 456 - 564 + 579 @@ -407,6 +407,29 @@ + + + + + + When exporting objects without UID, the generated UID will be stored inside the FreeCAD object for reuse next time that object is exported, which gives smaller diffs between versions + + + Store IFC universal ID in FreeCAD objects + + + true + + + ifcStoreUid + + + Mod/Arch + + + + + @@ -434,13 +457,13 @@
Gui/PrefWidgets.h
- Gui::PrefLineEdit - QLineEdit + Gui::PrefComboBox + QComboBox
Gui/PrefWidgets.h
- Gui::PrefComboBox - QComboBox + Gui::PrefLineEdit + QLineEdit
Gui/PrefWidgets.h
diff --git a/src/Mod/Arch/importIFC.py b/src/Mod/Arch/importIFC.py index 9c5043f3f..5ac4fe4ea 100644 --- a/src/Mod/Arch/importIFC.py +++ b/src/Mod/Arch/importIFC.py @@ -124,7 +124,7 @@ def getPreferences(): global DEBUG, PREFIX_NUMBERS, SKIP, SEPARATE_OPENINGS global ROOT_ELEMENT, GET_EXTRUSIONS, MERGE_MATERIALS global MERGE_MODE_ARCH, MERGE_MODE_STRUCT, CREATE_CLONES - global FORCE_BREP, IMPORT_PROPERTIES + global FORCE_BREP, IMPORT_PROPERTIES, STORE_UID p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch") if FreeCAD.GuiUp and p.GetBool("ifcShowDialog",False): import FreeCADGui @@ -146,6 +146,7 @@ def getPreferences(): CREATE_CLONES = p.GetBool("ifcCreateClones",True) FORCE_BREP = p.GetBool("ifcExportAsBrep",False) IMPORT_PROPERTIES = p.GetBool("ifcImportProperties",False) + STORE_UID = p.GetBool("ifcStoreUid",True) def explore(filename=None): @@ -262,9 +263,11 @@ def explore(filename=None): t = "Entity #" + str(argvalue.id()) + ": " + str(argvalue.is_a()) elif isinstance(argvalue,list): t = "" + elif isinstance(argvalue,str) or isinstance(argvalue,unicode): + t = argvalue.encode("latin1") else: t = str(argvalue) - t = " " + str(argname) + " : " + str(t) + t = " " + str(argname.encode("utf8")) + " : " + str(t) item = QtGui.QTreeWidgetItem(tree) item.setText(2,str(t)) if colored: @@ -910,6 +913,11 @@ def export(exportList,filename): uid = str(obj.IfcAttributes["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 + d["IfcUID"] = uid + obj.IfcAttributes = d # setting the IFC type + name conversions if hasattr(obj,"Role"): @@ -1142,6 +1150,10 @@ def export(exportList,filename): filename = decode(filename) ifcfile.write(filename) + + if STORE_UID: + # some properties might have been changed + FreeCAD.ActiveDocument.recompute() def getRepresentation(ifcfile,context,obj,forcebrep=False,subtraction=False,tessellation=1):