Saving thumbnails (Python)¶
Saving thumbnails (Python)¶
1# This example shows how to save drawing and layer thumbnail images for the active drawing
2# For layers the optional LAYERS.L_THUMB picture column should be defined in the database otherwise
3# retrieving multiple layer previews for the same project will be slow
4impact.gui.output_toolbox.clear()
5
6if not impact.active_drawing.isNone():
7
8 d = impact.active_drawing
9 dbItem = d.database_item
10
11 if dbItem.save_thumbnail_to_file("e:\temp\\drawing" + dbItem.key + ".jpg", ipFileFormat.ffJPG, True):
12 impact.gui.output_toolbox.add("Saved drawing preview '" + dbItem.reference + "'")
13 else:
14 impact.gui.output_toolbox.add("Unable to save drawing preview")
15
16 for l in dbItem.layers:
17 if l.save_thumbnail_to_file("e:\temp\\layer " + l.key + ".jpg", ipFileFormat.ffJPG, True):
18 impact.gui.output_toolbox.add("Saved layer preview for '" + l.name + "'")
19 else:
20 impact.gui.output_toolbox.add("Unable to save layer preview")
21else:
22 impact.gui.output_toolbox.add("No active drawing")