Count and Find Layers by SQL

Count and Find Layers by SQL
 1# This script shows how to use CountLayers and FindLayers in the "BySQL" mode.
 2
 3ot = impact.gui.output_toolbox
 4ot.clear()
 5
 6count_opts = impact.creator.count_items_options()
 7count_opts.layer_table_context = "ONE_UP"
 8sql = "DRAWINGS.D_NAME like 'poly'"
 9count_opts.sql = sql
10q_count = impact.active_database.count_layers(count_opts)
11ot.add(q_count)
12
13find_opts = impact.creator.find_items_options()
14find_opts.layer_table_context = "ONE_UP"
15find_opts.sql = sql
16find_opts.order_ascending = True
17find_opts.order_by = "DRAWINGS.D_NAME"
18items = impact.active_database.find_layers(find_opts)
19
20for item in items:
21    ot.add("drawing '" + str(item.database_item.reference) + "', layer '" + item.name + "'")
22