]> git.tdb.fi Git - libs/gl.git/blob - blender/io_mspgl/export_armature.py
Revise export function parameter orders
[libs/gl.git] / blender / io_mspgl / export_armature.py
1 class ArmatureExporter:
2         def export_to_file(self, context, out_fn):
3                 obj = context.active_object
4
5                 statements = self.export_armature(context, obj)
6
7                 with open(out_fn, "w") as out_file:
8                         for s in statements:
9                                 s.write_to_file(out_file)
10
11         def export_armature(self, obj):
12                 if obj.type!="ARMATURE":
13                         raise Exception("Object is not an armature")
14
15                 from .armature import Armature
16                 armature = Armature(obj.data)
17                 armature.sort_links()
18
19                 from .datafile import Statement
20                 statements = []
21
22                 for l in armature.links:
23                         st = Statement("link", l.name)
24                         st.sub.append(Statement("index", l.index))
25                         if l.parent:
26                                 st.sub.append(Statement("parent", l.parent.name))
27                         st.sub.append(Statement("base", *tuple(l.base)))
28                         statements.append(st)
29
30                 return statements