HOW TO

Create, change, and delete graphic point markers

Last Published: April 25, 2020

Summary

The following examples show how to add, manipulate, and delete graphic points from a view.

Procedure



  • Add a graphic to a view and set its symbol from the symbol palette

    1. Open a new script window.

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


    2. Copy and paste the code into the new window.

    Code:
    '-- Change View1 to match your view if necessary.
    theView = av.getproject.finddoc("View1")

    '-- Change the parameters to a different point if desired.
    thePt = Point.Make(0.5,0.5)
    theGPt = GraphicShape.Make(thePt)

    theSymWin = av.GetSymbolWin
    thePal = theSymWin.GetPalette
    theMarkerPal = thePal.GetList(#PALETTE_LIST_MARKER)

    '-- Change the number if a different symbol is desired.
    theNewSymbol = theMarkerPal.Get(10).Clone
    theNewSymbol.SetColor(color.getblue)
    theNewSymbol.SetSize(36)

    theGPt.SetSymbol(theNewSymbol)

    theView.GetGraphics.Add(theGPt)
    theView.Invalidate

    3. Click the Compile button.
    [O-Image] Script compile button

    4. Click the Run button.
    [O-Image] Run compiled script button
    Note:
    This script uses index numbers to access symbols. If you clear the palette, or modify it, the script may use the wrong symbol. The Marker Palette organizes symbols from left to right and right to bottom; thus, the first row is 0, 1, 2, the next row is 3, 4, 5, and so forth.

  • Change a graphic point's symbol

    To change the symbol a graphic point uses, get the graphic, get the symbol from the graphic, then assign another symbol from the marker palette.

    1. Open another new script window.

    2. Copy the following code into the new window.

    Code:
    theView = av.getproject.finddoc("View1")
    theGraphicList = theView.GetGraphics
    theSymWin = av.GetSymbolWin
    thePal = theSymWin.GetPalette
    theMarkerPal = thePal.GetList(#PALETTE_LIST_MARKER)

    for each g in theGraphicList
    '-- Change the number for a different symbol if desired
    theNewSymbol = theMarkerPal.Get(15).Clone
    theNewSymbol.SetColor(color.getblue)
    theNewSymbol.SetSize(36)
    g.SetSymbol(theNewSymbol)
    end
    theView.Invalidate

    3. Click the Compile button.
    [O-Image] Script compile button

    4. Click the Run button.
    [O-Image] Run compiled script button
  • Delete graphics from a view

    1. Open another new script window.

    2. Copy the following code into the new window.

    Code:
    theView = av.getproject.finddoc("View1")
    theGraphicList = theView.GetGraphics

    For Each g in theGraphicList
    theGraphicList.RemoveGraphic(g)
    End

    theView.Invalidate

    3. Click the Compile button.
    [O-Image] Script compile button

    4. Click the Run button.
    [O-Image] Run compiled script button
    Note:
    The above code will remove all graphic elements from the view. You can modify it to remove only desired graphics.

Article ID:000004176

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