Matrix element access

Hi folks,

How does one assign values to individual elements of a matrix?

I had a script that worked for 2.4x, but is broken in 2.59:


    matrix[3][0] = Points[i][0]
    matrix[3][1] = Points[i][1]
    matrix[3][2] = Points[i][2]
    matrix[3][3] = 1

It fails with the error:
TypeError: ‘NoneType’ object is not callable

If anyone can help with this, I would appreciate it.
Thanks!

Apologies - looks like the problem was with how I initialized the matrix.

This used to work:


     matrix = eulers[i-1].to_matrix().resize_4x4()

Now I have to use:


     matrix = eulers[i-1].to_matrix()
     matrix.resize_4x4()

See here in the Python console of Blender:
>>> from mathutils import Matrix
>>> m = Matrix()
>>> m
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)))

>>> m[0]
Vector((1.0, 0.0, 0.0, 0.0))

>>> m[1]
Vector((0.0, 1.0, 0.0, 0.0))

>>> m[1][3] = ‘Peter’
Traceback (most recent call last):
File “<blender_console>”, line 1, in <module>
TypeError: vector[index] = x: index argument not a number

>>> m[1][3] = 2.71818
>>> m
Matrix(((1.0, 0.0, 0.0, 0.0),
(0.0, 1.0, 0.0, 2.718179941177368),
(0.0, 0.0, 1.0, 0.0),
(0.0, 0.0, 0.0, 1.0)))

don’t forget to look at geometry!
>>> import mathutils
>>> dir(mathutils)
[‘Color’, ‘Euler’, ‘Matrix’, ‘Quaternion’, ‘Vector’, ‘doc’, ‘name’, ‘package’, ‘geometry’]