Well… I made a class
class Matrix:
bones = []
and how to make array out of it? I tried like:
array_of_matrices = Matrix[]
but it doesn’t work ;/
Well… I made a class
class Matrix:
bones = []
and how to make array out of it? I tried like:
array_of_matrices = Matrix[]
but it doesn’t work ;/
the - is used to indent
class Matrix:
—bones = []
#to get bones
Matrix().bones[0]
#to assign that class
bar = Matrix()
bar.bones[0]
bar.bones.append(“this a string being appended to Matrix.bones”)
array_of_matrices = []
for i in xrange(0, number_of_matrices):
array_of_matrices.append(Matrix())
#or one-liner:
array_of_matrices = map(lambda x: Matrix(), xrange(0, number_of_matrices))
#I’m pretty sure there’s a shorter one-liner, but python isn’t keen on TIMTOWTDI-ism.
Well… I don’t understand phaeton stuff. Sutabi was close. But I still don’t know how to make that I can make many matrices
Matrices[10].bones[2] = xxx
array_of_matrices = map(lambda x: Matrix(), xrange(0, number_of_matrices))
translates to
array = [Matrix() for _ in xrange(0, number_of_matrices)] i think.
~Toni
In Python, there isn’t really a concept of “arrays.”
Instead, what you have are (basically) lists and dictionaries.
A “list” is a sequence of “things.” The first thing is at position #0. And a “thing” can be absolutely anything, including another list.
A “dictionary” is a collection of “things,” each one accessed by means of a “key.”
The Python language as used in Blender is exactly the same language that is very-amply described in the Python web-site. Well worth spending some time there…