/3.1 (Extension.1 Name: "Vector Transformations 1.0" FirstRootClassName: "List" Roots: 2 Roots: 3 Roots: 4 Roots: 89 Roots: 90 Roots: 91 Roots: 92 Roots: 93 Roots: 94 Roots: 95 Roots: 96 Roots: 97 Roots: 98 Roots: 99 Roots: 100 Roots: 101 Version: 31 About: "Utility tools for point, polyline and polygon transformations and management" InstallScript: 102 UninstallScript: 103 ExtVersion: 1 ) (List.2 ) (List.3 ) (List.4 Child: 5 Child: 12 Child: 19 Child: 26 Child: 33 Child: 40 Child: 47 Child: 54 Child: 61 Child: 68 Child: 75 Child: 82 ) (List.5 Child: 6 Child: 10 Child: 11 ) (List.6 Child: 7 Child: 8 Child: 9 ) (AVStr.7 S: "View" ) (AVStr.8 S: "Vector Trans 1.0" ) (AVStr.9 S: "About Vector Trans 1.0" ) (Choice.10 Label: "About Vector Trans 1.0" Click: "About Vector Trans 1.0" Shortcut: "Keys.None" ) (Numb.11 ) (List.12 Child: 13 Child: 17 Child: 18 ) (List.13 Child: 14 Child: 15 Child: 16 ) (AVStr.14 S: "View" ) (AVStr.15 S: "Vector Trans 1.0" ) (AVStr.16 S: "Generalize Features" ) (Choice.17 Label: "Generalize Features" Click: "Generalize Features" Shortcut: "Keys.None" ) (Numb.18 N: 2.00000000000000 ) (List.19 Child: 20 Child: 24 Child: 25 ) (List.20 Child: 21 Child: 22 Child: 23 ) (AVStr.21 S: "View" ) (AVStr.22 S: "Vector Trans 1.0" ) (AVStr.23 S: "Merge Themes" ) (Choice.24 Label: "Merge Themes" Click: "Merge Themes" Shortcut: "Keys.None" ) (Numb.25 N: 3.00000000000000 ) (List.26 Child: 27 Child: 31 Child: 32 ) (List.27 Child: 28 Child: 29 Child: 30 ) (AVStr.28 S: "View" ) (AVStr.29 S: "Vector Trans 1.0" ) (AVStr.30 S: "Overwrite Index" ) (Choice.31 Label: "Overwrite Index" Click: "Overwrite Index" Shortcut: "Keys.None" ) (Numb.32 N: 4.00000000000000 ) (List.33 Child: 34 Child: 38 Child: 39 ) (List.34 Child: 35 Child: 36 Child: 37 ) (AVStr.35 S: "View" ) (AVStr.36 S: "Vector Trans 1.0" ) (AVStr.37 S: "Explode Polylines" ) (Choice.38 Label: "Explode Polylines" Click: "Explode Polylines" Shortcut: "Keys.None" ) (Numb.39 N: 5.00000000000000 ) (List.40 Child: 41 Child: 45 Child: 46 ) (List.41 Child: 42 Child: 43 Child: 44 ) (AVStr.42 S: "View" ) (AVStr.43 S: "Vector Trans 1.0" ) (AVStr.44 S: "Dissolve Adjacent Segments" ) (Choice.45 Label: "Dissolve Adjacent Segments" Click: "Dissolve Adjacent Segments" Shortcut: "Keys.None" ) (Numb.46 N: 6.00000000000000 ) (List.47 Child: 48 Child: 52 Child: 53 ) (List.48 Child: 49 Child: 50 Child: 51 ) (AVStr.49 S: "View" ) (AVStr.50 S: "Vector Trans 1.0" ) (AVStr.51 S: "Explode Polygons" ) (Choice.52 Label: "Explode Polygons" Click: "Explode Polygons" Shortcut: "Keys.None" ) (Numb.53 N: 7.00000000000000 ) (List.54 Child: 55 Child: 59 Child: 60 ) (List.55 Child: 56 Child: 57 Child: 58 ) (AVStr.56 S: "View" ) (AVStr.57 S: "Vector Trans 1.0" ) (AVStr.58 S: "Polyline 2 Polygon" ) (Choice.59 Label: "Polyline 2 Polygon" Click: "Polyline 2 Polygon" Shortcut: "Keys.None" ) (Numb.60 N: 8.00000000000000 ) (List.61 Child: 62 Child: 66 Child: 67 ) (List.62 Child: 63 Child: 64 Child: 65 ) (AVStr.63 S: "View" ) (AVStr.64 S: "Vector Trans 1.0" ) (AVStr.65 S: "Polygon 2 Polyline" ) (Choice.66 Label: "Polygon 2 Polyline" Click: "Polygon 2 Polyline" Shortcut: "Keys.None" ) (Numb.67 N: 9.00000000000000 ) (List.68 Child: 69 Child: 73 Child: 74 ) (List.69 Child: 70 Child: 71 Child: 72 ) (AVStr.70 S: "View" ) (AVStr.71 S: "Vector Trans 1.0" ) (AVStr.72 S: "Polyline 2 Points" ) (Choice.73 Label: "Polyline 2 Points" Click: "Polyline 2 Points" Shortcut: "Keys.None" ) (Numb.74 N: 10.00000000000000 ) (List.75 Child: 76 Child: 80 Child: 81 ) (List.76 Child: 77 Child: 78 Child: 79 ) (AVStr.77 S: "View" ) (AVStr.78 S: "Vector Trans 1.0" ) (AVStr.79 S: "Polyline 2 Intvl Points" ) (Choice.80 Label: "Polyline 2 Intvl Points" Click: "Polyline 2 Intvl Points" Shortcut: "Keys.None" ) (Numb.81 N: 11.00000000000000 ) (List.82 Child: 83 Child: 87 Child: 88 ) (List.83 Child: 84 Child: 85 Child: 86 ) (AVStr.84 S: "View" ) (AVStr.85 S: "Vector Trans 1.0" ) (AVStr.86 S: "Graphic Points 2 Polygon" ) (Choice.87 Label: "Graphic Points 2 Polygons" Click: "Graphic Points 2 Polygon" Shortcut: "Keys.None" ) (Numb.88 N: 12.00000000000000 ) (List.89 ) (Script.90 Name: "About Vector Trans 1.0" SourceCode: "msgbox.report(\"Vector Trans 1.0\" +NL+ \"Utility tools for transforming point, polyline and polygon shapefiles.\"+NL+\"All scripts copyright by Eugene Martin © 1998-1999 except where otherwise noted. All rights reserved.\"+NL+\"CommEn Space\" +NL+ \"The Community and Environment Spatial Analysis Center\"+NL+\"www.commenspace.org\" +NL+ NL+\"Generalze Features: (From ESRI Samples)\" +NL+\"Simplifies the shapes in a shapefile that is created from the selected features for each active polyline or polygon theme. This scrip t is used to generalize, or weed out, vertices that do not add to the desired level of detail in the definition of the shape geometry. A tolerance is specified to check whether or not vertices should be retained.\"+NL+NL+\"Merge Themes: (From ESRI Samples)\"+NL+\"Merges the active themes into a single theme. A new shapefile is created which combines the shapes and attributes of the active themes. The themes to be merged should have the same set of attributes (fields). Only the fields from the first active theme are preserved in the output theme.\"+NL+NL+\"Overwrite Index: (Eugene Martin © 1999)\"+NL+\"Overwrites the selected number field with index integers.\"+NL+NL+\"Explode Polylines: (Eugene Martin © 1999)\"+NL+\"Converts selected polylines to segment polylines to create a new shapefile. If no features are currently selected all polylines will be processed. Useful for separating polylines in prepartion for individual segment processes. Use spatial join to attach line attributes to the resulting point theme .\"+NL+NL+\"Dissolve Polyline Segments: (Eugene Martin © 1999)\"+NL+\"Creates polylines from adjacent polyline segments. A useful preparation stage for converting digitized segments into whole polylines for conversion to polygons. Use 'Explode Polylines' first to break down all multi-part polylines and reduce polylines to component segments. Examine output to verify closure of perimeter polylines prior to conversion to polygons. Nodes with more than two segments are not merged by this script.\"+NL+NL+\"Explod e Polygons: (From ESRI Samples)\"+NL+\"This script converts a polygon theme which may contain multi-part polygons into a new polygon shapefile which consists of single-part exploded polygons. It is currently setup to copy over only one field from the input FTab.\"+NL+NL+\"Polylines 2 Polygons: (From ESRI Samples)\"+NL+\"Converts selected polylines to polygons to create a new shapefile. If no features are currently selected all polylines will be processed. If the polylines are not closed, i.e., the first and la st points are not identical, the user may choose to automatically close all polylines. This option will move the last point to the first point. The test for multi-part shapes has been disabled. Check your results carefully.\"+NL+NL+\"Polygon 2 Polyline: (From ESRI Samples)\"+NL+\"Converts selected polygons to polylines to create a new shapefile. If no features are currently selected all polygons will be processed. Multi part shapes are not currently supported. A polygon theme must be the active theme.\"+NL+NL+ \"Polyline 2 Points: (Eugene Martin © 1999)\"+NL+\"Converts selected polylines to points to create a new shapefile. If no features are currently selected all polylines will be processed. User is prompted for a minimum distance between points for inserting intermediary nodes. Useful for extracting points from contour lines in preparation to interpolate grid surfaces. Use spatial join to attach line attributes to the resulting point theme.\"+NL+NL+\"Polyline 2 Interval Points: (Eugene Martin © 1999)\"+NL+\"Int erpolates regular points along selected polylines to create a new shapefile. If no features are currently selected all polylines will be processed. User is prompted for a minimum distance between points. Polyline nodes and verticies are ignored when interpolating points.\"+NL+NL+\"Graphic Points 2 Graphic Polyline: (From ESRI Samples)\"+NL+\"This script creates a polygon representing the connection of the outermost points from a cluster of graphic points.\",\"About Vector Trans 1.0\")\n" ) (Script.91 Name: "Generalize Features" SourceCode: "' Name: Theme.GeneralizeFeatures\n'\n' Title: Removes unneeded vertices from selected features\n'\n' Topics: GeoData\n'\n' Description: Simplifies the shapes in a shapefile that is created from \n' the selected features for each active polyline or polygon theme. This \n' script is used to generalize, or weed out, vertices that do not add \n' to the desired level of detail in the definition of the shape geometry.\n' A tolerance is specified to check whether or not vertices should be \n' retained.\n'\n' This script is a simple implementation of the Douglas - Peucker \n' algorithm used in ARC/INFO and PC ARC/INFO. It should be used as \n' a button in a View GUI. \n'\n' A few thoughts to consider: \n'\n' 1. The script first creates a new shapefile for selected features of \n' an active theme. The new shapefile is added to the view. The original \n' theme is not changed. \n'\n' 2. This script will reduce the quality of the data. Any metadata for \n' the themes should state that the data has been modified. \n'\n' 3. Results are very dependent on the polygon geometry. Shapes \n' created from adjacent polygons may no longer be coincident. They \n' may overlap, or leave a sliver. Proceed with caution. \n'\n' 4. Results are very dependent on the polyline geometry. While the \n' shape endpoints are maintained, interior points may be eliminated. \n' Other shapes in a network that may begin or end at an interior vertex \n' may now be dangling. A complex shape may cross itself after being \n' generalized. Proceed with caution. \n'\n' 5. The only chec k on the resulting geometry is to be sure a polygon \n' has not collapsed completely by removing too many vertices. If so, \n' the shape will revert to the original. \n'\n' 6. This script does not recalculate areas, perimeters, or lengths. \n' They may have changed as the shapes are simplified. The \n' View.CalculateFeatureGeometry (calcapl.ave) sample script can be used to\n' update the values. \n'\n' Requires: A View with at least one active polyline or polygon theme. \n'\n' Self: \n'\n' Returns: \n\n\n' Get the view and its projection\n\ntheView = av.GetActiveDoc\nthePrj = theView.GetProjection\nif (thePrj.IsNull) then\n hasPrj = false\nelse\n hasPrj = true\n thePrj = theView.GetProjection\nend\n\n' Get active themes\n\ntheThemes = theView.GetActiveThemes\n\nif (theThemes.Count < 1) then\n MsgBox.Error(\"Please make a polyline or polygon theme active\",\"*** Error ***\")\n exit\nend\n\n' Process each active theme\n\nfor each t in theThemes\n\n ' Check that the theme is of the correct type\n\n if (t.Is( FTHEME).Not) then\n MsgBox.Error (t. GetName++\"is not a polyline or polygon theme\",\"*** Error ***\")\n continue\n end\n\n theClassName = t.GetFTab.GetShapeClass.GetClassName\n if ((theClassName = \"Polygon\").Not and (theClassName = \"Polyline\").Not) then\n MsgBox.Error (t.GetName++\"is not a polyline or polygon theme\",\"*** Error ***\")\n continue\n end\n\n ' Get a tolerance in (distance units) to be used (must be > 0)\n\n theTol = 0\n theMUnits = theView.GetDisplay.GetUnits\n theDUnits = theView.GetDisplay.GetDistanceUnits\n theUStr = Units.GetF ullUnitString(theDUnits).LCase\n while ((theTol <= 0) or (theTol.AsString.IsNumber).Not)\n theTol = MsgBox.Input(\"Positive tolerance value (in \"+theUStr+\n \") for theme\"++t.GetName,\"Tolerance\",theTol.AsString)\n if (theTol = NIL) then exit end\n\n if (theTol.IsNumber) then\n theTol = theTol.AsNumber\n end\n end\n theTol = Units.Convert(theTol,theDUnits,theMUnits)\n\n ' Get the name for a new theme, from View.Export script\n\n def = av.GetProject.MakeFileName(\"theme\", \"shp\")\n def = FileDialo g.Put(def, \"*.shp\", \"New file for simplified \"+ t.getName)\n\n if (def = NIL) then return nil end\n\n ' Create a new shapefile theme, from View.Export script\n\n tbl = t.GetFtab\n shpfld = (tbl.FindField(\"Shape\"))\n if (shpfld.IsVisible.Not) then\n shpfld.SetVisible(shpfld.IsVisible.Not)\n WasNotVisible = TRUE\n else\n WasNotVisible =FALSE\n end\n\n ' This will only export the selected shapes, if any have been selected\n\n av.ShowMsg(\"Creating new shape file from\"++ t.GetName)\n anFTab = tbl.Export(def, Sh ape, tbl.GetSelection.Count > 0)\n anFTab.SetEditable(true)\n\n if (WasNotVisible) then\n shpfld.SetVisible(FALSE)\n end\n\n ' Find the shape field\n\n theSField = anFTab.FindField(\"Shape\")\n\n ' Set up status bar\n\n av.ShowMsg(\"Generalizing new shapes from theme\"++ t.GetName)\n theSize = anFTab.GetNumRecords\n\n ' Initialize counters for reporting\n\n count = 0\n oldCount = 0\n newCount = 0\n\n ' Process each shape\n\n for each r in anFTab\n\n av.SetStatus(100*count/theSize)\n\n ' Retrieve shape\n\n if (theCl assName = \"Polygon\") then\n theOShape = Polygon.MakeNull\n else\n theOShape = Polyline.MakeNull\n end\n anFTab.QueryShape(r,theView.GetProjection,theOShape)\n\n ' Make a list for collecting the new set of point lists\n\n theNShape = List.Make\n\n ' Process each list in the ListofListofPoints\n\n for each p in theOShape.AsList\n\n ' Make a list for collecting the vertices to keep\n\n theNList = List.Make\n\n oldCount = oldCount + p.Count\n\n ' Set up stack for holding a set of l ists of form {index,point}\n\n theStack = Stack.Make\n\n ' Add first point to the list being assembled, and make it the anchor\n\n theAnchor = p.Get(0)\n if (hasPrj) then\n theNList.Add(theAnchor.ReturnUnProjected(thePrj))\n else\n theNList.Add(theAnchor)\n end\n aIndex = 0\n\n ' Add last point to stack\n\n fIndex = p.Count - 1\n theStack.Push({fIndex,p.Get(fIndex)})\n\n ' Process the points with the Douglas - Peucker approach\n\n while (theStack.IsEmpty .Not)\n\n ' Process from Anchor (beginning) to Floater (top of stack)\n\n fIndex = theStack.Top.Get(0)\n\n ' Create graphic shape for comparing distances\n\n theVect = Line.Make(theAnchor,theStack.Top.Get(1))\n\n ' Initialize values for comparison\n\n theMax = theTol\n mxIndex = 0\n\n ' Find distance\n\n for each i in (aIndex + 1) .. (fIndex - 1) ' process middle points\n\n dist = theVect.Distance(p.Get(i))\n\n ' Check against previous maximum\n\n if (dist >= theMax) then ' this point is out of the tolerance\n theMax = dist\n mxIndex = i\n end\n\n end\n\n ' If a vertex is found outside the current tolerance corridor,\n ' push it onto the stack\n\n if (mxIndex > 0) then 'a new floater has been found\n theStack.Push({mxIndex,p.Get(mxIndex)})\n else ' add floater to the list for the new shape and move forward\n if (hasPrj) then\n theNList.Add(theStack.Top.Get(1).Re turnUnProjected(thePrj))\n else\n theNList.Add(theStack.Top.Get(1))\n end\n\n ' Make the floater the new anchor\n\n theAnchor = theStack.Pop.Get(1)\n aIndex = fIndex\n\n end\n\n end\n\n ' Check for collapsed polygons\n\n if ((theNList.Count < 4) and (theClassName = \"Polygon\")) then\n ' Revert to original polygon\n if (hasPrj) then\n theNList = List.Make\n for each pt in p\n theNList.Add(pt.ReturnUnProjected( thePrj))\n end\n else\n theNList = p\n end\n\n end\n\n ' Finish up individual lists\n\n newCount = newCount + theNList.Count\n theNShape.Add(theNList)\n\n end\n\n ' Finish up the shape\n\n if (theClassName = \"Polygon\") then\n theNShape = Polygon.Make(theNShape)\n else\n theNShape = Polyline.Make(theNShape)\n end\n anFTab.SetValue(theSField, r, theNShape)\n count = count + 1\n\n end\n\n ' Clear status message\n\n av.ClearMsg\n av.ClearStatus\n\n ' Repor t on counts of old and new theme\n\n MsgBox.Info(\"The old theme with\"++ oldCount.AsString ++\n \"vertices has been generalized to\"++\n newCount.AsString++\"vertices\",\"Results\")\n\n ' Create a theme and add it to the View\n\n anFTab.SetEditable(false)\n fthm = FTheme.Make(anFTab)\n theView.AddTheme(fthm)\n\nend\n\n' Bring the View to the front\n\ntheView.GetWin.Activate" ) (Script.92 Name: "Merge Themes" SourceCode: "' Name: View.MergeThemesClick\n' \n' Title: Merges Active Themes Click\n'\n' Topics: GeoData\n' \n' Description: Merges the active themes into a single theme. A new\n' shapefile is created which combines the shapes and attributes of the\n' active themes. The themes to be merged should have the same set of\n' attributes (fields). Only the fields from the first active theme are\n' preserved in the output theme.\n'\n' Associate this script with a new control. Use the corresponding\n' update script to enable the con trol and ensure that preconditions are \n' met for proper script execution. \n'\n' Requires: Merge Themes Update (mrgthmup.ave)\n'\n' Self: \n'\n' Returns: \n\ntheView = av.GetActiveDoc\nthemesToMerge = theView.GetActiveThemes\n\n\n' Specify the output shapefile...\n \noutFName = av.GetProject.MakeFileName(\"theme\", \"shp\")\noutFName = FileDialog.Put(outFName, \"*.shp\", \"Output Merged Shapefile\")\nif (outFName = Nil) then\n exit\nend\n \n\n' Create the list of fields used for the output theme. The fields\n' are taken from th e first active theme only, it is assumed that \n' other themes have an identical set of fields. If this is not the\n' case the themes will still be merged, however fields not found in\n' other themes will be empty...\n\nfieldList = List.Make\n\nfor each f in themesToMerge.Get(0).GetFTab.GetFields\n if (f.GetName = \"Shape\") then\n continue\n else \n fCopy = f.Clone\n fieldList.Add(fCopy)\n end\nend\n\n\n' Get the class of new FTab to create, create the new FTab and \n' add fields that we've gathered from the inpu t themes....\n\nshapeType = themesToMerge.Get(0).GetFTab.FindField(\"Shape\").GetType\n\nif (shapeType = #FIELD_SHAPELINE) then \n outClass = POLYLINE\n\nelseif (shapeType = #FIELD_SHAPEMULTIPOINT) then\n outClass = MULTIPOINT\n\nelseif (shapeType = #FIELD_SHAPEPOINT) then\n outClass = POINT\n\nelseif (shapeType = #FIELD_SHAPEPOLY) then\n outClass = POLYGON\n\nelse\n MsgBox.Error(\"Invalid shape field type.\", \"Merge Themes\")\n exit\n\nend\n\nmergeFTab = FTab.MakeNew( outFName, outClass )\n\nif (fieldList.Count > 0) then\n merge FTab.AddFields( fieldList )\nend\n\n\n' Populate the new FTab from the FTabs of the input themes...\n\nfor each t in themesToMerge\n\n av.ShowMsg( \"Merging\"++t.GetName )\n\n inFTab = t.GetFTab\n\n if (inFTab.GetSelection.Count = 0) then\n theRecordsToMerge = inFTab\n numRecs = inFTab.GetNumRecords\n else\n theRecordsToMerge = inFTab.GetSelection\n numRecs = theRecordsToMerge.Count\n end\n\n for each rec in theRecordsToMerge\n\n av.SetStatus( (rec / numRecs) * 100 )\n\n newRec = mergeFTab.AddRecord\n\n i nField = inFTab.FindField( \"Shape\" )\n outField = mergeFTab.FindField( \"Shape\" )\n mergeFTab.SetValue( outField, newrec, inFTab.ReturnValue( inField, rec ))\n\n if (fieldList.Count > 0) then\n for each f in fieldList \n fName = f.GetName \n inField = inFTab.FindField( fName )\n\n ' Skip field if not found in inFTab...\n if ( inField <> Nil ) then \n outField = mergeFTab.FindField( fName )\n aValue = inFTab.ReturnValue( inField, rec )\n mergeFT ab.SetValue( outField, newRec, aValue )\n end\n\n end ' for each f\n end ' if count \n end ' for each rec\nend ' for each t\n\nav.ClearMsg\nav.ClearStatus\n\n\nif (MsgBox.YesNo(\"Add shapefile as theme to a view?\",\n \"Merge Themes\", true).Not) then \n exit \nend\n\n\n' Create a list of views and allow the user to choose which view to\n' add the new theme to... \n\nviewList = {}\nfor each d in av.GetProject.GetDocs\n if (d.Is(View)) then\n viewList.Add( d )\n end\nend\n \n' Include a choice for a new view ...\nviewList.Add(\"\")\n \naddToView = MsgBox.ListAsString( viewList,\"Add Theme to:\", \"Merge Themes\" ) \n \n\n' Get the specified view, make the theme, and add it...\nif (addToView <> nil) then\n\n if (addToView = \"\") then\n addToView = View.Make\n addToView.GetWin.Open\n end\n \n mergeTheme = FTheme.Make( mergeFTab )\n addToView.AddTheme( mergeTheme )\n\n ' Bring the View to the front...\n addToView.GetWin.Activate\nend\n\n" ) (Script.93 Name: "Overwrite Index" SourceCode: "\n' Name: View.OverwriteIndex\n' Title: Overwrites Integer Index Beginning at 0\n'\n' Topics: Data Management\n'\n' Description: Overwrites the selected number field with index integers.\n' \n' Requires: A theme in edit mode with one integer field to be overwritten. \n'\n' Self: \n'\n' Returns: \n'\n' Version: 1.0 March 27, 1999 - Runs on ArcView 3.x\n'\n' Eugene Martin\n' CommEn Space - The Community Environment Ssatial Analysis Center\n' www.commenspace.org\n' eugene@commenspace.org\n' \n' Copyright © 1999. This script i s protected by applicable U.S. and international copyright laws. \n' Distribution or sale of this script without the author's permission\n' is prohibited. Use for research purposes is permitted only if the use of \n' this script is explained and cited. Commercial use requires the author's spermission. \n\ntheView = av.GetActiveDoc\n\n'check for active theme\nif (theView.getactivethemes.count=0) then \n msgbox.warning(\"No Active theme\",\"Warning\")\n return nil\nend\n\n'get active theme and properties\n theTheme=theView .getactivethemes.get(0)\n\ninFTab=theTheme.getftab\n\n\nif (inFtab.iseditable=false) then\n msgbox.info(\"Theme must be in edit mode...Quitting\",\"Error\")\n exit\nend\n\n\nindex=msgbox.ChoiceAsString (theTheme.GetFTab.GetFields, \"Number field to overwrite with index?\", \"Select field\")\n\nindexnum=0\n\n for each record in inFTab\n inFTab.SetValue(index, indexnum, indexnum)\n \n indexnum=indexnum+1\n \n'end of iterative loop\nend\n\n\n\n\n\n" ) (Script.94 Name: "Explode Polylines" SourceCode: "' Name: View.Polyline2Segments' \n' Title: Converts polylines into contributing segments.\n'\n' Topics: Data Conversions\n'\n' Description: Converts selected polylines to segment polylines to create a new\n' shapefile. If no features are currently selected all polylines will\n' be processed. Useful for separating polylines in prepartion for individual \n' segment processes. Use spatial join to attach line attributes to the resulting point theme.\n'\n' Requires: A View must be the active document, a polyline the me must\n' be the active theme. \n'\n' Self: \n'\n' Returns: \n'\n' Version: 1.0 - Runs on ArcView 3.x\n'\n' Eugene Martin\n' CommEn Space\n' The COMMunity ENvironment SPatial Analysis CEnter\n' ewmartin@u.washington.edu\n' \n' Copyright © 1998. This script is protected by applicable U.S. and international copyright laws. \n' Distribution or sale of this script without the author's permission (Eugene W. Martin) \n' is illegal and will be prosecuted to the fullest extent of the law. \n\ntheView = av.GetActiveDoc\n\nif (th eView.GetActiveThemes.Count < 1) then\n MsgBox.Error(\"You must have one polyline theme active in the View.\",\n \"Error\")\n return nil\nend\n\nthmThemeIn = theView.GetActiveThemes.Get(0)\n\nfldShapeIn = thmThemeIn.GetFTab.FindField(\"shape\")\n\nif (fldShapeIn.GetType <> #FIELD_SHAPELINE) then\n MsgBox.Error(\"The active theme in the View must be a polyline theme.\",\n \"Error\")\n return nil\nend\n\n' Establish the output shapefile...\n\nfnDefault = FileName.Make(\"$HOME\").MakeTmp(\"pl_expld\",\"shp\")\nf nOutput = FileDialog.Put( fnDefault,\"*.shp\",\"Output Shape File\" )\nif (fnOutput = nil) then exit end\nfnOutput.SetExtension(\"shp\")\nftbOutput = FTab.MakeNew( fnOutput, PolyLine )\nfldlineIDin= msgbox.ChoiceAsString (thmThemeIn.GetFTab.GetFields, \"Segment attribute?\", \"Select attribute field\")\nftbOutput.AddFields({fldlineIDin.clone})\nftbOutput.AddFields({Field.Make(\"segmentID\", #FIELD_LONG, 8, 0)})\n\n' Check for selected shapes, else use entire theme.\n\nif (thmThemeIn.GetFTab.GetSelection.Count > 0) then\n lineTo Process = thmThemeIn.GetFTab.GetSelection\nelse\n lineToProcess = thmThemeIn.GetFTab\nend\n\nfldShapeOut = ftbOutput.FindField(\"shape\")\nfldsegmentIDOut = ftbOutput.FindField(fldlineIDin.getalias) \nfldlineIDOut = ftbOutput.FindField(\"segmentID\")\n\n'Begin processing\n\nnCount=0\nfor each r in lineToProcess\n linein = thmThemeIn.GetFTab.ReturnValue(fldShapeIn,r)\n lineID = thmThemeIn.GetFTab.ReturnValue(fldlineIDin,r)\n mpoints=linein.asmultipoint\n linelist=linein.split(mpoints) \n for each one in linelist\n nCount=nCount+1\n nRecNew = ftbOutput.AddRecord\n ftbOutput.SetValue(fldShapeOut,nRecNew,one)\n ftbOutput.SetValue(fldsegmentIDOut,nRecNew,lineID) \n ftbOutput.SetValue(fldlineIDOut,nRecNew,nCount)\n end\nend\n\n\nif (MsgBox.YesNo(\"Add shapefile as theme to a view?\",\n \"Convert Polyline to Segments\", true).Not) then \n exit \nend\n\n' Create a list of views and allow the user to choose which view to\n' add the new theme to... \nlstViews = {}\nfor ea ch d in av.GetProject.GetDocs\n if (d.Is(View)) then\n lstViews.Add( d )\n end\nend\nlstViews.Add(\"\")\n \nvweAddTo = MsgBox.ListAsString( lstViews,\"Add Theme to:\",\n \"Convert Polyline to Segments\" ) \n \n' Get the specified view, make the theme, and add it...\nif (vweAddTo <> nil) then\n if (vweAddTo = \"\") then\n vweAddTo = View.Make\n vweAddTo.GetWin.Open\n end \n thmNew = FTheme.Make( ftbOutput )\n vweAddTo.AddTheme( thmNew )\n vweAddTo.GetWin.Activate\nend\n\n\n\n\n\n\n\n" ) (Script.95 Name: "Dissolve Adjacent Segments" SourceCode: "' Name: View.DissolveSegments\n' Title: Dissolve Adjacent Polyline Segments\n'\n' Topics: Data Conversions\n'\n' Description: Creates polylines from adjacent polyline segments. A useful\n' preparation stage for converting digitized segments into whole polylines\n' for conversion to polygons. Use 'Explode Polylines' first to break down all\n' multi-part polylines and reduce polylines to component segments. Carefully\n' output to verify closure of perimeter polylines prior to conversion to polygons.\n' Nodes with more than two segments are not merged by this script.\n'\n' Requires: A View must be the active document, a polyline theme must\n' be the active theme. \n'\n' Self: \n'\n' Returns: \n'\n' Version: 1.1 March 27, 1999 - Runs on ArcView 3.x\n'\n' Eugene Martin\n' CommEn Space - The Community Environment Ssatial Analysis Center\n' www.commenspace.org\n' eugene@commenspace.org\n' \n' Copyright © 1999. This script is protected by applicable U.S. and international copyright laws. \n' Distribution or sale of this script without the author's permission\n' is prohibited. Use for research purposes is permitted only if the use of \n' this script is explained and cited. Commercial use requires the author's spermission. \n\n\ntheView = av.GetActiveDoc\ninTheme = theView.GetActiveThemes.Get(0)\n\nif (theView.GetActiveThemes.Count < 1) then\n MsgBox.Error(\"You must have one polyline theme active in the View.\",\n \"Error\")\n return nil\nend\n\nfldShapeIn = inTheme.GetFTab.FindField(\"shape\")\n\nif (fldShapeIn.GetType <> #FIELD_SHAPELINE ) then\n MsgBox.Error(\"The active theme in the View must be a polyline theme.\",\n \"Error\")\n return nil\nend\n\ninFTab=inTheme.getFTab \n\n' Establish the output shapefile...\n\nfnDefault = FileName.Make(\"$HOME\").MakeTmp(\"shape\",\"shp\")\nfnOutput = FileDialog.Put( fnDefault,\"*.shp\",\"Output Shape File\" )\nif (fnOutput = nil) then exit end\nfnOutput.SetExtension(\"shp\")\noutFTab = FTab.MakeNew(fnOutput, POLYLINE)\noutFTab.AddFields({Field.Make(\"ID\", #FIELD_LONG, 12, 0)})\n\nfldShapeOut = outFTab.FindField(\"shap e\")\nIDOut = outFTab.FindField(\"ID\")\n\noutshapes=list.make\n\n'get all shapes in a list \n\ninshapes=list.make\nrecnum=0\nfor each rec in inFTab\n inshapes.add(inFTab.returnvalue(fldShapeIn, recnum))\n recnum=recnum+1\nend\n\nwhile (inshapes.count>1)\n\n flag=0\n\n ashp=inshapes.get(0)\n inshapes.remove(0)\n\n for each i in 0..(inshapes.count-1)\n if (ashp.distance(inshapes.get(i))=0) then \nashp=ashp.returnunion(inshapes.get(i))\n inshapes.set(i, ashp)\n flag=1\n break\n end\n end\n\n if (flag=0) then\n nRecNew = OutF Tab.AddRecord\n outFTab.SetValue(fldShapeOut,nRecNew,ashp)\n outFTab.SetValue(IDOut,nRecNew,nRecNew)\n\n end\n\nend\n\nnRecNew = OutFTab.AddRecord \noutFTab.SetValue(fldShapeOut,nRecNew,inshapes.get(0))\noutFTab.SetValue(IDOut,nRecNew,nRecNew) \n\nif (MsgBox.YesNo(\"Add output theme to a view?\",\n \"www.commenspace.org\", true).Not) then \n exit \nend\n\n' Create a list of views and allow the user to choose which view to\n' add the new theme to... \nlstViews = {}\nfor each d in av.GetProject.GetDocs\n if (d.Is(View)) then\n lstViews.Add( d )\n end\nend\nlstViews.Add(\"\")\n \nvweAddTo = MsgBox.ListAsString( lstViews,\"Add Output Theme to:\",\"www.commenspace.org\" ) \n \n' Get the specified view, make the theme, and add it...\nif (vweAddTo <> nil) then\n if (vweAddTo = \"\") then\n vweAddTo = View.Make\n vweAddTo.GetWin.Open\n end \n thmNew = FTheme.Make( outFtab )\n vweAddTo.AddTheme( thmNew )\n vweAddTo.GetWin.Activate\nend\n" ) (Script.96 Name: "Explode Polygons" SourceCode: "' Name: View.ExplodePolygons\n'\n' Title: Converts multi-part polygons to single-part polygons\n'\n' Topics: GeoData\n'\n' Description: This script converts a polygon theme which may contain\n' multi-part polygons into a new polygon shapefile which consists of single-part \n' exploded polygons. It is currently setup to copy over only one field from the \n' input FTab. You can modify it to do otherwise.\n'\n' You can simulate ARC/INFO Dissolve functionality in ArcView by first using the \n' Table Summary function to m erge your shapes by values in a chosen field. Then use \n' this script to explode those multi-part polygons into individual shapes. \n'\n' Requires: A view with one active polygon theme.\n'\n' Self:\n'\n' Returns:\n\ntheView = av.getactivedoc\nif (theView.GetActiveThemes.Count < 1) then\n MsgBox.Error(\"You must have one polygon theme active in the View.\",\n \"Error\")\n return nil\nend\n\norigTheme = theView.GetActiveThemes.Get(0) \norigFtab = origTheme.GetFtab\norigShpFld = origFtab.FindField(\"Shape\")\n\nif (or igShpFld.GetType <> #FIELD_SHAPEPOLY) then\n MsgBox.Error(\"The active theme in the View must be a polygon theme.\",\n \"Error\")\n return nil\nend\n \norigFldList = origFtab.GetFields.Clone\norigFldList.RemoveObj(origShpFld)\norigJoinFld = MsgBox.ChoiceAsString(origFldList,\n \"Choose join field\",\"\")\nif (origJoinFld = nil) then\n return nil\nend \n\nnewSFN = FileDialog.Put(\"*.shp\".asfilename,\"*.shp\",\n \"New Exploded Shapefile\")\nif (newSFN = nil) then\n return nil\n end \nnewFtab = Ftab.MakeNew(newSFN,Polygon)\nnewIDfld = Field.Make(\"theID\",#FIELD_SHORT,8,0)\nnewJoinFld = origJoinFld.Clone\nnewFtab.AddFields({newIDfld, newjoinFld})\nnewShpFld = newFtab.FindField(\"Shape\")\n\nfor each rec in origFtab\n origPolygon = origFtab.ReturnValue(origShpFld,rec)\n origJoinVal = origFtab.ReturnValue(origJoinFld,rec)\n \n if (origPolygon.AsList.Count < 2)\n then\n newRecNo = newFtab.AddRecord\n newFtab.SetValue(newShpFld,newRecNo,origPolygon)\n newFtab.SetValue(newJoinFld,ne wRecNo,origJoinVal)\n newFtab.SetValue(newIDfld,newRecNo,newRecNo)\n end\n \n if (origPolygon.AsList.Count > 1)\n then\n for each polyPiece in origPolygon.Explode\n newRecNo = newFtab.AddRecord\n newFtab.SetValue(newShpFld,newRecNo,polyPiece)\n newFtab.SetValue(newJoinFld,newRecNo,origJoinVal)\n newFtab.SetValue(newIDfld,newRecNo,newRecNo)\n end\n end\nend\n\nnewTheme = Ftheme.Make(newFtab)\ntheView.AddTheme(newTheme)\nnewTheme.SetVisible(true)\n' End of Script \"explode.ave\" \n\n\n" ) (Script.97 Name: "Polyline 2 Polygon" SourceCode: "' Name: View.ConvertPolyLineToPolygon\n' \n' Title: Converts polylines in the active theme to polygons.\n'\n' Topics: GeoData\n'\n' Description: Converts selected polylines to polygons to create a new\n' shapefile. If no features are currently selected all polylines will\n' be processed.\n'\n' If the polylines are not closed, i.e., the first and last points are\n' not identical, the user may choose to automatically close all \n' polylines. This option will move the last point to the first point.\n'\n' The test for m ulti-part shapes has been disabled. Check your results\n' carefully. \n'\n' Requires: A View must be the active document, a polyline theme must\n' be the active theme. Use the following as an update script:\n'\n'-Update script for control...\n'-v = av.GetActiveDoc\n'-t = v.GetActiveThemes.Get(0)\n'-SELF.SetEnabled((t <> NIL) AND \n'- (t.GetFTab.FindField(\"shape\").GetType = #FIELD_SHAPELINE)) \n'\n' Self: \n'\n' Returns: \n'\n' Version: 3.1 (will run with 3.0a)\n'\n\ntheView = av.GetActiveDoc\nthmThemeIn = theView.GetAct iveThemes.Get(0)\n\n' Specify the output shapefile...\n'\nfnDefault = FileName.Make(\"$HOME\").MakeTmp(\"shape\",\"shp\")\nfnOutput = FileDialog.Put( fnDefault,\"*.shp\",\"Output Shape File\" )\nif (fnOutput = nil) then exit end\nfnOutput.SetExtension(\"shp\")\nftbOutput = FTab.MakeNew( fnOutput, POLYGON )\nftbOutput.AddFields({Field.Make(\"ID\", #FIELD_LONG, 8, 0)})\n\n' Polylines must close to create polygons. The choices presented to the\n' Gentle User are to automatically 'snap' the last polyline vertex to\n' the first, or to sk ip any unclosed polylines...\n'\nbForceClosure = MsgBox.YesNoCancel(\"Force closure on all features?\",\n \"Convert Polyline to Polygon\",\"TRUE\")\nif (bForceClosure = NIL) then exit end\n\n' Use selected shapes if there are any, otherwise iterate\n' through the entire FTab...\n'\nif (thmThemeIn.GetFTab.GetSelection.Count > 0) then\n colToProcess = thmThemeIn.GetFTab.GetSelection\n nRecs = colToProcess.Count\nelse\n colToProcess = thmThemeIn.GetFTab\n nRecs = colToProcess.GetNumRecords\nend\n\nnCount = 0\nnRecAdded = 0 \nfldS hapeIn = thmThemeIn.GetFTab.FindField(\"shape\")\nfldShapeOut = ftbOutput.FindField(\"shape\")\nfldIDOut = ftbOutput.FindField(\"id\") \nfor each r in colToProcess\n nCount = nCount + 1\n av.SetStatus((nCount / nRecs) * 100)\n shpIn = thmThemeIn.GetFTab.ReturnValue(fldShapeIn,r)\n \n'***** Check for Multi-part polylines DISABLED****\n' if (shpIn.AsList.Count > 1) then\n' MsgBox.Warning(\"Unable to convert multi-part shape at record\"++\n' nCount.AsString,\"Convert Polyline to Polygon\")\n' continue\n' end\n \n \n lstPoints = shpIn.AsList.Get(0)\n ptStart = lstPoints.Get(0)\n ptEnd = lstPoints.Get((lstPoints.Count - 1))\n if (ptStart <> ptEnd) then\n if (bForceClosure) then ' Force the close...\n lstPoints.Add(Point.Make(ptStart.GetX, ptStart.GetY)) ' modified 9/97\n else\n continue\n end\n end\n\n shpNew = Polygon.Make({lstPoints})\n shpNew.Clean\n \n nRecNew = ftbOutput.AddRecord\n ftbOutput.SetValue(fldShapeOut,nRecNew,shpNew)\n ftbOutput.SetValue(fldIDOut,nRecNew,nCount)\n nRecAdded = nRecAdded + 1\nend\n\nav.SetStatus(100)\n\nif (nRecAdded = 0) then\n MsgBox.Info(\"No closed polylines found. Unable to convert\"++\n \"polylines to polygons.\", \"Convert Polyline to Polygon\")\n exit\nelse\n MsgBox.Info(nRecAdded.AsString++\"shapes converted.\",\n \"Convert Polyline to Polygon\")\nend\n\nif (MsgBox.YesNo(\"Add shapefile as theme to a view?\",\n \"Convert Polyline to Polygon\", true).Not) then \n exit \nend\n\n' Create a list of views and allow the user to choose which view to\n' add the new theme to... \nlstVie ws = {}\nfor each d in av.GetProject.GetDocs\n if (d.Is(View)) then\n lstViews.Add( d )\n end\nend\nlstViews.Add(\"\")\n \nvweAddTo = MsgBox.ListAsString( lstViews,\"Add Theme to:\",\n \"Convert Polyline to Polygon\" ) \n \n' Get the specified view, make the theme, and add it...\nif (vweAddTo <> nil) then\n if (vweAddTo = \"\") then\n vweAddTo = View.Make\n vweAddTo.GetWin.Open\n end \n thmNew = FTheme.Make( ftbOutput )\n vweAddTo.AddTheme( thmNew )\n vweAddTo.GetWin.Activate\nend\n\n\n" ) (Script.98 Name: "Polygon 2 Polyline" SourceCode: "' Name: View.ConvertPolygonToPolyLine \n' \n' Title: Converts polygons in active theme to polylines\n'\n' Topics: GeoData\n' \n' Description: Converts selected polygons to polylines to create a new\n' shapefile. If no features are currently selected all polygons will\n' be processed.\n'\n' Multi part shapes are not currently supported. \n'\n' Requires: a View must be the active document, a polygon theme must\n' be the active theme. Use the following as an update script:\n'\n'-Update script for control...\n'-v = av .GetActiveDoc\n'-t = v.GetActiveThemes.Get(0)\n'-SELF.SetEnabled((t <> NIL) AND \n'- (t.GetFTab.FindField(\"shape\").GetType = #FIELD_SHAPEPOLY)) \n'\n' Self: \n'\n' Returns: \n\ntheView = av.GetActiveDoc\nthmThemeIn = theView.GetActiveThemes.Get(0)\n\n' Specify the output shapefile...\n'\nfnDefault = FileName.Make(\"$HOME\").MakeTmp(\"shape\",\"shp\")\nfnOutput = FileDialog.Put( fnDefault,\"*.shp\",\"Output Shape File\" )\nif (fnOutput = nil) then exit end\nfnOutput.SetExtension(\"shp\")\nftbOutput = FTab.MakeNew( fnOutput, POLYLI NE )\nftbOutput.AddFields({Field.Make(\"ID\", #FIELD_LONG, 8, 0)})\n\n' Use selected shapes if there are any, otherwise iterate\n' through the entire FTab...\n'\nif (thmThemeIn.GetFTab.GetSelection.Count > 0) then\n colToProcess = thmThemeIn.GetFTab.GetSelection\n nRecs = colToProcess.Count\nelse\n colToProcess = thmThemeIn.GetFTab\n nRecs = colToProcess.GetNumRecords\nend\n\nnCount = 0\nnRecsAdded = 0\nfldShapeIn = thmThemeIn.GetFTab.FindField(\"shape\")\nfldShapeOut = ftbOutput.FindField(\"shape\")\nfldIDOut = ftbOutput. FindField(\"id\") \nfor each r in colToProcess\n nCount = nCount + 1\n av.SetStatus((nCount / nRecs) * 100)\n shpIn = thmThemeIn.GetFTab.ReturnValue(fldShapeIn,r)\n \n if (shpIn.AsList.Count > 1) then\n MsgBox.Warning(\"Unable to convert multi-part shape at record\"++\n nCount.AsString,\"Convert Polygon to PolyLine\")\n continue\n end \n \n shpNew = PolyLine.Make({shpIn.AsList.Get(0)})\n\n nRecNew = ftbOutput.AddRecord\n ftbOutput.SetValue(fldShapeOut,nRecNew,shpNew)\n ftbOutput.SetValue(fldIDOut,nRecNew, nCount)\n nRecsAdded = nRecsAdded + 1\nend\n\nav.SetStatus(100)\n\nif (nRecsAdded = 0) then\n MsgBox.Error(\"Unable to convert Polygons to PolyLines.\", \n \"Convert Polygon to PolyLine\")\n exit\nelse\n MsgBox.Info(nRecsAdded.AsString++\"shapes converted.\",\n \"Convert Polygon to PolyLine\")\nend\n\nif (MsgBox.YesNo(\"Add shapefile as theme to a view?\",\n \"Convert Polygon to PolyLine\", true).Not) then \n exit \nend\n\n' Create a list of views and allow the user to choose which view to\n' add the new theme to... \nlstViews = { }\nfor each d in av.GetProject.GetDocs\n if (d.Is(View)) then\n lstViews.Add( d )\n end\nend\nlstViews.Add(\"\")\n \nvweAddTo = MsgBox.ListAsString( lstViews,\"Add Theme to:\",\n \"Convert Polygon to PolyLine\" ) \n \n' Get the specified view, make the theme, and add it...\nif (vweAddTo <> nil) then\n if (vweAddTo = \"\") then\n vweAddTo = View.Make\n vweAddTo.GetWin.Open\n end \n thmNew = FTheme.Make( ftbOutput )\n vweAddTo.AddTheme( thmNew )\n vweAddTo.GetWin.Activate\nend\n\n" ) (Script.99 Name: "Polyline 2 Points" SourceCode: "' Name: View.Polyline2Points' \n' Title: Converts polylines in the active theme to points.\n'\n' Topics: Data Conversions\n'\n' Description: Converts selected polylines to points to create a new\n' shapefile. If no features are currently selected all polylines will\n' be processed. User is prompted for a minimum distance between points for\n' inserting intermediary nodes. Useful for extracting points from contour \n' lines in preparation to interpolate grid surfaces. Use spatial join to \n' attach line attribu tes to the resulting point theme.\n'\n' Requires: A View must be the active document, a polyline theme must\n' be the active theme. \n'\n' Self: \n'\n' Returns: \n'\n' Version: 1.1 January 5, 1999 - Runs on ArcView 3.x\n'\n' Eugene Martin\n' CommEn Space\n' The COMMunity ENvironment SPatial Analysis CEnter\n' www.commenspace.org\n' ewmartin@u.washington.edu\n' \n' Copyright © 1998-1999. This script is protected by applicable U.S. and international copyright laws. \n' Distribution or sale of this script without the author's permission\n' is illegal and will be prosecuted. \n\n\ntheView = av.GetActiveDoc\n\nif (theView.GetActiveThemes.Count < 1) then\n MsgBox.Error(\"You must have one polyline theme active in the View.\",\n \"Error\")\n return nil\nend\n\nthmThemeIn = theView.GetActiveThemes.Get(0)\n\n\nfldShapeIn = thmThemeIn.GetFTab.FindField(\"shape\")\n\nif (fldShapeIn.GetType <> #FIELD_SHAPELINE) then\n MsgBox.Error(\"The active theme in the View must be a polyline theme.\",\n \"Error\")\n return nil\nend\n\n\ndist=0\ni f (msgbox.yesno(\"derive intermediary points?\",\"\",TRUE)) then\ndist=msgbox.input(\"Enter minimum point seperation in map units...\",\"www.commenspace.org\",\"\")\ndist=dist.asnumber\nend\n\n\n\n' Establish the output shapefile...\n\nfnDefault = FileName.Make(\"$HOME\").MakeTmp(\"shape\",\"shp\")\nfnOutput = FileDialog.Put( fnDefault,\"*.shp\",\"Output Shape File\" )\nif (fnOutput = nil) then exit end\nfnOutput.SetExtension(\"shp\")\nftbOutput = FTab.MakeNew( fnOutput, POINT )\nfldlineIDin= msgbox.ChoiceAsString (thmThemeIn.GetFTab.GetFiel ds, \"Polyline attribute field to attach to points?\", \"Select attribute field\")\nftbOutput.AddFields({fldlineIDin.clone})\nftbOutput.AddFields({Field.Make(\"Point_ID\", #FIELD_LONG, 8, 0)})\n\n' Check for selected shapes, else use entire theme.\n\nif (thmThemeIn.GetFTab.GetSelection.Count > 0) then\n lineToProcess = thmThemeIn.GetFTab.GetSelection\nelse\n lineToProcess = thmThemeIn.GetFTab\nend\n\nfldShapeOut = ftbOutput.FindField(\"shape\")\nfldlineIDin = thmThemeIn.GetFTab.FindField(fldlineIDin.getalias)\nfldpointIDOu t = ftbOutput.FindField(\"Point_ID\") \nfldlineIDOut = ftbOutput.FindField(fldlineIDin.getalias)\n\n'Begin processing\n\nnCount=0\nfor each r in lineToProcess\n linein = thmThemeIn.GetFTab.ReturnValue(fldShapeIn,r)\n lineID = thmThemeIn.GetFTab.ReturnValue(fldlineIDin,r)\n if (dist>0) then\n linein=linein.returndensified(dist) \n end\n pointlist=linein.asmultipoint.aslist\n for each xy in pointlist\n nCount=nCount+1\n nRecNew = ftbOutput.AddRecord\n ftbOutput.SetValu e(fldShapeOut,nRecNew,xy)\n ftbOutput.SetValue(fldlineIDOut,nRecNew,lineID) \n ftbOutput.SetValue(fldpointIDOut,nRecNew,nCount)\n end\nend\n\n\nif (MsgBox.YesNo(\"Add shapefile as theme to a view?\",\n \"Convert Polyline to Polygon\", true).Not) then \n exit \nend\n\n' Create a list of views and allow the user to choose which view to\n' add the new theme to... \nlstViews = {}\nfor each d in av.GetProject.GetDocs\n if (d.Is(View)) then\n lstViews.Add( d )\n end\nend\nlstViews.Add(\"\")\n \nvweAddTo = MsgBox.ListAsString( lstViews,\"Add Theme to:\",\n \"Convert Polyline to Points\" ) \n \n' Get the specified view, make the theme, and add it...\nif (vweAddTo <> nil) then\n if (vweAddTo = \"\") then\n vweAddTo = View.Make\n vweAddTo.GetWin.Open\n end \n thmNew = FTheme.Make( ftbOutput )\n vweAddTo.AddTheme( thmNew )\n vweAddTo.GetWin.Activate\nend\n\n\n\n\n\n\n" ) (Script.100 Name: "Polyline 2 Intvl Points" SourceCode: "' Name: View.Polyline2IntervalPoints\n' Title: Interpolates regular spaced points along a polyline.\n'\n' Topics: Data Conversions\n'\n' Description: Interpolates regular points along selected polylines to create a new\n' shapefile. If no features are currently selected all polylines will\n' be processed. User is prompted for a minimum distance between points. Polyline nodes and \n' verticies are ignored when interpolating points. \n'\n' Requires: A View must be the active document, a polyline theme must\n' be t he active theme. \n'\n' Self: \n'\n' Returns: \n'\n' Version: 1.1 January 5, 1999 - Runs on ArcView 3.x\n'\n' Eugene Martin\n' CommEn Space\n' The COMMunity ENvironment SPatial Analysis CEnter\n' www.commenspace.org\n' ewmartin@u.washington.edu\n' \n' Copyright © 1998-1999. This script is protected by applicable U.S. and international copyright laws. \n' Distribution or sale of this script without the author's permission\n' is illegal and will be prosecuted. \n\n\ntheView = av.GetActiveDoc\nthmThemeIn = theView.GetActive Themes.Get(0)\n\nif (theView.GetActiveThemes.Count < 1) then\n MsgBox.Error(\"You must have one polyline theme active in the View.\",\n \"Error\")\n return nil\nend\n\nfldShapeIn = thmThemeIn.GetFTab.FindField(\"shape\")\n\nif (fldShapeIn.GetType <> #FIELD_SHAPELINE) then\n MsgBox.Error(\"The active theme in the View must be a polyline theme.\",\n \"Error\")\n return nil\nend\n\n\n'get distance input\ndist=msgbox.input(\"Enter point seperation distance in map units...\",\"www.commenspace.org\",\"\")\ndist=dis t.asnumber\n\n' Establish the output shapefile...\n\nfnDefault = FileName.Make(\"$HOME\").MakeTmp(\"shape\",\"shp\")\nfnOutput = FileDialog.Put( fnDefault,\"*.shp\",\"Output Shape File\" )\nif (fnOutput = nil) then exit end\nfnOutput.SetExtension(\"shp\")\nftbOutput = FTab.MakeNew( fnOutput, POINT )\nfldlineIDin= msgbox.ChoiceAsString (thmThemeIn.GetFTab.GetFields, \"Polyline attribute field to attach to points?\", \"Select attribute field\")\nftbOutput.AddFields({fldlineIDin.clone})\nftbOutput.AddFields({Field.Make(\"Point_ID\", #FIE LD_LONG, 8, 0)})\n\n' Check for selected shapes, else use entire theme.\n\nif (thmThemeIn.GetFTab.GetSelection.Count > 0) then\n lineToProcess = thmThemeIn.GetFTab.GetSelection\nelse\n lineToProcess = thmThemeIn.GetFTab\nend\n\nfldShapeOut = ftbOutput.FindField(\"shape\")\n\nfldpointIDOut = ftbOutput.FindField(\"Point_ID\") \nfldlineIDOut = ftbOutput.FindField(fldlineIDin.getalias)\n\n'Begin processing\n\n\nfor each r in lineToProcess\n lineID = thmThemeIn.GetFTab.ReturnValue(fldlineIDin,r)\n linein = thmThemeIn.GetFTab. ReturnValue(fldShapeIn,r)\n length = linein.returnlength\n reps = ((length/dist).floor)\n int = (dist/length)*100\n percent = int\n for each i in 0..reps\n apoint=linein.Along(percent * i)\n nRecNew = ftbOutput.AddRecord\n ftbOutput.SetValue(fldShapeOut,nRecNew,apoint)\n ftbOutput.SetValue(fldlineIDOut,nRecNew,lineID) \n ftbOutput.SetValue(fldpointIDOut,nRecNew,i)\n end\nend\n\n\nif (MsgBox.YesNo(\"Add interval points as theme to a view?\",\n \"www.commenspace.org\", true).Not) then \n exit \n end\n\n' Create a list of views and allow the user to choose which view to\n' add the new theme to... \nlstViews = {}\nfor each d in av.GetProject.GetDocs\n if (d.Is(View)) then\n lstViews.Add( d )\n end\nend\nlstViews.Add(\"\")\n \nvweAddTo = MsgBox.ListAsString( lstViews,\"Add Theme to:\",\"www.commenspace.org\" ) \n \n' Get the specified view, make the theme, and add it...\nif (vweAddTo <> nil) then\n if (vweAddTo = \"\") then\n vweAddTo = View.Make\n vweAddTo.GetWin.Open\n end \n thmNew = FTheme .Make( ftbOutput )\n vweAddTo.AddTheme( thmNew )\n vweAddTo.GetWin.Activate\nend\n\n\n\n\n\n\n" ) (Script.101 Name: "Graphic Points 2 Polygon" SourceCode: "'Name: Points.ConvertToPolygon \n'\n'Title: Convert a cluster of points to a polygon\n'\n'Topics: Graphics \n'\n'Description: This script creates a polygon representing the connection\n'of the outermost points from a cluster of graphic points.\n'\n'Requires: The active view must have at least 3 graphic points.\n'\n' Self: \n'\n' Returns: \n'\n\nv = av.GetActivedoc\npts = v.GetGraphics\n\nif (pts.Count < 3) then\n msgbox.info(\"Please select at least 3 points to make polygon\",\"\")\n exit\nend\n\ndicX = dictionary.make(11)\ndicY = dictionary.make(11)\n\nlistPoly = {}\n\nfor each pt in pts\n pt = pt.GetShape\n if (pt.Is(Point)) then\n dicX.Add(pt.GetX,pt)\n dicY.Add(pt.GetY,pt)\n end\nend\nif (dicX.Count < 3) then\n msgbox.info(\"Please have least 3 graphic points on view to make polygon\",\"\")\n exit\nend\n\nlistX = dicX.ReturnKeys\nlistY = dicY.ReturnKeys\n\nlistX.Sort(true)\n\npt0 = dicX.Get(listX.Get(0))\nlistPoly.Add(pt0)\n'msgbox.listasstring(listx,pt0.GetX.AsString,\"\")\n\nlistX.Remove(0)\n\nfor each X in listX\n pt = dicX.Get(X)\n if (pt.GetY < pt0.GetY) then \n pt0 = pt \n listPoly.Add(pt0)\n' msgbox.listasstring(listx,pt0.GetX.AsString,\"\")\n end\nend\n\nlistY.Sort(true)\nlistY.Remove(0)\nfor each Y in listY\n pt = dicY.Get(Y)\n if (pt.GetX > pt0.GetX) then \n pt0 = pt \n listPoly.Add(pt0)\n end\nend\n\nlistX.Sort(false)\nlistX.Remove(0)\nfor each X in listX\n pt = dicX.Get(X)\n if (pt.GetY > pt0.GetY) then \n pt0 = pt \n listPoly.Add(pt0)\n end\nend\n\nlistY.Sort(false)\nlistY.Remove(0)\nfor each Y in listY\n pt = dicY.Get(Y)\n if (pt.GetX < pt0.GetX) then \n pt0 = pt \n listPoly.Add(pt0)\n end\nend\n\nlistPoly.Add(listPoly.Get(0))\n\npoly = polygon.make({listPoly})\n\nv.GetGraphics.Add(GraphicShape.Make(poly))\n" ) (Script.102 Name: "My Extension Install" SourceCode: "'DO NOT EDIT!!!\n\nif (av.getproject=nil) then return(nil) end\n\n\ntheDocs = SELF.get(0)\ntheControlList = SELF.get(1)\ntheMenuList = SELF.get(2)\ntheToolMenuList=SELF.Get(3)\ntheProject=Av.getproject\n\n\n'Add the Docs\n'\nfor each adoc in theDocs\n theProject.addDoc(adoc)\nend\n\n'Add the Controls\n'\nfor each totalControl in theControlList\n 'The Control list\n acontrol=totalControl.get(0)\n \n 'The physical control\n theControl = totalControl.get(1)\n \n 'The control Index\n theCindex=totalControl.get(2)\n\n 'Find the DocGUI\n theControlDoc=av.getproject.findGUI(aControl.get(0))\n if (theControlDoc=NIL) then \n MsgBox.Warning(\"The GUI \"+aControl.get(0)+\" cannot be found in the current project.\",\"Script Eror\")\n return(nil)\n end\n \n 'This finds the control set \n thecommand=\"av.getproject.findGUI(\"\"\"+aControl.get(0)+\"\"\").Get\"+acontrol.get(1)\n thescript1=Script.Make(thecommand)\n thecontrolset=thescript1.doit(\"\")\n \n 'Add the control to the control set\n theControlSet.Add(theControl,theCindex )\nend\n\n\n'Add the menus\nfor each totalcontrol in theMenuList\n \n 'The Control list\n acontrol=totalControl.get(0)\n mDoc=acontrol.get(0)\n mMenu=acontrol.get(1)\n mMenuItem=acontrol.get(2)\n\n 'The physical control\n theControl = totalControl.get(1)\n \n 'The control Index\n theCindex=totalControl.get(2)\n\n 'Find the DocGUI\n theControlDoc=av.getproject.findGUI(aControl.get(0))\n if (theControlDoc=NIL) then \n MsgBox.Warning(\"The GUI \"+aControl.get(0)+\" cannot be found in the c urrent project.\",\"Script Eror\")\n return(nil)\n end\n \n theMbar=av.getproject.findGUI(mDoc).GetMenuBar\n themenu=theMbar.findbylabel(mMenu)\n if (themenu=NiL) then\n themenu=menu.make\n themenu.setlabel(mMenu)\n theMbar.add(themenu,999)\n end\n \n themenu.add(thecontrol, theCindex)\nend\n \n \n'Add the Tool Menus\n\nfor each totalControl in theToolMenuList\n 'The Control list\n acontrol=totalControl.get(0)\n \n 'The physical control\n theControl = totalControl.get(1)\n \n 'The con trol Index\n theCindex=totalControl.get(2)\n\n 'Find the DocGUI\n theControlDoc=av.getproject.findGUI(aControl.get(0))\n if (theControlDoc=NIL) then \n MsgBox.Warning(\"The GUI \"+aControl.get(0)+\" cannot be found in the current project.\",\"Script Eror\")\n return(nil)\n end\n \n 'This finds the control set \n thecommand=\"av.getproject.findGUI(\"\"\"+aControl.get(0)+\"\"\").Get\"+acontrol.get(1)\n thescript1=Script.Make(thecommand)\n thecontrolset=av.getproject.findGUI(aControl.get(0)).GetToolBa r\n \n 'Add the control to the control set\n theControlSet.Add(theControl,theCindex)\nend\n\n\nav.getproject.setmodified(true)\n\n\n'And the scripts add themselves\n" ) (Script.103 Name: "My Extension Uninstall" SourceCode: "'DO NOT EDIT!!!\n\n'The SELF is the Extension\n\ntheDocs = SELF.get(0)\ntheControlList = SELF.get(1)\ntheMenuList = SELF.get(2)\ntheToolMenuList=SELF.get(3)\ntheProject=Av.getproject\n\n\n'Add the Docs\n'\nfor each adoc in theDocs\n If (theProject.finddoc(adoc.getname)<>NIL) then \n theAnswer=msgbox.yesno(\"Remove the Document \"+adoc.getname+\"?\",\"Remove Document?\",TRUE)\n if (theAnswer=TRUE) then theProject.RemoveDoc(adoc) end\n end\nend\n\n'Removethe Controls\n'\nfor each totalControl in theControlList\n 'Get the control list from the Ext\n acontrol=totalControl.get(0)\n \n 'Get the physical Control\n theControl = totalControl.get(1)\n \n 'Get the Controls Index\n theCindex=totalControl.get(2)\n\n 'Find the DocGUI for the Control\n theControlDoc=av.getproject.findGUI(aControl.get(0))\n if (theControlDoc=NIL) then \n MsgBox.Warning(\"The GUI \"+aControl.get(0)+\" cannot be found in the current project.\",\"Script Eror\")\n return(nil)\n end\n \n 'This sequence finds the appropiate control set\n thecommand= \"av.getproject.findGUI(\"\"\"+aControl.get(0)+\"\"\").Get\"+acontrol.get(1)\n thescript1=Script.Make(thecommand)\n thecontrolset=thescript1.doit(\"\")\n\n 'See if the control is in the set , if so remove it\n if (theControlSet.GetControls.find(theControl)<>NIL) then\n theControlSet.remove(theControl)\n if (thecontrol = \"ToolBar\") then\n theControlSet.selectdefault\n end\n end\nend\n\n\n'Remove the Menus\n'\nfor each totalcontrol in theMenuList\n \n 'The Control list\n acontrol=totalControl.get(0 )\n mDoc=acontrol.get(0)\n mMenu=acontrol.get(1)\n mMenuItem=acontrol.get(2)\n\n 'The physical control\n theControl = totalControl.get(1)\n \n 'The control Index\n theCindex=totalControl.get(2)\n\n 'Find the DocGUI\n theControlDoc=av.getproject.findGUI(aControl.get(0))\n if (theControlDoc=NIL) then \n MsgBox.Warning(\"The GUI \"+aControl.get(0)+\" cannot be found in the current project.\",\"Script Eror\")\n return(nil)\n end\n \n theMbar=av.getproject.findGUI(mDoc).GetMenuBar\n themenu=theMbar.findbylabel(mMenu)\n if (themenu=NiL) then\n MsgBox.Warning(\"The menu named \"+mMenu+\" is not here.\",\"Script Eror\")\n 'return(nil)\n else\n \n thething=themenu.getcontrols.find(thecontrol)\n if (thething<>NIL) then \n themenu.remove(thecontrol) \n end\n 'msgbox.info(themenu.GetControls.count.asstring,\"\")\n if (themenu.GetControls.count<1) then\n theMbar.remove(themenu)\n end\n end\nend\n \nfor each totalControl in theToolMenuList\n 'Get the control list from the Ext\n acontrol=totalControl.get(0)\n \n 'Get the physical Control\n theControl = totalControl.get(1)\n \n 'Get the Controls Index\n theCindex=totalControl.get(2)\n\n 'Find the DocGUI for the Control\n theControlDoc=av.getproject.findGUI(aControl.get(0))\n if (theControlDoc=NIL) then \n MsgBox.Warning(\"The GUI \"+aControl.get(0)+\" cannot be found in the current project.\",\"Script Eror\")\n return(nil)\n end\n \n 'This sequence finds the appropiate control set\n thecontrolset=av.getp roject.findGUI(aControl.get(0)).GetToolBar\n\n \n 'See if the control is in the set , if so remove it\n if (theControlSet.GetControls.find(theControl)<>NIL) then\n \n theControlSet.remove(theControl)\n theControlSet.selectdefault\n end\n\nend\n \n\n'And the scripts delete themselves\n\n\nav.getproject.setmodified(true)\n" )