How To: Apply a Theme Definition Query using Avenue
You can limit which records of a dataset are present as features in a theme
by applying a Theme Definition Query. This article demonstrates how to apply a theme definition for the ESRI sample data counties.shp so that only Ohio counties are present. For more information refer to the ArcView Help topic "Defining a feature selection for a theme."
- Open a new script window. A. Activate the Project window.
B. Click the Scripts icon.
C. Click New.
- Paste the following code into the new script window:
'-- Creating a new theme from a feature source:
theView = av.GetActiveDoc
'-- Replace the path to match your feature data source
theTheme = Theme.Make("c:\esri\esridata\usa\counties.shp".AsSrcName)
theFTab = theTheme.GetFTab
'-- Example of using a string field for query
SearchStr = MsgBox.Input("Enter the Search String:",
"Input Window", "Ohio")
theQuery = "[State_Name] = " + SearchStr.Quote
'-- Example of using a numeric field for query
'theFTab.SetDefinition("[Fips] = 2336")
The path to the counties shapefile referenced in the second line of code may differ from the path on your machine. Edit this path to match the sample data directory on your machine or to point to another data set.
- Attach the script to a button on the View GUI. A. Compile the script.
B. Switch to the Project window.
C. Select Customize from the Project menu.
D. On the Customize dialog box, click the Type dropdown arrow and click View.
E. Select Buttons under Category.
F. Click the New button.
G. Double-click the Click property in the Customize dialog box.
H. Type the name of the script in the Script Manager and click Select.
I. Close the Customize dialog box.
For more information, see "Customize dialog box" in ArcView Help.
- Open a view and click the new button.
- Type in the name of a state and click OK.