4

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!

VOid
  • 43
  • 1
  • 3
  • 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

2 Answers2

2

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: Example

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)>
TLousky
  • 16,043
  • 1
  • 40
  • 72
1

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. enter image description here

Mr.Epic Fail
  • 353
  • 3
  • 7