0
$\begingroup$

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



try:
    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:
    print(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")
try:
    with open(material_folder + mat_export.name+".xml",'r') as f:
        xml_node_tree = parse(f)            
        rna_xml.xml2rna(xml_node_tree,root_rna=mat_import_to,)
except Exception as e:
    print(e)
$\endgroup$

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.