How can an Image-Empty be done with Python?

And how to set an image file on it? Object.data is None for empties, and there is no .image property on the object level either.


An Empty is created like a regular Object, but with None for its data:

empty = bpy.data.objects.new("My Empty", None)

It can be linked to the current Scene like any other object:

scene = bpy.context.scene

The origin is set using the standard .location property (you may also use .matrix_world.translation):

empty.location = (1, 2, 3)

To make this Empty an Image-Empty, change its .empty_draw_type property to IMAGE:

empty.empty_draw_type = 'IMAGE'

An Image datablock is then assigned to the Object's .data attribute!

img = bpy.data.images.load("path/to/image.png")
empty.data = img

Other properties available for Image-Empties are (UI / Python):

  • Transparency / Object.color[3]
  • Image Offset / Object.empty_image_offset
  • Image Size / Object.empty_draw_size

BTW: You can change the RGB colors (.color[0:3]) of the object to tint the Image, which is not possible via the interface!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.