English

How To: Split a polygon with a polygon using Avenue

Summary

This document provides an Avenue example of how to spilt a polygon feature with a user-defined polygon.

Procedure

  1. Start ArcView.
  2. Open a new script.
    A. Activate the Project window.
    B. Click the Scripts icon.
    C. Click New.
  3. Paste the below Avenue code into the new script.
    Code:
    theView = av.GetActiveDoc 
    theTheme = theView.GetEditableTheme 
    theFTab = theTheme.GetFTab 
    shpFld = theFTab.FindField("Shape") 
    
    thePoly = theView.ReturnUserPolygon 
    if (thePoly.IsNull) then 
      return nil 
      else if (theTheme <> nil) then 
        thePolyLine = PolyLine.Make({thePoly.AsList.Get(0)}) 
        theTheme.SelectByShapes({thePoly},#VTAB_SELTYPE_NEW) 
        theFtab.BeginTransaction 
        for each rec in theFTab.GetSelection 
          p = theFTab.ReturnValue(shpfld, rec) 
          pl = thePolyline.LineIntersection(p) 
            if (pl.CountParts > 1) then 
              pl = pl.ReturnConnected 
            end 
         theTheme.Split(pl) 
        end 
        theFtab.EndTransaction 
        theTheme.Invalidate(true) 
        av.GetProject.SetModified(true) 
      end 
    end
  4. Attach the script to a new tool on the View.
    A. Compile the script.
    B. Make the Project window active.
    C. Select Customize from the Project menu.
    D. Set the Type dropdown to View on the Customize dialog box.
    E. Set the Category dropdown to Tools.
    F. Click Tool.
    G. Double-click the Apply property at the bottom of the Customize dialog box.
    H. Type the name of the script in the Script Manager and click Select.
    I. Close the Customize dialog box.
    Note:
    For more information, refer to the ArcView Help topic "Customize (dialog box)."
  5. Load a polygon shapefile into the View.
  6. From the Theme menu select Start Editing.
  7. Click the new tool.
  8. Draw a polygon.
  9. Double-click to complete the polygon and split the feature.