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
6CountOpts = impact.creator.count_items_options()
7CountOpts.layer_table_context = "ONE_UP"
8SQL = "DRAWINGS.D_NAME like 'poly'"
9CountOpts.sql = SQL
10q_count = impact.active_database.count_layers(CountOpts)
11ot.add(q_count)
12
13FindOpts = impact.creator.find_items_options()
14FindOpts.layer_table_context = "ONE_UP"
15FindOpts.sql = SQL
16FindOpts.order_ascending = True
17FindOpts.order_by = "DRAWINGS.D_NAME"
18items = impact.active_database.find_layers(FindOpts)
19
20for item in items:
21 ot.add("drawing '" + str(item.database_item.reference) + "', layer '" + item.name + "'")
22