Material: mat card template for material editor, move to a much more pythonic one

This commit is contained in:
Bernd Hahnebach
2019-04-25 19:47:08 +02:00
parent eb21144c4b
commit f69537ed30
7 changed files with 313 additions and 188 deletions

View File

@@ -22,7 +22,7 @@
import FreeCAD
import Material
from materialtools.cardutils import get_material_template
import os
import sys
if sys.version_info.major >= 3:
@@ -151,17 +151,15 @@ def write(filename, dictionary, write_group_section=True):
# sort the data into sections
contents = []
tree = Material.getMaterialAttributeStructure()
MatPropDict = tree.getroot()
for group in MatPropDict.getchildren():
groupName = group.attrib['Name']
template_data = get_material_template()
for group in template_data:
groupName = list(group.keys())[0] # group dict has only one key
contents.append({"keyname": groupName})
if groupName == "Meta":
header = contents[-1]
elif groupName == "User defined":
elif groupName == 'UserDefined':
user = contents[-1]
for proper in group.getchildren():
properName = proper.attrib['Name']
for properName in group[groupName]:
contents[-1][properName] = ''
for k, i in dictionary.items():
found = False