English

How To: Return the RGB values for symbols in a theme's legend

Summary

This document provides a sample Avenue script that will create a table containing the labels and RGB values for each classification in the active theme.

Procedure

  1. Open a new script window.

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

  2. Copy the following code into the new script window.

    Code:
    theview = av.getactivedoc
    thetheme = theview.getactivethemes.get(0)
    theleg = thetheme.getlegend.clone

    aFilename =Filedialog.put("rgb.dbf".asFilename, "*.*", "Create Attribute Table")
    thevtab = vtab.makenew(afilename, dbase)

    thelblfld = field.make("AVlabel", #FIELD_CHAR, 20, 0)
    therfld = field.make("R", #FIELD_DECIMAL, 5, 0)
    thegfld = field.make("G", #FIELD_DECIMAL, 5, 0)
    thebfld = field.make("B", #FIELD_DECIMAL, 5, 0)
    thevtab.seteditable(true)
    thevtab.addfields({thelblfld, therfld, thegfld, thebfld})
    thenum = (theleg.getnumclasses - 1)
    for each i in 0..thenum
    thevtab.addrecord
    thelist = theleg.returnclassinfo(i)
    thelbl = thelist.get(0)
    thesym = thelist.get(2)
    thevtab.setvalue(thelblfld, i, thelbl)
    thergblist = thesym.getcolor.getrgblist
    thevtab.setvalue(therfld, i, thergblist.get(0))
    thevtab.setvalue(thegfld, i, thergblist.get(1))
    thevtab.setvalue(thebfld, i, thergblist.get(2))
    end
    thevtab.seteditable(false)
    thetable = table.make(thevtab)
    thetable.getwin.open
    av.purgeobjects

  3. Click the Compile button.
    [O-Image] Script compile button
  4. Make the View and desired Theme active.
  5. Make the Script window active.
  6. Click the Run button.
    [O-Image] Run compiled script button