Easy way to format mathutils.Matrix Vector as tuple (or list) for json? Hi I am currently making simple pose preset system with json for specific Armatures. It just discribe non driven bone matrix as json (export), then import and apply for pose bones when there is same name bone in context armature.
Then is there good format function which convert blender Matrix or Vector as tupul for json?
when I get Matrix of bones, bpy return like this
'''Matrix(((1.0, 0.0, 0.0, 0.0),
(0.0, 1.0, 0.0, 0.0),
(0.0, 0.0, 1.0, 0.0),
(0.0, 0.0, 0.0, 1.0)))'''
then,,  mat_z[0] rerturn Vector
Vector((1.0, 0.0, 0.0, 0.0))
I know, I can divide each component, then compose as tupul, for each 4*4 element, (or make function which convert matrix avlue as tupul,) But I think if I miss easy step which bpy or python already offered?
or python json module auto format them without convert tupul? (Though I do not suppose so)
List comprehension
Can be done with list comprehension to work with any M x N matrix
Example below, as a list of rows and a list of columns.
&gt;&gt;&gt; M = Matrix.Translation((1, 2, 4))

&gt;&gt;&gt; M
Matrix(((1.0, 0.0, 0.0, 1.0),
        (0.0, 1.0, 0.0, 2.0),
        (0.0, 0.0, 1.0, 4.0),
        (0.0, 0.0, 0.0, 1.0)))

&gt;&gt;&gt; [list(row) for row in M]
[[1.0, 0.0, 0.0, 1.0], [0.0, 1.0, 0.0, 2.0], [0.0, 0.0, 1.0, 4.0], [0.0, 0.0, 0.0, 1.0]]

&gt;&gt;&gt; [list(col) for col in M.col]
[[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [1.0, 2.0, 4.0, 1.0]]