what I woud do is to select a different image in the UV/Image editor from the ones already opened depending on the selected object in the 3d view. http://img96.imageshack.us/img96/2955/myprob.jpg I wanted to know if there is a command in the api to select a different image. Being in the right context or not wouldn’t matter, it could also be accessed through the space-bar search menu. Not related: since 2.62 increased the maximum objects’ name lenght i started using longer ones. Is it a bug bpy.ops.object.select_pattern(pattern=‘objectname’) doesn’t work with names longer than 32 characters?
nvm found it.
For others who look for this information: The method above depends on how the user has setup the screens in Blender. In some scenes UV/Image Editor might be in index “2” of screens, on other scenes it might not. User could even have a scene where the UV editor is not open at all.
In object mode, one can assign textures properly like this:
>>> for ii, i in enumerate(bpy.context.object.data.uv_textures.active.data): ... if ii % 2 == 0: ... i.image = bpy.data.images['my_texture_2.dds']
This example sets the texture of every other face to the image “my_texture_2.dds”, which was previously imported (using the current object)
Is it a bug bpy.ops.object.select_pattern(pattern=‘objectname’ ) doesn’t work with names longer than 32 characters?
It is, reported and fixed in SVN. You can fix it yourself for your current installation if you want:
Go to Blender folder
Navigate to \2.63\scripts\startup\bl_operators
Open object.py in text editor
Search for maxlen=32
Replace by maxlen=63
Save and restart blender