HOW TO

Apply a Theme Definition Query using Avenue

Last Published: April 25, 2020

Summary

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."

Procedure



  1. Open a new script window.

    A. Activate the Project window.
    B. Click the Scripts icon.
    C. Click New.

  2. Paste the following code into the new script window:

    Code:
    '-- 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)
    theTheme.SetName("Ohio Counties")
    theView.AddTheme(theTheme)
    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
    theFTab.SetDefinition(theQuery)

    '-- Example of using a numeric field for query
    'theFTab.SetDefinition("[Fips] = 2336")
    theTheme.SetVisible(true)
    theTheme.SetActive(true)


    Note:
    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.

  3. 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.

  4. Open a view and click the new button.
  5. Type in the name of a state and click OK.

Article ID:000003919

Software:
  • Legacy Products

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic