0
$\begingroup$

So i have these variables that search for the active object's coordinates.

obj = bpy.context.scene.objects.active

Xrot = obj.rotation_euler.x
Yrot = obj.rotation_euler.x
Zrot = obj.rotation_euler.x

eul = mathutils.Euler((Xrot, float(Yrot), Zrot), 'XYZ') # <--- Does not print coordinates

mat_rot = eul.to_matrix() #Convert rotations to matrix

mat = mat_rot.to_4x4() #Lets turn this into a grid!

print(mat)

However the "eul' variable does not read out the coordinates. If I also try using float on the Xrot for Zrot variables then i will get a "too many arguments" error.

I've attempted to use "int" aswell but no luck.

$\endgroup$
  • 1
    $\begingroup$ SImpler to use mat_rot = obj.rotation_euler.to_matrix() (assuming you dont want to set each to the x rotation) $\endgroup$ – batFINGER Nov 18 '17 at 3:14
0
$\begingroup$

Your script is fine, i just tested and it work as expected. The problem maybe is that you are looking in the python interactive console, but you need to look in the system console.

python interactive console after run script:

enter image description here

System console after run script:

enter image description here

If you are in GNU/Linux os look in the terminal or run blender from a terminal.

In Windows got to: Window>Toggle System console:

enter image description here

mat_rot = eul.to_matrix() #Convert rotations to matrix

mat = mat_rot.to_4x4() #Lets turn this into a grid!

print(mat)
print(mat[0])
print(mat[0][0])

enter image description here

$\endgroup$
  • $\begingroup$ Yeah I did have it open but it would oddly give me the default coordinates like you have at the very top, first 4x4 one. As one comment suggested to try: mat_rot = obj.rotation_euler.to_matrix() which works fine now. All i need left is to figure out printing a single value from a row. $\endgroup$ – nathan miller Nov 18 '17 at 13:59
  • $\begingroup$ Sorry my english comprehension make me dificult to understand. but if you want a single value from mat_rot = obj.rotation_euler.to_matrix() use mat_rot[row][colum] that will give you a single value. $\endgroup$ – Strapicarus Nov 18 '17 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.