Пример #1
0
def main():
    filename = os.path.splitext(bpy.data.filepath)[0] + ".xml"

    file = open(filename, 'w')

    if 1:
        # blend file
        rna_xml.rna2xml(file.write,
                        root_rna=bpy.data,
                        root_rna_skip={"window_managers"})
    else:
        # theme. just another test
        rna_xml.rna2xml(file.write,
                        root_rna=bpy.context.user_preferences.themes[0],
                        method='ATTR')

        file.close()

    # read back to ensure this is valid!
    from xml.dom.minidom import parse
    xml_nodes = parse(filename)
    print("Written:", filename)

    # test reading back theme
    if 1:
        theme = xml_nodes.getElementsByTagName("Theme")[0]
        rna_xml.xml2rna(
            theme,
            root_rna=bpy.context.user_preferences.themes[0],
        )
Пример #2
0
def main():
    filename = os.path.splitext(bpy.data.filepath)[0] + ".xml"

    file = open(filename, 'w')

    if 0:
        # blend file
        rna_xml.rna2xml(file.write,
                        root_rna=bpy.data,
                        root_rna_skip={"window_managers"})
    else:
        # theme. just another test
        rna_xml.rna2xml(file.write,
                        root_rna=bpy.context.user_preferences.themes[0],
                        method='ATTR')

        file.close()

    # read back to ensure this is valid!
    from xml.dom.minidom import parse
    xml_nodes = parse(filename)
    print("Written:", filename)

    # test reading back theme
    if 1:
        theme = xml_nodes.getElementsByTagName("Theme")[0]
        rna_xml.xml2rna(theme,
                        root_rna=bpy.context.user_preferences.themes[0],)
# Script to load and run from Blender

import bpy, rna_xml, prep_rna
import xml.dom.minidom as minidom

# Ensure a sequence_editor object is present (this object is created only when a first strip is added to the sequencer)
if not bpy.data.scenes[0].sequence_editor:
    bpy.data.scenes[0].sequence_editor_create()

# Parsing
fhandle = open("xmlol2.xml", "r")
xmldoc = minidom.parse(fhandle)
fhandle.close()


# Ensure the root node of the provided XML file is of type SequencerEditor
sequence_editorNode = xmldoc.documentElement
if sequence_editorNode.nodeName != "SequenceEditor":
    raise Exception("Incorrect root node type")

# prep_rna("node element with name SequenceEditor", "scene to add to", "frame to add at")
prep_rna.prep_rna(sequence_editorNode)

# xml2rna
rna_xml.xml2rna(sequence_editorNode, bpy.data.scenes[0].sequence_editor)
Пример #4
0
# Script to load and run from Blender

import bpy, rna_xml, prep_rna
import xml.dom.minidom as minidom

# Ensure a sequence_editor object is present (this object is created only when a first strip is added to the sequencer)
if not bpy.data.scenes[0].sequence_editor:
    bpy.data.scenes[0].sequence_editor_create()

# Parsing
fhandle = open("xmlol2.xml", 'r')
xmldoc = minidom.parse(fhandle)
fhandle.close()

# Ensure the root node of the provided XML file is of type SequencerEditor
sequence_editorNode = xmldoc.documentElement
if sequence_editorNode.nodeName != 'SequenceEditor':
    raise Exception('Incorrect root node type')

# prep_rna("node element with name SequenceEditor", "scene to add to", "frame to add at")
prep_rna.prep_rna(sequence_editorNode)

# xml2rna
rna_xml.xml2rna(sequence_editorNode, bpy.data.scenes[0].sequence_editor)