X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=blender%2Fio_mspgl%2Fexport_armature.py;h=c2ec67125f64c93f49322a5bbbb3e71bde68e485;hp=f3f18c8adcb1c8f2cf1c2e20bfb93535012c1cd2;hb=6ee541f;hpb=04c89988c7eda12ea763a9283df0aeba177a11ad diff --git a/blender/io_mspgl/export_armature.py b/blender/io_mspgl/export_armature.py index f3f18c8a..c2ec6712 100644 --- a/blender/io_mspgl/export_armature.py +++ b/blender/io_mspgl/export_armature.py @@ -1,21 +1,30 @@ class ArmatureExporter: - def export(self, context, out_file): + def export_to_file(self, context, out_fn): obj = context.active_object + + statements = self.export_armature(context, obj) + + with open(out_fn, "w") as out_file: + for s in statements: + s.write_to_file(out_file) + + def export_armature(self, obj): if obj.type!="ARMATURE": - raise Exception("Can only export Armature data") + raise Exception("Object is not an armature") 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