I want to manage a list of image in a collection, but I need to search the image in bpy.images.data, but is a Panel class, so it make a lot of refresh. I've create a ID prop to bpy.type.Image, so each image ave a unique ID wich I assign in other process. The collections prop have the ID of the image, bat the only way is to make a for:

name = "no image"
images = bpy.data.images
if bpy.context.scene.paintPBR_index > -1:
    for img in images:
        if img.id_pbrpainter == layer.image_ID and img.id_pbrpainter != 0:
            name = img.name

    return name

There is a way to search the image in bpy.data.images by the custom prop?

  • $\begingroup$ Can you expand on the code, The code you posted will only return the name of the last matching image. Later versions of blender allow an object reference to be saved in a groupproperty, could be useful in this case, I think. $\endgroup$ – batFINGER Oct 8 '17 at 14:41
  • $\begingroup$ Are you saying about the 2.8? $\endgroup$ – Alfonso Annarumma Oct 19 '17 at 12:28
  • $\begingroup$ Available in 2.79 The example here uses bpy.types.Object whereas you would use image type. $\endgroup$ – batFINGER Oct 19 '17 at 16:07

Your Answer

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

Browse other questions tagged or ask your own question.