English

How To: Move points across a map without leaving a symbol trail

Summary

When you animate point features in ArcView using Avenue, a trail of symbols may be left along the path. This document discusses how to animate point feature without leaving a trail and without the need to refresh the entire screen; only the area where the point is moving gets refreshed.

The example scripts below assume you have an editab;le point theme with only one feature in a view titled View1. The point theme must be the first active theme in the view.

Procedure

Use the InvalidateRect request to refresh only a portion of the view extent. The sample scripts below demonstrates how to incorporate this request into a animation script.

  1. Open a new script.

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

  2. Paste the following code into the new script.

    Code:
    '-- Sample Script #1 "Sscript1"
    '
    '-- Get the view, display, theme, editable FTab, and shape field
    theView = av.FindDoc("View1")
    theDisplay = theView.GetDisplay
    theTheme = theView.getactivethemes.Get(0)
    theFTab = theTheme.GetFTab
    theFTab.SetEditable(true)
    shpFld = theFTab.FindField("Shape")
    '
    '-- Get the current point location
    pt = theFTab.ReturnValue(shpFld,0)
    '
    '-- Make a rectangle that surrounds the current point's marker symbol

    '-- You may need to adjust these numbers
    origExt = Rect.Make((pt.GetX - 2) @ (pt.GetY - 2), 4@4)
    '
    '-- Increment the location of the poiont.
    '-- In this case the point is moved 1.4 coverage units to the Northeast
    pt = pt + (1@1) '1 unit north, 1 unit east = 1.4 units northeast
    '
    '-- Give the theme's FTab this new point location
    theFTab.SetValue(shpFld,0,pt)
    '
    '-- Stop editing the FTab and write it to disk
    theFTab.SetEditable(false)
    theFTab.Flush
    '
    '-- Make a rectangle that surrounds the new point's marker symbol

    '-- You may need to adjust these numbers
    newExt = Rect.Make((pt.GetX - 2) @ (pt.GetY - 2), 4@4)
    '
    '-- Calculate the portion of the view you want to re-draw

    '-- Do a union of the original point's symbol extent with the new point's symbol
    invRect = origExt.UnionWith(newRect)
    '
    '-- Re-draw the view only within the re-draw area
    theDisplay.InvalidateRect(invExt)
    '
    '-- Wait 2 seconds and run Script2
    av.delayedrun("Script2",nil,2)
    '
    '-- End of Script1

  3. Make sure the name of the script window is Script1.

    A. Select Properties from the Script menu.
    B. Type in a new name in the Name field.
    C. Click OK.

  4. Open a new script.
  5. Paste the following code into the second new script.

    Code:
    '-- Sample Script #2 "Sscript2"
    '
    '-- Run Script1
    av.Run("Script1",nil)
    '
    '-- End of Script2


  6. Make sure the name of the second script window is Script2.
  7. Compile both scripts.
  8. Run Script1.