' ********************************************************** ' UnionAll.AVE ' ' Unions all polygons of the theme. ' ' Written by Tim Thomas on 12/10/01. ' ' Used ideas from the following: ' Find Gaps and Overlaps ' Author: David M. Theobald, davet@nrel.colostate.edu ' Date: August 1999 ' ************************************************************ theView = av.GetActiveDoc theActiveTheme = theView.GetActiveThemes.Get(0) theFTab = theActiveTheme.GetFTab theshapeFld = theFTab.FindField ( "Shape" ) ' ************************************************************ ' Make new shapefile ' ************************************************************ FTabFN = theFTab.GetSrcName.GetFileName baseString = FTabFN.GetBaseName extString = FTabFN.GetExtension newString = FTabFN.AsString.Substitute(baseString,"") new2String = baseString.Substitute(extString,"shp") newFTabFN = FileDialog.Put( (newString + "Union " + new2String).AsFileName, "*.shp","Union shapefile name") newFTab = FTab.MakeNew(newFTabFN,Polygon) newShapeField = newFTab.FindField("Shape") idField = Field.Make ("UnionID", #FIELD_BYTE, 2, 0) newFTab.AddFields ( { idField } ) ' Union all polygons theUnion = theFTab.ReturnValue ( theshapeFld, 0 ) for each rec in theFTab thePoly = theFTab.ReturnValue ( theshapeFld, rec ) theUnion = thePoly.ReturnUnion(theUnion) end rec = newFTab.AddRecord newFTab.SetValue ( newShapeField, rec, theUnion ) newFTab.SetValue ( idField, rec, 1) newFTab.SetEditable ( FALSE ) newFTheme = FTheme.Make ( newFTab ) theView.AddTheme ( newFTheme )