Get icon_id of image already loaded I'd like to know how i can get the icon_id of an image already loaded.
For exemple, if i use the template "ui_previews_dynamic_enum.py" and i change the directory, there is no problem as long as i don't return in a folder already used to display the icons.
In this case, i've got this message error:

  File "C:\Program Files\Blender Foundation\Blender\2.77\scripts\modules\bpy\utils\previews.py", line 97, in load
  raise KeyError("key %r already exists" % name)


How can i "ask to blender" using the icon_id of the corresponding image if this one already exist ?
i'm not sure without seeing your code ( a github link would be great ). I can make a guess about how you might be able to avoid the KeyError

# ImagePreviewCollection(dict) is a subclass of Python's built-in dict type
main_collection = icon_collection["main"]
icon = main_collection.get(some_key)
if not icon:
    main_collection.load(icon_name, icon_path, 'IMAGE')


I use custom icons in mesh_tiny_cad

If i'm reading bpy/utils/previews.py correctly it isn't possible to overwrite or clear a key/value pair.



If you are keeping track of the IDs somehow then..

if icon_id in [v.icon_id for k, v in pcoll.items()]:
    ...