From 91a61d4813aef2dd49ccdf8ed58ef115dffc86ca Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Sat, 29 Dec 2018 14:40:25 -0200 Subject: [PATCH] Material: Fixed py3/import issues --- src/Mod/Material/MaterialEditor.py | 15 +++++++-------- src/Mod/Material/importFCMat.py | 5 ++++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Mod/Material/MaterialEditor.py b/src/Mod/Material/MaterialEditor.py index 33a5d34c72..2fe45e589c 100644 --- a/src/Mod/Material/MaterialEditor.py +++ b/src/Mod/Material/MaterialEditor.py @@ -24,8 +24,6 @@ from __future__ import print_function import FreeCAD import FreeCADGui -from Units import Unit -from Units import Quantity from Material import getMaterialAttributeStructure import os from PySide import QtCore, QtGui @@ -234,10 +232,11 @@ class MaterialEditor: self.getMaterialResources() self.cards = {} for p in self.resources: - for f in os.listdir(p): - b, e = os.path.splitext(f) - if e.upper() == ".FCMAT": - self.cards[b] = p + os.sep + f + if os.path.exists(p): + for f in os.listdir(p): + b, e = os.path.splitext(f) + if e.upper() == ".FCMAT": + self.cards[b] = p + os.sep + f # self.outputCards() if self.cards: self.widget.ComboMaterial.clear() @@ -568,9 +567,9 @@ def matProperWidget(parent=None, Type="String", Units=None, Value=None, widget = ui.createWidget("Gui::InputField") if Units: vv = string2tuple(Units) - unit = Unit(vv[0], vv[1], vv[2], vv[3], + unit = FreeCAD.Units.Unit(vv[0], vv[1], vv[2], vv[3], vv[4], vv[5], vv[6], vv[7]) - quantity = Quantity(1, unit) + quantity = FreeCAD.Units.Quantity(1, unit) widget.setProperty('unit', quantity.getUserPreferred()[2]) elif Type == "Integer": diff --git a/src/Mod/Material/importFCMat.py b/src/Mod/Material/importFCMat.py index 6fcbccf338..5785352944 100644 --- a/src/Mod/Material/importFCMat.py +++ b/src/Mod/Material/importFCMat.py @@ -95,7 +95,10 @@ def read(filename): if not line[0] in ";#[": k = line.split("=") if len(k) == 2: - d[k[0].strip()] = k[1].strip().decode('utf-8') + v = k[1].strip() + if hasattr(v,"decode"): + v = v.decode('utf-8') + d[k[0].strip()] = v l += 1 return d