# Export model transformation matrix

I am a very basic blender user, I need to know if there is a add-on or a built in function that could export selected objects model transformation matrix (the matrix that contains the models scaling, rotation and translation information).

Thanks!

• What do you mean by export? To where or in what format? This would be a pretty easy thing to do using a python script, but you need to be more specific about how you need the matrix to be represented and exported. – TLousky Sep 28 '15 at 20:38
• For example a text file, any format would be fine. – VOid Sep 28 '15 at 20:48

Alrighty, then this script creates a text file with the transform matrix [see answer here to understand blender's transform matrix format] of the active object as it is represented in blender. Just copy and paste it into a text editor window in Blender, save your blendfile where you want your text file to be created, and run the script:

import bpy
from os.path import dirname, join

if bpy.context.object and bpy.data.filepath:
fname = bpy.context.object.name + ".matrix"
fpath = join( dirname( bpy.data.filepath ),  fname )

f = open( fpath, "w" )
f.write( str( bpy.context.object.matrix_world ) )
f.close()


Example:

For this transformed cube with the following transform values:

You get this result in the generated textfile:

<Matrix 4x4 ( 0.6416, 0.2411,  0.7263, -0.8912)
(-0.8174, 0.1801, -1.0416, -2.1409)
(-0.8864, 0.0084,  1.4863,  3.1665)
( 0.0000, 0.0000,  0.0000,  1.0000)>


There is this Blender add-on, that allows you to extract transformation matrices from objects and write them on disc.

It also allows you to apply transformation matrices to object - for instance by loading them from disc.

Here is a screen shot of the GUI elements added by the add-on.