English

How To: Return the end point of a polyline via Avenue

Summary

The script in this article demonstrates one way to return the end point of a polyline and draw a graphic point at this location. You can modify this script to meet your needs.

Procedure

  1. Make your view active.
  2. Make sure the polyline theme is the first theme in the Table of Contents.
  3. Select the features of the polyline theme whose points you would like to return.
  4. Open a new script window.

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

  5. Copy the following code into the script window:

    Code:
    aView = av.GetActiveDoc
    aTheme = aView.GetThemes.Get(0)
    aFtab = aTheme.GetFtab
    aShapeField = aFtab.FindField("Shape")
    for each rec in aFtab.GetSelection
    aPolyLine = aFtab.ReturnValue(aShapeField, rec)

    '-- The following line will return a list containing lists of Points

    aPTList = aPolyLine.asList

    '-- Get the list of points from the list containing lists of Points

    aPTList2 = aPTList.Get(0)

    '-- Get the last point in the list of Points,
    '-- which should be the end Point of the Polyline

    aPT = aPTList2.Get(aPTList2.Count -1)

    '-- To return the starting point of the PolyLine, uncomment the
    '-- following line and comment out the previous line

    'aPT = aPTList2.Get(0)

    '-- Create a graphic of the End Point

    aGraphicShape = GraphicShape.Make(aPT)
    aView.GetGraphics.Add(aGraphicShape)
    end
    aView.Invalidate

  6. Click the
    [O-Image] Script compile button
    button to compile the script.
  7. Click the
    [O-Image] Run compiled script button
    button to run the script.