From 0620caea33f354f9fca8854049ff3e497ef0e4b9 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Sat, 15 Jun 2019 16:53:43 -0300 Subject: [PATCH] Arch: Minor bugfixes, better doctrings and fixed transparency in OBJ exporter --- src/Mod/Arch/ArchIFC.py | 3 +++ src/Mod/Arch/importDAE.py | 5 ++++- src/Mod/Arch/importIFC.py | 4 +++- src/Mod/Arch/importOBJ.py | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Mod/Arch/ArchIFC.py b/src/Mod/Arch/ArchIFC.py index a64a4f65d2..45baa0728c 100644 --- a/src/Mod/Arch/ArchIFC.py +++ b/src/Mod/Arch/ArchIFC.py @@ -45,6 +45,7 @@ def getIfcProduct(IfcType): name = "IfcBuildingElementProxy" if name in ArchIFCSchema.IfcProducts: return ArchIFCSchema.IfcProducts[name] + return None def getIfcProductAttribute(ifcProduct, name): @@ -81,6 +82,8 @@ def addIfcProductAttribute(obj, attribute): "Adds a given attribute property" + if not hasattr(obj,"IfcData"): + return IfcData = obj.IfcData if "attributes" not in IfcData: IfcData["attributes"] = "{}" diff --git a/src/Mod/Arch/importDAE.py b/src/Mod/Arch/importDAE.py index 3574c08696..b5082cce5e 100644 --- a/src/Mod/Arch/importDAE.py +++ b/src/Mod/Arch/importDAE.py @@ -189,7 +189,10 @@ def read(filename): def export(exportList,filename,tessellation=1,colors=None): - "called when freecad exports a file" + """export(exportList,filename,tessellation=1,colors=None) -- exports FreeCAD contents to a DAE file. + colors is an optional dictionary of objName:shapeColorTuple or objName:diffuseColorList elements + to be used in non-GUI mode if you want to be able to export colors. Tessellation is used when breaking + curved surfaces into triangles.""" if not checkCollada(): return p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch") diff --git a/src/Mod/Arch/importIFC.py b/src/Mod/Arch/importIFC.py index 8017494b31..1d85dd052f 100644 --- a/src/Mod/Arch/importIFC.py +++ b/src/Mod/Arch/importIFC.py @@ -1466,7 +1466,9 @@ class recycler: def export(exportList,filename,colors=None): - "exports FreeCAD contents to an IFC file" + """export(exportList,filename,colors=None) -- exports FreeCAD contents to an IFC file. + colors is an optional dictionary of objName:shapeColorTuple or objName:diffuseColorList elements + to be used in non-GUI mode if you want to be able to export colors.""" getPreferences() diff --git a/src/Mod/Arch/importOBJ.py b/src/Mod/Arch/importOBJ.py index 5aaef03621..dde94cc9f6 100644 --- a/src/Mod/Arch/importOBJ.py +++ b/src/Mod/Arch/importOBJ.py @@ -220,7 +220,7 @@ def export(exportList,filename,colors=None): outfile = pythonopen(filenamemtl,"w") outfile.write("# FreeCAD v" + ver[0] + "." + ver[1] + " build" + ver[2] + " Arch module\n") outfile.write("# http://www.freecadweb.org\n") - kinds = {"AmbientColor":"Ka ","DiffuseColor":"Kd ","SpecularColor":"Ks ","EmissiveColor":"Ke ","Transparency":"d "} + kinds = {"AmbientColor":"Ka ","DiffuseColor":"Kd ","SpecularColor":"Ks ","EmissiveColor":"Ke ","Transparency":"Tr "} done = [] # store names to avoid duplicates for mat in materials: if isinstance(mat,tuple):