HOW TO

Get RGB values for colors in the palette

Last Published: April 25, 2020

Summary

Knowing the RGB values can be important for recreating these colors in other applications, such as ArcIMS.

Procedure

You can return the RGB values of colors in the ArcView color palette by running the following script.

  1. Open a new script window.

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

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

    Code:
    '-- This script dumps colors from palette to layout
    '-- RGB values are listed below each color.

    thePalette = av.GetSymbolWin.GetPalette
    symType = "color"
    thePaletteList = thePalette.GetList(#PALETTE_LIST_COLOR)
    numPages = (thePaletteList.Count / 60).Ceiling
    pageCount = 0
    symNum = 0
    MakeNewPage = true
    xp = 0
    While (pageCount < numPages)
    if (MakeNewPage) then
    theLayout = Layout.Make
    pageCount = pageCount + 1
    end
    MakeNewPage = false
    theLayout.GetWin.open
    theLayout.SetName(symType.UCase+((pageCount).AsString))
    dis = theLayout.GetDisplay
    dis.SetPageSize(8.5@11)
    dis.SetMarginVisible(FALSE)
    gl = theLayout.GetGraphics

    '-- Make a bounding box
    boundX = (750 - (8.50 / 2))
    boundY = (750 + (11.00 / 2))
    bboundX = (750 + (8.50 / 2))
    bboundY = (750 - (11.00 / 2))
    boundBox = Rect.MakeXY(boundX, boundY, bboundX, BBoundY)
    gBoundBox = GraphicShape.Make(boundBox)
    gl.AddBatch(gboundBox)

    '-- Make framing box
    topX = (750 - (8.50 / 2)) + 0.50
    topY = (750 + (11.00 / 2)) - 0.50
    botX = (750 + (8.50 / 2)) - 0.50
    botY = (750 - (11.00 / 2)) + 0.50
    box = Rect.MakeXY(topX, topY, botX, botY)
    gbox = GraphicShape.Make(box)
    gl.AddBatch(gbox)
    dx = 1.25 'X distance change
    dy = 0.99 'Y distance change
    originX = 750 - (8.50 / 2)
    originY = 750 + (11.00 / 2)
    x = originX + 0.75
    y = originY - 1.3
    tX = x + 3.0
    tY = originY - 0.75
    tPt = (tX@tY)
    gtPt = GraphicText.Make(symType+"s", tPt)
    gl.AddBatch(gtPt)

    '-- Create rectangle
    xMin = x
    yMin = y
    xMax = x + 0.75
    yMax = y + 0.5
    r = Rect.MakeXY(xMin, yMin, xMax, yMax)
    gr = GraphicShape.Make(r)
    if (symType = "COLOR") then
    for each ROW in 1..10
    for each COLUMN in 0..5
    nextRec = gr.Clone
    nextRec.SetSymbol(av.GetSymbolWin.GetPalette.GetList(#PALETTE_LIST_FILL).Get(1).Clone)
    nextRec.GetSymbol.SetColor(thePaletteList.GET(symNum).Clone)
    rgb = nextrec.getsymbol.getcolor.getrgblist
    r = "R "+rgb.get(0).asstring
    g = "G "+rgb.get(1).asstring
    b = "B "+rgb.get(2).asstring
    offsetPt = (x@y)
    nextRec.setOrigin(offsetPt)
    pt = offsetPt + (0@0) - (0@0.25)
    t = GraphicText.Make(r++g++b, pt)
    ts = textsymbol.make
    ts.setsize(9)
    t.setsymbol(ts)
    gl.UnselectAll
    theLayout.GetGraphics.AddBatch(nextRec)
    theLayout.GetGraphics.AddBatch(t)
    x = x + dx
    symNum = symNum + 1
    if (symNum = thePaletteList.Count) then exit end
    end 'for each COLUMN
    x = originX + 0.75
    y = y - dy
    end 'for each ROW
    if (symNum < ((thePaletteList.Count) - 1) ) then
    MakeNewPage = true
    end
    end '-- Per Page
    end '-- While
    gl.UnSelectAll
    av.GetProject.SetModified(true)
    gl.EndBatch

  3. Compile and run the script.

    A new layout is created with all the colors in the current color palette. The RGB values are listed below each color.

Article ID:000002601

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