List of Meshes

Hello,

In an uninformed attempt to generate a list of meshes, I tried…

me = ()
me[0] = Blender.Mesh.New()

…and Python generated the following error message…

TypeError: object does not support item assignment

I need to access several selected object.meshes simultaneously. I’d like these to be referenced as me[0], me[1], etc. Any reasonable solution is welcomed.

Thanks,
Doug

You should read the Python tutorial on lists, dicts and tuples (www.python.org). Tuples like () are immutable and lists like [] must be extended with .append(…). You syntax is correct for dicts but you probably don’t want those here.

Thanks Sjored,

Been there, done that. Have successfully coded lists, dictionaries, key lookups, appends, etc, using Python tutorial as a guide. I can slog through a workaround, but I’m thinking I’m missing something simple. Don’t want to create unnecessary work if a simple definition or assignment will do the trick.

Doug

Sjoerd,

You are correct. I overlooked append. Working code is …

obs = Blender.Object.GetSelected()
me = []
for i in range(len(obs)):
me.append(Blender.Mesh.New())
me[i].getFromObject(obs[0], 0, 0)

Thanks,
Doug

please use the CODE-tag
migius