Using python, I'm hoping to serialize a materials node tree, then unserialize it and overwrite another materials node tree.

I'm trying the below, but it's returning errors 'matches no enum in 'FloatProperty', 'dimensions', 'subtype''

import bpy
import json
import rna_xml 

material_folder = 'C:\\Materials\\'
mat_export = bpy.data.materials.get('tester')#name of material in scene I want to copy node tree from.

node_tree = mat_export.node_tree

    with open(material_folder + mat_export.name +".xml",'w') as f:
        rna_xml.rna2xml(fw=f.write,root_node= mat_export.name,root_rna = node_tree)
except Exception as e:

mat_import_to = bpy.data.materials.get('from_tester')#material whose node tree to overwrite
node_tree = mat_import_to.node_tree

#parse the xml file
from xml.dom.minidom import parse
xml_node_tree = parse(material_folder + mat_export.name +".xml")
    with open(material_folder + mat_export.name+".xml",'r') as f:
        xml_node_tree = parse(f)            
except Exception as e:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.