class ArmatureExporter:
- def export(self, context, out_file):
- obj = context.active_object
+ def export_armature(self, obj):
if obj.type!="ARMATURE":
- raise Exception("Can only export Armature data")
+ raise ValueError("Object {} is not an armature".format(obj))
from .armature import Armature
-
armature = Armature(obj.data)
armature.sort_links()
- from .outfile import open_outfile
- out_file = open_outfile(out_file)
+ from .datafile import Statement
+ statements = []
for l in armature.links:
- out_file.begin("link", '"{}"'.format(l.name))
- out_file.write("index", l.index)
+ st = Statement("link", l.name)
+ st.sub.append(Statement("index", l.index))
if l.parent:
- out_file.write("parent", '"{}"'.format(l.parent.name))
- out_file.write("base", *tuple(l.base))
- out_file.end()
+ st.sub.append(Statement("parent", l.parent.name))
+ st.sub.append(Statement("base", *tuple(l.base)))
+ statements.append(st)
+
+ return statements