I created a custom property group with a list of strings (populated with the name of image textures). How do I compare the list of textures in my scene to this custom property list?
import bpy
class CustomPropertiesGroup(bpy.types.PropertyGroup):
customString: bpy.props.StringProperty()
bpy.utils.register_class(CustomPropertiesGroup)
bpy.types.Scene.customLists = bpy.props.CollectionProperty(type=CustomPropertiesGroup)
bpy.context.scene.customLists.clear()
# Filling up the custom list with the texture names
for m in bpy.data.images:
if len(m.filepath) != 0:
newCustomItem = bpy.context.scene.customLists.add()
newCustomItem.customString = m.name
Later in the code I would like to modify the texture path of those textures which are on my list but I don't know how to iterate over the scene textures and over the custom list at the same time to see if there is a match. This code below doesn't work as it only has the last item in the custom list and therefore it's only true for that last item:
for m in bpy.data.images:
if m.name in customPropertyGroup.customString:
print("Something...")
How can I compare the actual m.name to all of the items in the custom list?
if m.name in [pg.customString for pg in bpy.context.scene.customLists]:
? It's called a list comprehension if you want to look it up :) $\endgroup$