English

How To: Load a legend file using a different field name

Summary

You can use Avenue to apply a legend file (*.avl) to a theme that has a field with a different name referenced by the legend file.

Procedure

Use the following syntax to redefine the field name for a legend file and load the legend:

  1. Open a new script window.

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

  2. Copy the following script into the new window:

    Code:
    aview = av.getactivedoc
    atheme = aview.getthemes.get(0)
    alegend = atheme.getlegend
    afldname = atheme.getftab.findfield("area")
    alegend.load( "legend1.avl".asfilename,#LEGEND_LOADTYPE_ALL)
    alegend.setfieldnames({afldname})
    atheme.updatelegend


    Note:
    You must edit the script to specify the full path to the legend file.

  3. Click the Compile button.
    [O-Image] Script compile button
  4. 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.

  5. Open the View and make the theme active.
  6. Click the new button to run the script.