I was wondering if there was a method for getting at the 3D View’s background image in Python. I dug around a bit in the API docs and tried poking things in Python, but I haven’t found anything useful. I can get at the Image object, but I can’t get at the properties associated with it (i.e. the screen position and size).
My goal is to allow for a separate image in each of the views (top, bottom, left, right, etc). Besides just changing the image, I would want to be able to set up the position and size of the image for each view separately as well.
I considered modifying the Blender source, but I would rather not spend that much time on it.
Hi!
Well, that was in 2006; nowadays I see, in the Blender Python API, references to
BackgroundImage(bpy_struct) and SpaceView3D.background_images ,
but I cannot find the right enchantment to pick out the one (or, the first) background image in a .blend file:
heelp, pleease! :o
P.S. with e.g.
MyImage = bpy.data.images[0]
I do get the background image, if it is the only (or, the first)
image in the .blend file, and I can loop through all the images,
but, how do I know if an image is being used as a background?
import bpy
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
space_data = area.spaces.active
bg = space_data.background_images[0]
print(repr(bg.image))
break