Iterating ThumbnailGenerators (Python)

Iterating ThumbnailGenerators (Python)
 1ot = impact.gui.output_toolbox
 2db = impact.active_database
 3
 4ot.clear()
 5docs = db.documents
 6
 7if docs.isNone():
 8    ot.add("No document support in the database")
 9else:
10    ot.add("Document support is enabled in this database")
11    docSettings = db.settings.document_settings
12    thumbnailGenerators = docSettings.thumbnail_generators
13
14    ot.add("Installed Thumbnail Generators: " + thumbnailGenerators.count)
15
16    for i in range(1, thumbnailGenerators.count + 1):
17        thumbnailGenerator = None
18        try:
19            thumbnailGenerator = thumbnailGenerators.item(i)
20        except Exception as exc:
21            pass
22        impact.gui.output_toolbox.add(f"Failed to create object via thumbnail_generators.item(): {exc}")
23
24        ot.add("  ThumbnailGeneratorKey: " + thumbnailGenerator.key)
25        ot.add("    Extender: " + thumbnailGenerator.extender.name)
26    thumbnailGenerator = None
27    try:
28        thumbnailGenerator = thumbnailGenerators.item("impact:image")
29    except Exception as exc:
30        pass
31    impact.gui.output_toolbox.add(f"Failed to create object via thumbnail_generators.item(): {exc}")
32
33    if thumbnailGenerator.isNone():
34        ot.add("Unable to find thumbnail generator by key")
35    else:
36        ot.add("Found " + thumbnailGenerator.key + " thumbnail generator by key")