English

How To: Assign a symbol to a graphics in a view using Avenue

Summary

When you assign a symbol to a graphic, it is important you select the appropriate symbol type for the graphic type. If you select the wrong symbol type, you may get error messages.

This script below demonstrates how to check the graphic type before assigning a symbol.

Procedure

  1. Open a New Script window.
  2. Copy and paste this code.

    Code:
    '-- Get the GraphicList from the active view document
    theView = av.GetActiveDoc
    theGList = theView.GetGraphics

    '-- Create a BasicMarker symbol type
    aBasicMarker = BasicMarker.Make
    aBasicMarker.SetColor(Color.GetRed)

    '-- Create a TextSymbol symbol type
    aTextSymbol = TextSymbol.Make
    aTextSymbol.SetSize(24)

    '-- Cycle through the GraphicList
    '-- If it is a GraphicShape of type point, set symbol to aBasicMarker
    '-- If it is a GraphicText, set symbol to aTextSymbol

    for each g in theGList
    If (g.is(GraphicShape)) Then
    If (g.GetShape.Is(Point)) Then
    g.SetSymbol(aBasicMarker)
    End
    ElseIf (g.Is(GraphicText)) then
    g.SetSymbol(aTextSymbol)
    End
    End

    theView.Invalidate

  3. Compile the script and run it.

    Note:
    For additional properties you can set for each symbol type, see the Symbol(Class) topic in ArcView Help.