Count Items By Query¶
Count Items By Query¶
1# This example count database items using a specified query and displays the
2# count in the output toolbox
3
4# Create a local variable for the output toolbox
5ot = impact.gui.output_toolbox
6
7# Clear the output toolbox
8ot.clear()
9
10# Create a local variable for the active database
11db = impact.active_database
12
13# Create a local variable for the name of the query
14query_name = "Contains a"
15
16# Get the query to find items by
17query = db.find_master_tool_setting(query_name, ipMasterSettingType.mstDBQuery)
18
19# Check the query exists
20if query is None:
21
22 # Add a message to the output toolbox
23 ot.add("Unable to find query '" + str(query_name) + "'")
24
25else:
26
27 # Count the database items using the specified query
28 count = db.count_items_by_query2(query)
29 ot.add(count)
30