/3.1 (Extension.1 Name: "CRWR Vector" FirstRootClassName: "List" Roots: 2 Roots: 3 Roots: 4 Roots: 68 Roots: 69 Roots: 70 Roots: 71 Roots: 72 Roots: 73 Roots: 74 Roots: 75 Roots: 76 Roots: 77 Roots: 78 Roots: 79 Roots: 80 Roots: 81 Roots: 82 Version: 31 About: "CRWR-Vector v1.1. Set of tools for analysis of vector data. Scripts have been borrowed from different sources. Extension created by Francisco Olivera on April 13, 1999." InstallScript: 83 UninstallScript: 84 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 ) (List.5 Child: 6 Child: 10 Child: 11 ) (List.6 Child: 7 Child: 8 Child: 9 ) (AVStr.7 S: "View" ) (AVStr.8 S: "CRWR-Vector" ) (AVStr.9 S: "CRWRVector.Projector" ) (Choice.10 Help: "Projects a feature theme." Label: "Project" Click: "CRWRVector.Projector" 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: "CRWR-Vector" ) (AVStr.16 S: "CRWRVector.Fishnet" ) (Choice.17 Help: "Creates a fishnet polygon theme." Label: "Fishnet" Click: "CRWRVector.Fishnet" 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: "CRWR-Vector" ) (AVStr.23 S: "CRWRVector.Theissen" ) (Choice.24 Help: "Creates a Theissen polygon polygon theme." Label: "Theissen polygons" Click: "CRWRVector.Theissen" 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: "CRWR-Vector" ) (AVStr.30 S: "CRWRVector.ClipByGraphic" ) (Choice.31 Help: "Clips feature theme by graphic." Label: "Clip by graphic" Click: "CRWRVector.ClipByGraphic" 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: "CRWR-Vector" ) (AVStr.37 S: "CRWRVector.PolygonsToPolylines" ) (Choice.38 Help: "Creates a polyline theme from a polygon theme." Label: "Polygons to polylines" Click: "CRWRVector.PolygonsToPolylines" 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: "CRWR-Vector" ) (AVStr.44 S: "CRWRVector.PolyOnPolyAverage" ) (Choice.45 Help: "Transfers a property from one polygon theme to another polygon theme." Label: "Poly to poly property transfer" Click: "CRWRVector.PolyOnPolyAverage" Shortcut: "Keys.None" ) (Numb.46 N: 7.00000000000000 ) (List.47 Child: 48 Child: 52 Child: 53 ) (List.48 Child: 49 Child: 50 Child: 51 ) (AVStr.49 S: "View" ) (AVStr.50 S: "CRWR-Vector" ) (AVStr.51 S: "CRWRVector.CalculateFeatureGeometry" ) (Choice.52 Help: "Updates area and perimeter of polygons, and length of polylines." Label: "Update feature geometry" Click: "CRWRVector.CalculateFeatureGeometry" Shortcut: "Keys.None" ) (Numb.53 N: 8.00000000000000 ) (List.54 Child: 55 Child: 59 Child: 60 ) (List.55 Child: 56 Child: 57 Child: 58 ) (AVStr.56 S: "View" ) (AVStr.57 S: "CRWR-Vector" ) (AVStr.58 S: "CRWRVector.AddXYToFTab" ) (Choice.59 Help: "Add XY to polygon (centroid) or point attribute table." Label: "Add XY to table" Click: "CRWRVector.AddXYToFTab" Shortcut: "Keys.None" ) (Numb.60 N: 9.00000000000000 ) (List.61 Child: 62 Child: 66 Child: 67 ) (List.62 Child: 63 Child: 64 Child: 65 ) (AVStr.63 S: "View" ) (AVStr.64 S: "CRWR-Vector" ) (AVStr.65 S: "CRWRVector.AddRecordNumberToFTab" ) (Choice.66 Help: "Adds record number to attribute table." Label: "Add record number to table" Click: "CRWRVector.AddRecordNumberToFTab" Shortcut: "Keys.None" ) (Numb.67 N: 10.00000000000000 ) (List.68 ) (Script.69 Name: "CRWRVector.Projector" SourceCode: "' Name: Projector!\n'\n' Headline: Allows user to project themes from one projection \n' to another, using any projections ArcView supports. User must \n' know the input and output projection and units. \n'\n' Self: \n'\n' Returns:\n'\n' Description: Projects active fthemes in current view to \n' new shape files in any projection that ArcView supports, \n' projecting into units of feet, meters or decimal degrees. \n' The user must know the units (and projection) of the input \n' theme(s), and will be asked for the outpu t units and projection.\n'\n' If neither input or output projection is geographic, \n' then the user must have 2x the amount of space of the original \n' shape file, as this script writes a temporary shapefile in geographic\n' coordinates, projects that to the output projection and \n' deletes the temporary files (much faster than stepping through records).\n'\n' Attach this as the click script to a control in a View GUI.\n'\n' Topics: Conversion, Themes\n'\n' Search Keys: Project, projections, theme, units, convert\n'\n ' Requires: Fthemes in a view with the map units set, and a \n' knowledge of the projection of the themes.\n'===========================================================\n\n'check for shift key, if shift key is down pop up instructions\n\n'explain script, pops up a message with\n'info about how to use\n\nif (System.IsShiftKeyDown) then\n message =\n \"To use the projection tool you must know the map units and projection\"++\n \"of the datasets being projected. You will be prompted for the output units and projectio n.\"+nl+nl+\n \"Brief Instructions:\"+nl+nl+\n \"1. Add some themes to the view.\"+nl+nl+\n \"2. Set the map units appropriately in the View Properties window.\"+nl+nl+\n \"3. Make the theme(s) you wish to project active.\"+nl+nl+\n \"4. Press this button. You will be prompted for certain information\"++\n \"which may include the input projection, the output units and the\"++\n \"output projection.\"+nl+nl+\n \"5. You will be asked if you want to recalculate area, perimeter and length fields.\"+nl+nl +\n \"WARNING - If the field to be recalculated is not large enough to hold the new \"+\n \"(calculated) number, the value put in that field will be incorrect.\"+nl+nl+\n \n \"6. You will be asked if you want to add the projected theme(s) to a view.\"+nl+nl+\n \"7. You will be asked for output shapefile names for each theme to be projected.\"+nl\n \n msgbox.report(message,\"Projector! Instructions\")\n return nil\nend\n\n\n\n'get the active document, which should be a view\n\ntheView=av.GetActiveDoc\n\nif (th eView.Is(View).Not) then\n MsgBox.Error(\"This script must be run from a view. Exiting\",\"Error\")\n return nil\nend\n\n'Get the current source units and make sure they are not unknown\n\nsourceunits = av.getactivedoc.getdisplay.getunits\n\nif (sourceunits = #UNITS_LINEAR_UNKNOWN) then\n MsgBox.Error(\"View units must be set before projecting. Stopping.\",\n \"Error!\")\n return nil\nend\n\n\n'build a list of fthemes from the active theme list, we will project these\nthms=List.Make\nfor each t in theView.GetActive Themes\n if (t.Is(Ftheme)) then\n thms.Add(t)\n end\nend\n\n'if no themes active let the user know and quit\n\nif (thms.Count = 0) then\n System.Beep\n MsgBox.Error(\"Please make at least one feature theme active!\",\"Error\")\n return nil\nend\n\n \n'Get the projection of the view\n\nmyprj=av.getactivedoc.getprojection\n\n'Try to figure out if the source data is geographic \n' If our Prj.AsString <> \"\" then we have a projection and we are\n' geographic, or if our sourceunits are set to decimal degrees withou t\n' a projection we are too\n\ninputgeographic =((myprj.AsString <> \"\") or\n ((sourceunits = #UNITS_LINEAR_DEGREES) and (myprj.AsString = \"\")))\n\n'If not, then let user pick input and output\n\nif (inputgeographic.Not) then\n\n Msgbox.Info(\"Please select the input projection\"++\n \"in the next dialog box\",\"Projector!\")\n \n 'Pop up dialog box, to get input projection\n 'and check for cancel button (nil)\n \n inputPrj = ProjectionDialog.Show(theView,sourceunits)\n if (inputPrj.IsNull) then\n retur n nil\n end\n \n 'Pop up dialog box, to get output projection\n 'and check for cancel button (nil)\n \nelse 'your input projection is geographic\n sourceunits = #UNITS_LINEAR_DEGREES\nend\n\nunitslist1 = {\"meters\",\"feet\",\"decimal degrees\",\"miles\",\"kilometers\",\"yards\",\n \"centimeters\",\"inches\",\"millimeters\"}\n\nunitslist2 = {#UNITS_LINEAR_METERS, #UNITS_LINEAR_FEET,\n #UNITS_LINEAR_DEGREES, #UNITS_LINEAR_MILES,\n #UNITS_LINEAR_KILOMETERS, #UNITS_LINEAR_YARDS,\n #UNIT S_LINEAR_CENTIMETERS, #UNITS_LINEAR_INCHES,\n #UNITS_LINEAR_MILLIMETERS}\n \noutputunits = MsgBox.ChoiceAsString(unitslist1,\n \"Please pick output units\",\"Projector!\")\n\n\nif (outputunits = nil) then\n return nil\nelse \n outunits = unitslist2.Get(unitslist1.FindByValue(outputunits))\nend\n\n'get the output projection, using the dialog box and check for cancel (nil)\nif (outputunits = \"decimal degrees\") then\n outputPrj = prj.MakeNull\n outputPrj.SetDescription(\"Geo graphic\")\n outputgeographic = true\nelse\n outputPrj = ProjectionDialog.Show(theView,outunits)\nend\n\nif (outputPrj = nil) then\n return nil\nend\n\n'check to see if they are the same. If so, exit\n \nif ((inputgeographic.Not) and ((outputPrj = inputPrj) and (sourceunits = outunits))) then\n MsgBox.Error(\"Input projection same as output projection.\",\"Error\")\n return nil\nend\n\n\n'check to see if output projection is geographic. If it is, we won't need\n'to do as much work below\n\noutputgeographic = outputPrj.ReturnD escription.Contains(\"Geographic\")\n\n'if both input and output are geographic, quit here\n\nif (inputgeographic and outputgeographic) then\n MsgBox.Error(\"Both input and output are geographic. Stopping.\",\"Error\")\n return nil\nend\n\n'check to see if we want to recalculate area, perimeter, length fields\n\nrecalc = Msgbox.YesNo(\"Recalculate area, perimeter and length fields\"++\n \"(if present) using\"++outputunits+\"?\",\"Projector!\",true)\n \n'check to see if we want to put results into a view\n \nif (MsgB ox.YesNo(\"Add projected shapefile(s) as theme(s) to a view?\",\n \"Projector!\",true)) then\n 'make a list of views\n viewlist = List.Make\n for each d in av.GetProject.GetDocs\n if (d.Is(View)) then\n viewlist.Add(d)\n end\n end 'for each d\n \n 'provide a choice for a new view\n viewlist.Add(\"\")\n \n AddToView = MsgBox.ListAsString(viewlist,\"Add Theme to:\", \n \"Projector!\")\n \n if (AddToView <> nil) then\n if (AddToView = \"\") then\n AddToView = View.Make\n AddToView.GetWin.Open\n end\n end\nelse 'don't add to view\n AddtoView = nil\nend\n\n\n\n'step through each active theme\n\nFor each thm in thms\n \n 'get a filename for the new shapefile\n \n defname = Filename.GetCWD.MakeTmp(\"theme\",\"shp\")\n outputfile = FileDialog.Put(defname,\"*.shp\",\"Project \"+thm.GetName)\n \n 'if Canceled, then skip this theme\n \n if (outputfile = nil) then\n continue\n end\n \n 'now export the ftab (selected records only), \n \n thmftab = thm.GetFtab\n sha petype = thmftab.FindField(\"Shape\").GetType\n \n if (outputgeographic) then\n newFtab = thmFtab.ExportUnprojected(outputfile,inputPrj,\n thmFtab.GetSelection.Count >0)\n elseif (inputgeographic) then\n newFtab = thmFtab.ExportProjected(outputfile,outputPrj,\n thmFtab.GetSelection.Count > 0)\n else 'need to go to geographic, then to something else\n 'make a temporary shape file\n tempshape = Filename.GetCWD.MakeTmp(\"xxprj\",\"shp\")\n tempftab = thmFtab.ExportUnpr ojected(tempshape,\n inputPrj,thmFtab.GetSelection.Count >0)\n newFtab = tempFtab.ExportProjected(outputfile,outputPrj,false)\n \n 'now clean up\n tempftab.DeActivate\n tempftab = nil\n av.PurgeObjects\n tempshpname = tempshape.GetBaseName.AsTokens(\".\").Get(0)\n tempshpdir = tempshape.GetFullName.Clone.AsFilename\n tempshpdir.Stripfile\n filesToDelete = tempshpdir.Readfiles(tempshpname+\".*\")\n \n for each f in filesToDelete\n File.Delete(f)\n end\n end\n \n 'r ecalculate area, perim, length fields if asked to\n \n if (recalc) then\n \n 'find the fields we need to recalculate\n newareafield = newftab.Findfield(\"Area\")\n newperimfield = newftab.Findfield(\"Perimeter\")\n newlengthfield = newftab.Findfield(\"Length\")\n \n newftab.SetEditable(True)\n if (shapetype = #FIELD_SHAPEPOLY) then\n if (newareafield <> nil) then\n newftab.Calculate(\"[Shape].ReturnArea\",newareafield)\n end\n if (newperimfield <> nil) then\n newftab.Calculat e(\"[Shape].ReturnLength\",newperimfield)\n end\n elseif (shapetype = #FIELD_SHAPELINE) then\n if (newlengthfield <> nil) then\n newftab.Calculate(\"[Shape].ReturnLength\",newlengthfield)\n end\n end\n newftab.SetEditable(false)\n end 'if recalc\n \n if (addtoView <> nil) then\n 'create a theme and add it to the specifiedView\n fthm = FTheme.Make(newFTab)\n AddToView.AddTheme(fthm)\n 'put this theme in the same order as it was in the original view\n newplace = AddtoView. GetThemes.Count\n AddToView.GetThemes.Shuffle(fthm,newplace)\n end\n \nend 'for each thm\n\nif (addtoView <> nil) then\n\n 'if view units aren't set, then set them\n if (AddtoView.GetDisplay.GetUnits = #UNITS_LINEAR_UNKNOWN) then\n AddtoView.GetDisplay.SetUnits(outunits)\n end\n \n 'bring the View to the front\n\n AddToView.InvalidateTOC(nil)\n AddToView.GetWin.Activate\nend" ) (Script.70 Name: "CRWRVector.Fishnet" SourceCode: "' Name: View.GridMaker\n' \n' Title: Creates arbitrary grid(vector) shapefile\n' \n' Topics: Views, Geodata\n' \n' Description: This script is attached to a tool. When you drag a rectangle with the tool, \n' you are then prompted for how many rows and columns you want in the grid. Then you are asked \n' for the name of a shapefile to create, and the grid is created. One attribute is added to this \n' grid shape theme, a label, that is \"A1 A2 B1 B2....\" as you might see on an index map. The \n' labeling starts at the upper left.\n' \n' The grid is added to your current view as a theme called \"Grid\" with hollow fill pattern and thick \n' (thickness 2) black lines. You are prompted as to whether you want to label the grid. If you say yes, \n' it will put the labels in the grid box using the current textsymbol. \n' \n' Requires: \n' \n' Self: \n' \n' Returns: \n' \n' On September 26, 1998, Francisco Olivera replaced the word \"grid\" with \"fishnet\" in some messages.\n\n\n' *** if (self.Is(Tool).Not) then\n' *** System.Beep\n' * ** MsgBox.Error(\"This script must be run from a tool.\",\"Error\")\n' *** exit\n' *** end\n\ntheView=av.GetActiveDoc\nviewUnits=theView.GetDisplay.GetUnits\nviewProj=theView.GetProjection\n\n' Defining the rectangle (modified by Francisco Olivera)\n' *** theRect=theView.ReturnUserRect\ntheLabels = {\"Lower Left Easting\",\"Lower Left Northing\",\"Upper Right Easting\",\"Upper Right Northing\"}\ntheDefaults = {\"\",\"\",\"\",\"\"}\ntheParameters = MsgBox.MultiInput(\"Choose the Output Grid Parameters\",\"Interpolation Grid Parameters\",th eLabels,theDefaults)\nx1 = theParameters.Get(0).AsNumber\ny1 = theParameters.Get(1).AsNumber\nx2 = theParameters.Get(2).AsNumber\ny2 = theParameters.Get(3).AsNumber\ntherect = Rect.MakeXY(x1,y1,x2,y2)\n\n\nif (theRect=nil) then\n exit\nend\n\nllx=therect.getleft\nlly=therect.getBottom\n\n\ntheWidth=therect.getwidth\ntheHeight=therect.getheight\nrows=Msgbox.Input(\"Number of rows (up/down):\",\"Fishnet\",\"10\")\n\nif ((rows = nil) or (rows.asNumber < 1)) then\n MsgBox.Error(\"Must use more than one row.\",\"Aborting\")\n exit\nend\n\ncols =Msgbox.Input(\"Number of columns (left/right):\",\"Fishnet\",\"10\")\nif ((cols =nil) or (cols.asNumber < 1)) then\n MsgBox.Error(\"Must use more than one column.\",\"Aborting\")\n exit\nend\n\nrows=rows.asnumber\ncols=cols.asnumber\n\nrsize=theheight/rows\ncsize=thewidth/cols\n\nletters=\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n\nnewshpname=filedialog.Put(\"Fishnet.shp\".AsFilename,\"*.shp\",\"Fishnet file\")\nif (newshpname =nil) then\n exit\nend\n\n\n\ngridftab=Ftab.MakeNew(newshpname,POLYGON)\nlabelfield=Field.Make(\"Label\",#FIELD_CHAR,6,0)\ngridftab .SetEditable(true)\ngridftab.Addfields({labelfield})\ngridftab.SetEditable(True)\nshpfield=gridftab.FindField(\"shape\")\nlabfield=gridftab.FindField(\"label\")\n\ncountup=0\nsizer=rows*cols\nav.setstatus(0)\nAv.ShowMsg(\"Creating fishnet...\")\nfor each r in 1..rows\n row_id=(rows-r+1).AsString\n for each c in 1..cols\n countup=countup+1\n av.setstatus(countup/sizer*100)\n if ((c/26) > 1) then\n col_prefix=letters.middle((c/26).floor-1,1)\n else\n col_prefix=\"\"\n end\n if (c.Mod(26) = 0) then\n col _name=letters.Middle(25,1)\n else\n col_name=letters.Middle(c.Mod(26)-1,1)\n end\n col_id=col_prefix+col_name\n\n originx=llx+((c-1)*csize)\n originy=lly+((r-1)*rsize)\n size=csize@rsize\n theOrigin=originx@originy\n rct=rect.make(theOrigin,size)\n if (viewunits=#UNITS_LINEAR_METERS) then\n rct=rct.ReturnUnprojected(viewproj)\n end\n newrec=gridftab.AddRecord\n gridftab.SetValue(shpfield,newrec,rct.aspolygon)\n gridftab.SetValue(labfield,newrec,col_id+row_id)\n end\nend\ngridftab. SetEditable(false)\nav.clearMsg\n\nmytheme=ftheme.Make(gridftab)\nmysym=av.GetSymbolWin.GetPalette.GetList(#PALETTE_LIST_FILL).Get(0)\nmysym.setolwidth(2)\nmytheme.GetLegend.GetSymbols.Set(0,mysym)\nmytheme.SetName(\"Fishnet\")\nmytheme.SetActive(true)\nmyTheme.SetVisible(true)\ntheview.AddTheme(mytheme)\nmytheme.Invalidate(true)\ntheview.GetDisplay.Flush\n\nyn=MsgBox.YesNo(\"Label the fishnet?\",\"Fishnet Maker\",true)\n\n\nif (yn) then\n for each thm in theView.GetThemes\n if (thm <> mytheme) then\n thm.SetActive(False)\n end\n end\n\n theView.LabelThemes(false)\nend\n\n\n\n" ) (Script.71 Name: "CRWRVector.Theissen" SourceCode: "'*Script: View.MakePointPolygons\ntheView = av.GetActiveDoc\npointTheme = nil\n\n\n'*** define point input\nactThemes = theView.GetActiveThemes\nif (actThemes.Count = 1) then\n theTheme = actThemes.Get(0)\n if (theTheme.Is(FTheme)) then\n if (theTheme.GetFTab.GetShapeClass.GetClassName = \"Point\") then\n if (theTheme.GetFTab.GetNumRecords < 2) then\n MsgBox.Error(\"There must be at least 3 points in a theme for calculation!\", \"Build Thiessen Polygons\")\n return nil\n end\n pointTheme = theT heme\n end\n end\nend\n\nif (pointTheme = nil) then\n MsgBox.Error(\"Single active \"\"point\"\" theme not found!\", \"Build Thiessen Polygons\")\n return nil\nend\n\npointFTab = pointTheme.GetFTab\npointSelection = nil\nif (pointTheme.CanSelect) then\n pointSelection = pointFTab.GetSelection\n if (pointSelection.Count <= 0) then\n pointSelection = nil\n elseif (pointSelection.Count < 2) then\n MsgBox.Error(\"To calculate on a subset, a minimum of 2 points must be selected.\"++\n \"Please reselect or clea r the selection to use the entire theme.\",\n \"Build Thiessen Polygons\")\n return nil\n end\nend\n\n\n'*** define point-polygon ID link field\npointFieldList = List.Make\nfor each aField in pointFTab.GetFields\n if (aField.IsVisible and aField.IsTypeShape.Not) then\n pointFieldList.Add(aField)\n end\nend\n\nif (pointFieldList.Count = 0) then\n idField = nil\nelse\n idField = MsgBox.List(pointFieldList, \"Select point field for polygon ID link:\", \"Build Thiessen Polygons\")\nend\n\nbuildDictionary = True\n if (idField = nil) then\n if(MsgBox.YesNo(\"There was no point ID field was defined. Do you want to continue without an ID link?\", \"Build Thiessen Polygons\", False).Not) then\n return nil\n else\n buildDictionary = False\n pointIdDict = nil\n end\nend\n\n\n'*** define polygon boundry \npgThemeList = List.Make\nfor each aTheme in theView.GetThemes\n if (aTheme.Is(FTheme) and aTheme.CanSelect and (aTheme.GetFTab.GetShapeClass.GetClassName = \"Polygon\")) then\n pgThemeList.Add(aTheme)\n end\nend\n\nlimitsPG = Polygon.MakeNull\nif (pgThemeList.Count > 0) then\n pgTheme = MsgBox.List(pgThemeList, \"Select polygon theme for boundry or \"\"Cancel\"\" to use a buffered point area:\", \"Build Thiessen Polygons\")\n if (pgTheme <> nil) then\n pgFTab = pgTheme.GetFTab\n pgShapeField = pgFTab.FindField(\"Shape\")\n pgSelection = pgFTab.GetSelection\n if (pgFTab.GetNumRecords = 1) then\n for each pgRec in pgFTab\n limitsPG = pgFTab.ReturnValue(pgShapeField, pgRec)\n end\n elseif (pgSelection.Count = 1) then\n limitsPG = pgFTab.ReturnValue(pgShapeField, pgSelection.GetNextSet(-1))\n elseif (pgSelection.Count = 0) then\n if (MsgBox.YesNo(\"There are no selected records in the boundry theme. Would you like to merge all features and use the entire theme?\", \"Build Thiessen Polygons\", True)) then\n for each pgRec in pgFTab\n if (limitsPG.IsNull) then\n limitsPG = pgFTab.ReturnValue(pgShapeField, pgRec)\n else\n limitsPG = limitsPG.ReturnUnion(pgFTab.ReturnValue(pgS hapeField, pgRec))\n end\n end\n else\n return nil\n end\n else\n if (MsgBox.YesNo(\"There are multiple records selected in the boundry theme. Would you like to merge the selected features and continue?\", \"Build Thiessen Polygons\", True)) then\n pgRec = pgSelection.GetNextSet(-1)\n while (pgRec > -1)\n if (limitsPG.IsNull) then\n limitsPG = pgFTab.ReturnValue(pgShapeField, pgRec)\n else\n limitsPG = limitsPG.ReturnUnion(pgFTab .ReturnValue(pgShapeField, pgRec))\n end\n pgRec = pgSelection.GetNextSet(pgRec)\n end\n end\n end\n end\nend\n\nif (limitsPG.IsNull) then\n if (MsgBox.YesNo(\"There is no polygon boundry defined. Would you like to continue with a buffered point area?\", \"Build Thiessen Polygons\", False).Not) then\n return nil\n end\nend\n\n\n'*** build and verify point input list\npointList = List.Make\npointShapeField = pointFTab.FindField(\"Shape\")\n\nav.ClearStatus\nav.ShowMsg(\"Building point input list. ..\")\ncurrentElt = 0\nexcludeCount = 0\nif (pointSelection = nil) then\n if (buildDictionary) then\n pointIdDict = Dictionary.Make(pointFTab.GetNumRecords / 2)\n end\n \n eltCount = pointFTab.GetNumRecords\n for each pointRec in pointFTab\n aPoint = pointFTab.ReturnValue(pointShapeField, pointRec)\n\n if (limitsPG.IsNull) then\n pointList.Add(aPoint)\n if (buildDictionary) then\n pointIdDict.Add(aPoint, pointFTab.ReturnValue(idField, pointRec))\n end\n elseif (limitsPG.Contains(aPoint) ) then\n pointList.Add(aPoint)\n if (buildDictionary) then\n pointIdDict.Add(aPoint, pointFTab.ReturnValue(idField, pointRec))\n end\n else\n excludeCount = excludeCount + 1\n end\n\n currentElt = currentElt + 1\n av.SetStatus(currentElt / eltCount * 100)\n end\nelse\n if (buildDictionary) then\n pointIdDict = Dictionary.Make(pointSelection.Count / 2)\n end\n \n eltCount = pointSelection.Count\n pointRec = pointSelection.GetNextSet(-1)\n while (pointRec <> -1)\n aPoint = poin tFTab.ReturnValue(pointShapeField, pointRec)\n\n if (limitsPG.IsNull) then\n pointList.Add(aPoint)\n if (buildDictionary) then\n pointIdDict.Add(aPoint, pointFTab.ReturnValue(idField, pointRec))\n end\n elseif (limitsPG.Contains(aPoint)) then\n pointList.Add(aPoint)\n if (buildDictionary) then\n pointIdDict.Add(aPoint, pointFTab.ReturnValue(idField, pointRec))\n end\n else\n excludeCount = excludeCount + 1\n end\n\n pointRec = pointSelection.GetNextSet(pointRe c)\n currentElt = currentElt + 1\n av.SetStatus(currentElt / eltCount * 100)\n end \nend\nif (excludeCount > 0) then\n if (MsgBox.YesNo(\"There were\"++excludeCount.AsString++\"points excluded outside the boundry limits. Would you like to continue?\", \"Build Thiessen Polygons\", True).Not) then\n return nil\n end\nend\nav.ClearStatus\nav.ClearMsg\n\n\n'*** build buffered point area boundry\nif (limitsPG.IsNull) then\n buffPercent = MsgBox.Input(\"Enter percentage to buffer point area with for boundry:\", \"B uild Thiessen Polygons\", \"\")\n if (buffPercent = nil) then return nil end\n while (buffPercent.IsNumber.Not and (buffPercent.AsNumber > 0))\n buffPercent = MsgBox.Input(\"Buffer percentage must be a positive number:\", \"Build Thiessen Polygons\", buffPercent)\n if (buffPercent = nil) then return nil end\n end\n \n buffFactor = buffPercent.AsNumber / 100\n hullList = av.Run(\"Sub.GetConvexHull\", pointList)\n if (hullList = nil) then return nil end\n hullPG = Polygon.Make({hullList})\n hullExtent = hullPG.Ret urnExtent\n buffDistance = hullExtent.ReturnCenter.Distance(hullExtent.ReturnOrigin) * buffFactor\n limitsPG = hullPG.ReturnBuffered(buffDistance)\n\n if (limitsPG = nil) then return nil end\nend\n\n\n'*** define output theme file\ntype = \"Polygon\"\nclass = Polygon\n\noutThemeFile = FileName.GetCWD.MakeTmp(\"thiesn\", \"shp\")\noutThemeFile = FileDialog.Put(outThemeFile, \"*.shp\", \"Output Theme File\")\nif (outThemeFile = nil) then return nil end\noutTable = FTab.MakeNew(outThemeFile, class)\nif (outTable.HasError) then\n if (outTable.HasLockError) then\n MsgBox.Error(\"Unable to acquire write lock for file \" + outThemeFile.GetBaseName, \"Build Thiessen Polygons\")\n else\n MsgBox.Error(\"Unable to create \" + outThemeFile.GetBaseName, \"Build Thiessen Polygons\")\n end\n return nil\nend\n\n\n'*** build thiessen polygons\nthsnList = av.Run(\"Sub.GetThsnPolygons\", {pointList, limitsPG})\nif (thsnList = nil) then\n MsgBox.Error(\"Error in polygon calculation!\", \"Build Thiessen Polygons\")\n return nil\nend\npointIndex = thsnList.Get(1) \nthsnList = thsnList.Get(0)\n\n\n'*** write output theme file\noutShapeField = outTable.FindField(\"Shape\")\nareaField = Field.Make(\"Area\", #FIELD_DECIMAL, 16, 16)\npercentField = Field.Make(\"Prcnt_tot\", #FIELD_DECIMAL, 16, 16)\noutTable.AddFields({areaField, percentField})\ntotalArea = limitsPG.ReturnArea\nif (idField = nil) then\n for each thsnPolygon in thsnList\n addRec = outTable.AddRecord\n outTable.SetValue(outShapeField, addRec, thsnPolygon)\n outTable.SetValue(areaField, addRec, thsnPolygon.ReturnArea) \n outTable.SetValue(percentField, addRec, thsnPolygon.ReturnArea / totalArea * 100)\n end\nelse\n pgIDField = idField.Clone\n outTable.AddFields({pgIDField})\n currentElt = 0\n while (currentElt < thsnList.Count)\n thsnPolygon = thsnList.Get(currentElt)\n idValue = pointIdDict.Get(pointIndex.Get(currentElt))\n addRec = outTable.AddRecord\n outTable.SetValue(outShapeField, addRec, thsnPolygon)\n outTable.SetValue(pgIDField, addRec, idValue)\n outTable.SetValue(areaField, addRec, thsnPolygon.Ret urnArea)\n outTable.SetValue(percentField, addRec, thsnPolygon.ReturnArea / totalArea * 100)\n currentElt = currentElt + 1\n end\nend\n\n\n'*** add theme to view\noutTable.SetEditable(False)\noutTheme = FTheme.Make(outTable)\ntheView.AddTheme(outTheme)\noutTheme.SetVisible(True)" ) (Script.72 Name: "CRWRVector.ClipByGraphic" SourceCode: "' Name: Graphic.ClipFromGraphic\n'\n' Title: Extract and clip features by graphics\n'\n' Topics: Geodata, Graphics & Symbols\n'\n' Description: Using the selected graphics this script will\n' extract all features of the active theme and clip their boundary \n' to the graphic. All theme attributes are extracted as well.\n'\n' Requires: An update script which enables this only if a theme is\n' active and poly graphic shapes are selected.\n'\n' Self: \n'\n' Returns: \n'\n\n\ntheView=av.getactiveDoc\n\nthemelist=theView.get themes\nif (TheView.getactiveThemes.count=0) then exit end\n\n\nSRCTheme=TheView.getactiveThemes.get(0)\n\ntheGraphics=theView.getGraphics\nif (theGraphics.Hasselected.Not) then \n msgbox.error(\"No selected graphics\",\"Error\")\n exit \nend\n\ntheselGraphics = theGraphics.getselected\n\n\n\n\n' Specify the output shapefile...\noutFName = av.GetProject.MakeFileName(\"theme\", \"shp\")\noutFName = FileDialog.Put(outFName, \"*.shp\", \"Output Clipped Shapefile\")\nif (outFName = Nil) then\n exit\nend\n \nshapeType = SRCTheme.GetFTab.FindFiel d(\"Shape\").GetType\n\nif (shapeType = #FIELD_SHAPELINE) then \n outClass = POLYLINE\nelseif (shapeType = #FIELD_SHAPEMULTIPOINT) then\n outClass = MULTIPOINT\nelseif (shapeType = #FIELD_SHAPEPOINT) then\n outClass = POINT\nelseif (shapeType = #FIELD_SHAPEPOLY) then\n outClass = POLYGON\nelse\n MsgBox.Error(\"Invalid shape field type.\", \"Clip Theme\")\n exit\nend\n\n\n'-------------------------------------------------------\n'Set the variables\n'-------------------------------------------------------\n\nOutputFTab = FTab.Ma keNew( outFName, outClass )\nSRCfields = List.Make\n\nfor each f in SRCTheme.GetFTab.GetFields\n if (f.GetName = \"Shape\") then\n continue\n else \n fCopy = f.Clone\n SRCfields.Add(fCopy)\n end\nend\n\n'-------------------------------------------------------\n'add the fields to the output file\n'-------------------------------------------------------\nif (SRCFields.Count > 0) then\n OutputFTab.AddFields( SRCFields )\nend\n\n\noutshpfld = OutputFtab.findfield(\"Shape\")\n\nTheme1 = SRCTheme\nftab1=Theme1.getftab\nshpfld1=f tab1.findfield(\"Shape\")\ntherecs1 = ftab1.getselection\ntheoldsel = ftab1.getselection.clone\n \n if (therecs1.count=0) then\n therecs1=ftab1\n end\n\nOutputFtab.seteditable(False)\nOutputFtab.seteditable(True)\n\nacount=0 'A counter variable\n\n'-------------------------------------------------------\n'Start processing each record in the selected overaly polys\n'-------------------------------------------------------\n\nfor each arec2 in theselgraphics\n\n 'get the polygon shape and select all records within that shape\n \n theSRCshape1 = arec2.getshape\n \n if (theView.getprojection.isNull) then\n theSRCshape = arec2.getshape\n else\n theSRCshape = arec2.getshape.returnunprojected(theview.getprojection)\n end\n \nTheme1.SelectbyShapes({theSRCshape1}, #VTAB_SELTYPE_NEW)\nftab1.updateselection\n\n 'For each selected record \nrecordCount = 0\n \n \nfor each Selrec in ftab1.getselection\n\nrecordcount=recordcount +1\nav.showmsg(\"Spliting Shapes...\")\nav.setstatus((recordCount / ftab1.getselection.count) * 100)\n'Get the shape of the record\n \n SelectedShape = ftab1.returnvalue(shpfld1,Selrec)\n\n'If the output is a line\n\n if (outshpfld.getType = #FIELD_SHAPELINE) then\n'If the line is wholely within the polygon (no intersection) then\n msgbox.report(selectedshape.asstring,\"\") \n\n \n if (SelectedShape.iscontainedin(theSRCShape)) then\n alineshp = SelectedShape\n msgbox.info(\"contains\",\"\")\n'Else split the line using the polygon\n else \n alineshp = SelectedShape.LineIntersection(theSRCshape)\n end\n\n'Add the new record \n theoutrec=outputftab.addrecord\n'Set the shape value\n outputFtab.SetValue(outshpfld,theoutrec,alineshp)\n\n'Set the field values \n for each afield in SRCfields\n oldfield=ftab1.findfield(afield.getname)\n oldvalue=ftab1.returnvalue(oldfield,selrec)\n outputftab.setValue(afield, theoutrec, oldvalue)\n end\n\n \n \n \n 'This enters into the polygon loop\n else\n shpIntersect = SelectedShape.R eturnIntersection(theSRCshape.aspolygon)\n \n if (shpintersect.isempty) then \n continue \n end\n \n 'theview.getgraphics.add(graphicshape.make(shpintersect.returnprojected(theview.getprojection)))\n \n theoutrec=outputftab.addrecord\n outputFtab.SetValue(outshpfld,theoutrec,shpIntersect)\n \n \n for each afield in SRCfields\n oldfield=ftab1.findfield(afield.getname)\n oldvalue=ftab1.returnvalue(oldfield,selrec)\n ou tputftab.setValue(afield, theoutrec, oldvalue)\n end\n \n \n end\n ' acount=acount+1\n av.purgeobjects\n \n end \n\nend 'ends the for each on arec1\n\n\n'Set editing OFF\n\nOutputftab.seteditable(false)\n\ntheview.getgraphics.endbatch\n\nftab1.setselection(theoldsel)\nftab1.updateselection\n\nif (MsgBox.YesNo(\"Add shapefile as theme to a view?\",\n \"Clip Theme\", 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\nviewLis t = {}\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:\", \"Clip Theme\" ) \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( OutputFTab )\n addToView.AddTheme( mergeTheme )\n\n ' Br ing the View to the front...\n addToView.GetWin.Activate\nend\n\n \nav.clearstatus\n\n\n" ) (Script.73 Name: "CRWRVector.PolygonsToPolylines" 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 Polyline to Polygon\")\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 Polyline to Polygon\")\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 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" ) (Script.74 Name: "CRWRVector.PolyOnPolyAverage" SourceCode: "'----------------------------------------------------\n'----------------------------------------------------\n' Name: swbp.polyavg\n'\n' Description: Given an arbitrary\n' polygon coverage, compute a representative values for\n' these polygons based on a field in another coverage.\n' Use an area weighted average for continuous values \n' or predominant type for categorical parameters. \n'\n' History: Created by Seann Reed 2/8/98\n'----------------------------------------------------\n'------------------------------- ---------------------\n'determine inputs\ntheproject=av.getproject\ntheview=av.getactivedoc\navailthemes=theview.getthemes\n'-------------------------\n'--- identify input themes\n'-------------------------\n'make a list of themes\npolythemes=list.make\nfor each t in availthemes\n if (t.getclass.getclassname <> \"GTheme\") then\n if (t.getftab.findfield(\"shape\").gettype=#field_shapepoly) then\n polythemes.add(t)\n end\n end\nend\navgTheme=Msgbox.Choiceasstring(polythemes,\"Identify the target polygon them e.\",\"Property transferring\")\nif (avgTheme = NIL) then exit end\nvalTheme=Msgbox.choiceasstring(polythemes,\"Identify the source polygon theme.\",\"Property transferring\")\nif (valTheme = NIL) then exit end\navgftab=avgtheme.getftab\nvalftab=valtheme.getftab\nvalfields=valftab.getfields\nvalfield=msgbox.choice(valfields,\"Select the value field of the source theme.\",\"Property transferring\")\nif (valfield=nil) then\n msgbox.info(\"No value field selected. Exiting.\",\"\")\n exit\nend\navgtype=msgbox.choiceasstring({\"Area-w eighted average\",\"Most frequent value\"},\"Select method\",\"Property transferring\")\nif (avgtype.count=0) then\n msgbox.info(\"No method selected.\",\"\")\n exit\nend\n'create output field\navgftab.seteditable(true)\nif (avgftab.findfield(valfield.getname)<>nil) then\n msgbox.info(\"Field\"++valfield.getname++\"already exists in target theme.\",\"\")\n exit\nelse\n newfield=field.make(valfield.getname,valfield.gettype,valfield.getwidth,valfield.getprecision)\n newfieldc=newfield.clone\n avgftab.addfields({newfieldc})\nend\n'--- identify avg and val shape fields\navgshapef=avgftab.findfield(\"shape\")\nvalshapef=valftab.findfield(\"shape\")\n'--------------------------------------------------------\n'--- loop through all the features in the averaging theme\n'--------------------------------------------------------\navgreccount=0\nnumrecs = avgftab.getnumrecords\n'--- initialize lists needed for most likely value calculations\nvallist=list.make\narealist=list.make\nfor each avgrec in avgftab\n \n av.showmsg(\"Determining Averages...\")\n av.setstat us((avgreccount/ numrecs) * 100)\n avgreccount=avgreccount+1\n \n 'get current polygon shape\n theavgshape=avgftab.returnvalue(avgshapef,avgrec)\n valtheme.SelectbyShapes({theavgshape}, #VTAB_SELTYPE_NEW)\n \n '--------------------------------------------------------\n '--- loop through selected features\n '--------------------------------------------------------\n totarea=theavgshape.returnarea\n \n val=0\n if (avgtype=\"Area-weighted average\") then\n for each selrec in valftab.getselection \n \n selectedshape=valftab.returnvalue(valshapef,selrec)\n shpIntersect = SelectedShape.ReturnIntersection(theavgshape)\n if (shpintersect.isempty) then \n continue \n end\n fractarea=(shpintersect.returnarea)/totarea\n \n val=(valftab.returnvalue(valfield,selrec)*fractarea) + val\n \n end\n \n else\n \n for each selrec in valftab.getselection\n selectedshape=valftab.returnvalue(valshapef,selrec)\n shpIntersect = SelectedShape.ReturnIntersection(theavgs hape)\n if (shpintersect.isempty) then \n continue \n end\n fractarea=(shpintersect.returnarea)/totarea\n \n val=valftab.returnvalue(valfield,selrec)\n listnumber=vallist.findbyvalue(val)\n if (listnumber=-1) then\n vallist.add(val)\n arealist.add(fractarea)\n else\n arealist.set(listnumber,arealist.get(listnumber)+fractarea)\n end\n end\n maxarea=0\n 'determine the value with the maximum area coverage\n for each i in 0..(valli st.count-1)\n if (arealist.get(i)>maxarea) then\n maxarea=arealist.get(i)\n val=vallist.get(i)\n end\n end\n \n end ' end of if area-weighted average\n \n \n avgftab.setvalue(newfieldc,avgrec,val)\n vallist.empty\n arealist.empty\n \n \nend ' end of loop through polygons in averaging Theme\nav.purgeobjects \nav.setstatus(100) \nvalftab.getselection.clearall\navgftab.seteditable(false)\n \n' 119. d:\\washita\\avefiles\\swarm.intersectshd of 273 lines,\n' 2. d:\\washita\\swbpscript\\sw bp.intersectincl of 259 lines,\n' 105. e:\\washita\\swbpscript\\swbp.userpolyavg of 146 lines,\n\n\n''c:\\paco\\swbp.polyavg of 143 lines,\n" ) (Script.75 Name: "CRWRVector.CalculateFeatureGeometry" SourceCode: "' Name: View.CalculateFeatureGeometry\n' \n' Title: Calculates feature geometry values\n' \n' Topics: GeoData\n'\n' Description: Calculates area and perimeter for polygon themes and length \n' for line themes. If the View has been projected the calculations are in \n' projected meters. Otherwise the calculations are in 'native' map units.\n' Modify the script to provide calculation in the current report units of\n' the View. The script processes the list of active themes to calculate \n' area and perimeter, or length, depending on the theme type.\n'\n' The script will add the fields: Area and Perimeter to polygon themes, Length\n' to line themes if they do not exist. If the fields exist their values will \n' be recalculated. Rerun the script if you change the projection of the view.\n'\n' Requires: A View with at least one active theme. You must have write access\n' to the active theme(s).\n'\n' Self:\n'\n' Returns:\n\n'\n' Get the view and it's projection if any.\n'\ntheView = av.GetActiveDoc\nthePrj = theView.GetProjectio n\nif (thePrj.IsNull) then\n hasPrj = false\nelse\n hasPrj = true\nend\n\n'\n' Get the list of active themes. if there aren't any, let the user know\n' and exit.\n'\ntheActivethemeList = theView.GetActivethemes\nif (theActivethemeList.Count = 0) then\n MsgBox.Error(\"No active themes.\",\"\")\n Exit\nend\n\n'\n' Loop through the list of active themes. if you can't edit the theme\n' inform the user.\n'\nFor Each thetheme in theActivethemeList\n theFTab = thetheme.GetFTab\n if (theFTab.CanEdit.Not) then\n MsgBox.Info(\"Cannot ed it table for theme:\"++thetheme.AsString,\"\")\n Continue\n end\n '\n ' Make the FTAB editable, and find out which type of feature it is.\n '\n theFTab.SetEditable(TRUE)\n theType = theFTab.FindField(\"shape\").GetType\n if (theType = #FIELD_SHAPEPOLY) then\n '\n ' if it's polygonal check for the existence of the fields \"Area\" and\n ' Perimeter. if they do not exist, create them.\n '\n if (theFTab.FindField(\"Area\") = nil) then\n theAreaField = Field.Make(\"Area\",#FIELD_DOUBLE,16,3)\n theFTab.A ddFields({theAreaField})\n else\n ok = MsgBox.YesNo(\"Update Area?\", \"Calculate\", true)\n if (ok.Not) then\n continue\n end\n\n theAreaField = theFTab.FindField(\"Area\")\n end\n\n if (theFTab.FindField(\"Perimeter\") = nil) then\n thePerimeterField = Field.Make(\"Perimeter\",#FIELD_DOUBLE,16,3)\n theFTab.AddFields({thePerimeterField})\n else\n ok = MsgBox.YesNo(\"Update Perimeter?\", \"Calculate\", true)\n if (ok.Not) then\n continue\n end\n\n thePerimeterField = theFTab.FindField(\"Perimeter\")\n end\n \n '\n ' Loop through the FTAB and find the projected area and perimeter of each \n ' shape and set the field values appropriately.\n '\n theShape = theFTab.ReturnValue(theFTab.FindField(\"shape\"),0)\n For Each rec in theFTab\n theFTab.QueryShape(rec,thePrj,theShape)\n\n theArea = theShape.ReturnArea\n thePerimeter = theShape.ReturnLength\n\n theFTab.SetValue(theAreaField,rec,theArea)\n theFTab.SetValue(thePerimeterField,rec,thePerim eter)\n end\n \n elseif (theType = #FIELD_SHAPELINE) then\n '\n ' if the data source is linear, check for the existence of the \n ' field \"Length\". if it doesn't exist, create it.\n '\n if (theFTab.FindField(\"Length\") = nil) then\n theLengthField = Field.Make(\"Length\",#FIELD_DOUBLE,16,3)\n theFTab.AddFields({theLengthField})\n\n else\n ok = MsgBox.YesNo(\"Update Length?\", \"Calculate\", true)\n if (ok.Not) then\n continue\n end\n\n theLengthField = theFTab.FindField( \"Length\")\n end\n \n '\n ' Loop through the FTAB and find the projected length of each shape and set\n ' the field values appropriately.\n ' \n theShape = theFTab.ReturnValue(theFTab.FindField(\"shape\"),0)\n For Each rec in theFTab\n theFTab.QueryShape(rec,thePrj,theShape)\n \n theLength = theShape.ReturnLength\n\n theFTab.SetValue(theLengthField,rec,theLength)\n end\n \n end \n\n theFTab.SetEditable(FALSE)\nend\n\n\n" ) (Script.76 Name: "CRWRVector.AddXYToFTab" SourceCode: "' Name: View.AddXYCoordToFTab\n' \n' Title: Adds X and Y coordinates of features to Attribute Table\n'\n' Topics: GeoData\n'\n' Description: Adds two new fields, named X-coord and Y-coord, to the table\n' of the first active theme in the TOC and fills the respective fields with\n' the X,Y coordinates of the selected points (or all points if no selection \n' is defined) in a point theme. If instead the active theme is a polygon \n' theme, then the X,Y coordinates of the polygon centroid are calculated. If \n' the t heme is projected, the output coordinates will also be projected.\n'\n' Requires: An active point or polygon theme. This script does minimal\n' error checking and assumes that there is an active theme. \n'\n' Self: \n'\n' Returns: \n\ntheView = av.GetActiveDoc\n'must be global to work in Calc exp below\n_theProjection = theView.GetProjection \nproject_flag = _theProjection.IsNull.Not 'true if projected\ntheTheme = theView.GetActiveThemes.Get(0)\n\n'Check if point or polygon theme\nif (((theTheme.GetSrcName.GetSubName = \"point\") or \n (theTheme.GetSrcName.GetSubName = \"polygon\")).Not) then\n MsgBox.Info(\"Active theme must be polygon or point theme\",\"\")\n exit\nend \n\n'get the theme table and current edit state\ntheFTab = theTheme.GetFTab\ntheFields = theFTab.GetFields\nedit_state = theFTab.IsEditable\n\n'make sure table is editable and that fields can be added\nif (theFtab.CanEdit) then\n theFTab.SetEditable(true)\n if ((theFTab.CanAddFields).Not) then\n MsgBox.Info(\"Can't add fields to the table.\"+NL+\"Check write permission .\",\n \"Can't add X,Y coordinates\")\n exit\n end\nelse\n MsgBox.Info(\"Can't modify the feature table.\"+NL+\n \"Check write permission.\",\"Can't add X,Y coordinates\")\n exit\nend\n\n'Check if fields named \"X-coord\" and Y-coord\" exist\nx_exists = (theFTab.FindField(\"X-coord\") = NIL).Not\ny_exists = (theFtab.FindField(\"Y-coord\") = NIL).Not\n\nif (x_exists or y_exists) then \n if (MsgBox.YesNo(\"Overwrite existing fields?\",\n \"X-coord, Y-coord fields already exist\", false)) then\n 'if ok to overwrite, delete the fiel ds as they may not be defined\n 'as required by this script (eg., created from another script).\n if (x_exists) then\n theFTab.RemoveFields({theFTab.FindField(\"X-coord\")})\n end\n if (y_exists) then\n theFTab.RemoveFields({theFTab.FindField(\"Y-coord\")})\n end\n else\n exit\n end 'if (MsgBox...)\nend 'if\n\nx = Field.Make (\"X-coord\",#FIELD_DECIMAL,18,5)\ny = Field.Make (\"Y-coord\",#FIELD_DECIMAL,18,5)\ntheFTab.AddFields({x,y})\n\n'Get point coordinates or polygon centroid coordinates\nif (theThe me.GetSrcName.GetSubName = \"point\") then\n if (project_flag) then\n 'Projection defined\n theFTab.Calculate(\"[Shape].ReturnProjected(_theProjection).GetX\", x)\n theFTab.Calculate(\"[Shape].ReturnProjected(_theProjection).GetY\", y)\n else\n 'No projection defined\n theFTab.Calculate(\"[Shape].GetX\", x)\n theFTab.Calculate(\"[Shape].GetY\", y)\n end 'if\nelse 'polygon case\n if (project_flag) then\n theFTab.Calculate(\"[Shape].ReturnCenter.ReturnProjected(_theProjection).GetX\", x)\n theFTab.Calcul ate(\"[Shape].ReturnCenter.ReturnProjected(_theProjection).GetY\", y)\n else\n theFTab.Calculate(\"[Shape].ReturnCenter.GetX\", x)\n theFTab.Calculate(\"[Shape].ReturnCenter.GetY\", y)\n end ' if\nend\n\n'Return editing state to pre-script running state\ntheFTab.SetEditable(edit_state)\n\n" ) (Script.77 Name: "CRWRVector.AddRecordNumberToFTab" SourceCode: "' Name: View.AddRecNumFieldToThemes\n'\n' Title: Adds a Recno attribute to all active FTabs\n'\n' Topics: Views\n'\n' Description: Adds a Recno attribute to Ftab of all active themes, \n' if it doesn't exist, and populates it. If it already \n' exists, the user is prompted as to whether they want \n' it's values updated or not. \n'\n' Requires: At least one active theme that you can write to.\n'\n' Self: \n'\n' Returns: \n\n\ntheView = av.GetActiveDoc\nthemesList = theView.GetActiveThemes\nif (themesList.Count = 0) the n\n MsgBox.Error(\"No active themes in view.\",\"Aborting\")\n exit\nend\nfor each atheme in themesList\n currentFtab = atheme.GetFtab\n addRecno = FALSE\n hasRecno = FALSE\n updateattr = FALSE\n for each attr in currentFtab.GetFields\n if (attr.AsString.UCase = \"RECNO\") then\n hasRecno = TRUE\n if (MsgBox.YesNo(atheme.AsString+\" contains RECNO attribute.\"+nl+\n \"Do you want to update it?\",\"Update\",FALSE)) then\n updateattr = TRUE\n break\n else\n break\n end\n end\n end\n numRecs = currentFTab.GetNumRecords\n if (hasRecno.Not) then\n addRecno = (MsgBox.YesNo(\"Add Record Number Attribute \"+nl+\n \"to \"+atheme.AsString+\"?\",\"Query\",TRUE))\n if (addRecno) then\n currentFtab.SetEditable(TRUE)\n recAttr = Field.Make(\"Recno\",#FIELD_LONG,8,0)\n av.ShowMsg(\"Adding Recno Attribute to \"+atheme.AsString+\"...\")\n currentFtab.AddFields({recAttr})\n av.ClearMsg\n end\n end\n if ((updateattr) or (addRecno)) then \n currentFtab.SetEditable(TRUE )\n recnoField = currentFtab.FindField(\"Recno\")\n for each recNum in currentFtab\n recno = ( recNum + 1 ).SetFormat(\"d\").AsString\n currentFtab.SetValue( recnoField, recNum, recno )\n av.ShowMsg(\"Populating Recno Attribute of \"+atheme.AsString+\"...\")\n proceed = av.SetStatus((recNum / numRecs) * 100)\n if ( proceed.Not ) then\n av.ClearStatus\n av.ShowMsg( \"Stopped\" )\n exit\n end\n end\n currentFtab.SetEditable(FALSE)\n av.SetStatus(100)\n av.ClearMsg\n av.ClearStatus\n end\nend\n\n" ) (Script.78 Name: "Sub.Get3PCircle" SourceCode: "'*Script: Sub.Get3PCircle\na_Point = Self.Get(0)\na_X = a_Point.GetX\na_Y = a_Point.GetY\nb_Point = Self.Get(1)\nb_X = b_Point.GetX\nb_Y = b_Point.GetY\nc_Point = Self.Get(2)\nc_X = c_Point.GetX\nc_Y = c_Point.GetY\ncalcA = b_X - a_X\ncalcB = b_Y - a_Y\ncalcC = c_X - a_X\ncalcD = c_Y - a_Y\ncalcG = 2 * ((calcA * (c_Y - b_Y)) - (calcB * (c_X - b_X)))\nif (calcG = 0) then\n theCircle = Circle.MakeNull\nelse \n calcE = (calcA * (a_X + b_X)) + (calcB * (a_Y + b_Y))\n calcF = (calcC * (a_X + c_X)) + (calcD * (a_Y + c_Y))\n cent erX = ((calcD * calcE) - (calcB * calcF)) / calcG\n centerY = ((calcA * calcF) - (calcC * calcE)) / calcG\n centerPoint = Point.Make(centerX, centerY)\n theRadius = a_Point.Distance(centerPoint)\n theCircle = Circle.Make(centerPoint, theRadius)\nend\nreturn theCircle" ) (Script.79 Name: "Sub.Get3PDirection" SourceCode: "'*Script: Sub.Get3PDirection\na_Point = Self.Get(0)\na_X = a_Point.GetX\na_Y = a_Point.GetY\nb_Point = Self.Get(1)\nb_X = b_Point.GetX\nb_Y = b_Point.GetY\nc_Point = Self.Get(2)\nc_X = c_Point.GetX\nc_Y = c_Point.GetY\nxStartMid = b_X - a_X 'dx1\nyStartMid = b_Y - a_Y 'dy1\nxStartEnd = c_X - a_X 'dx2\nyStartEnd = c_Y - a_Y 'dy2\n'slopes multiplied by \"xStartMid * xStartEnd\" to avoid divide by 0\nslopeStartMid = xStartEnd * yStartMid\nslopeStartEnd = xStartMid * yStartEnd\nif (slopeStartEnd > slopeStartMid) then\n return 1 ' counterclockwise\nelseif (slopeStartEnd < slopeStartMid) then\n return -1 'clockwise\nelse\n return 0 'coliner\nend" ) (Script.80 Name: "Sub.GetConvexHull" SourceCode: "'*Script: Sub.GetConvexHull\npointList = Self\n\n'*** geometry subroutines\nsubGet3PDirection = av.FindScript(\"Sub.Get3PDirection\")\nsubRadialPointSort = av.FindScript(\"Sub.RadialPointSort\")\n\n'*** input validation\nif (subGet3PDirection = nil) then\n MsgBox.Error(\"Subroutine not found: \"\"Sub.Get3PDirection\"\"\", \"Sub.GetConvexHull\")\n return nil\nelseif (subRadialPointSort = nil) then\n MsgBox.Error(\"Subroutine not found: \"\"Sub.RadialPointSort\"\"\", \"Sub.GetConvexHull\")\n return nil\nelseif (pointList.Is(List).Not) the n\n MsgBox.Error(\"Invalid point list\", \"Sub.GetConvexHull\")\n return nil\nelseif (pointList.Count < 3) then\n MsgBox.Error(\"Point list count < 3\", \"Sub.GetConvexHull\")\n return nil\nend\n\nav.ClearMsg\nav.ClearStatus\neltCount = pointList.Count\ncurrentElt = 0\nav.ShowMsg(\"Validating point input...\")\nfor each aPoint in pointList\n if (aPoint.Is(Point).Not) then\n av.ClearStatus\n av.ClearMsg\n MsgBox.Error(\"Input point invalid\", \"Sub.GetConvexHull\")\n return nil\n end\n currentElt = currentElt + 1\n av.SetS tatus(currentElt / eltCount * 100)\nend\nav.ClearStatus\n\n'*** begin calcs\nhullBase = Point.MakeNull\nhullTop = Point.MakeNull\nhullLeft = Point.MakeNull\nhullRight = Point.MakeNull\nfor each aPoint in pointList\n if (hullBase.IsNull) then\n hullBase = aPoint\n elseIf (aPoint.GetY < hullBase.GetY) then\n hullBase = aPoint\n end\n if (hullTop.IsNull) then\n hullTop = aPoint\n elseIf (aPoint.GetY > hullTop.GetY) then\n hullTop = aPoint\n end\n if (hullLeft.IsNull) then\n hullLeft = aPoint\n elseIf (aPoint. GetX < hullLeft.GetX) then\n hullLeft = aPoint\n end\n if (hullRight.IsNull) then\n hullRight = aPoint\n elseIf (aPoint.GetX > hullRight.GetX) then\n hullRight = aPoint\n end\nend\n\nexcludeBounds = {hullBase, hullRight, hullTop, hullLeft}\nexcludePoly = Polygon.Make({excludeBounds})\n\nav.ClearStatus\nav.ShowMsg(\"Excluding known interior points...\")\nstatusCount = pointList.Count\neltCount = 0\ncheckList = List.Make\nfor each aPoint in pointList\n if (\n (aPoint = hullBase) or \n (excludePoly.Contains(a Point) and (excludeBounds.Find(aPoint) = -1))\n ) then\n continue\n end\n checkList.Add(aPoint)\n eltCount = eltCount + 1\n av.SetStatus(eltCount / statusCount * 100)\nend\ncheckList = subRadialPointSort.DoIt({checkList, hullBase})\nav.ClearStatus\nav.ClearMsg \n\nav.ClearStatus\nav.ShowMsg(\"Locating convex hull...\")\nstatusCount = checkList.Count\neltCount = 0\nhullList = {hullBase}\nfor each checkPoint in checkList\n if (hullList.Count < 2) then\n hullList.Add(checkPoint)\n continue\n end\n hullDir = subGe t3PDirection.DoIt({hullList.Get(hullList.Count -2), hullList.Get(hullList.Count -1), checkPoint})\n if (hullDir = 0) then\n colinerBase = hullList.Get(hullList.Count -2)\n colinerLast = hullList.Get(hullList.Count -1)\n if (colinerBase.Distance(checkPoint) < colinerBase.Distance(colinerLast)) then\n hullList.Set(hullList.Count -1, checkPoint)\n checkPoint = colinerLast\n end\n end\n while ((hullDir < 0) and (hullList.Count > 1))\n hullList.Remove(hullList.Count -1)\n hullDir = subGet3PDi rection.DoIt({hullList.Get(hullList.Count -2), hullList.Get(hullList.Count -1), checkPoint})\n end\n hullList.Add(checkPoint)\n eltCount = eltCount + 1\n av.SetStatus(eltCount / statusCount * 100)\nend\nav.ClearStatus\nav.ClearMsg \n\nreturn hullList" ) (Script.81 Name: "Sub.GetThsnPolygons" SourceCode: "'*Script: Sub.GetThsnPolygons\npointList = Self.Get(0)\nlimitsPG = Self.Get(1)\nlimitsPL = limitsPG.AsPolyLine\n\n'*** geometry subroutines\nsubGet3PCircle = av.FindScript(\"Sub.Get3PCircle\")\nsubRadialPointSort = av.FindScript(\"Sub.RadialPointSort\")\n\n'*** input validation\nif (subGet3PCircle = nil) then\n MsgBox.Error(\"Subroutine not found: \"\"Sub.Get3PCircle\"\"\", \"Sub.GetThsnPolygons\")\n return nil\nelseif (subRadialPointSort = nil) then\n MsgBox.Error(\"Subroutine not found: \"\"Sub.RadialPointSort\"\"\", \"Sub.GetThsnPoly gons\")\n return nil\nelseif (pointList.Is(List).Not) then\n MsgBox.Error(\"Invalid point list\", \"Sub.GetThsnPolygons\")\n return nil\nelseif (pointList.Count < 2) then\n MsgBox.Error(\"Point list count < 2\", \"Sub.GetThsnPolygons\")\n return nil\nelseif (limitsPG.Is(Polygon).Not) then\n MsgBox.Error(\"Invalid limits polygon\", \"Sub.GetThsnPolygons\")\n return nil\nend\n\nav.ClearMsg\nav.ClearStatus\neltCount = pointList.Count\ncurrentElt = 0\nav.ShowMsg(\"Validating point input...\")\nfor each aPoint in pointList\n if (aPoint.I s(Point).Not or limitsPG.Contains(aPoint).Not) then\n av.ClearStatus\n av.ClearMsg\n MsgBox.Error(\"Input point invalid or outside limits\", \"Sub.GetThsnPolygons\")\n return nil\n end\n currentElt = currentElt + 1\n av.SetStatus(currentElt / eltCount * 100)\nend\nav.ClearStatus\n\n'*** begin calcs\nlimitsRect = limitsPG.ReturnExtent\nlimitsCenter = limitsRect.ReturnCenter\nlimitsRadius = limitsCenter.Distance(limitsRect.ReturnOrigin) * 2\nworldTop = Point.Make(limitsCenter.GetX, limitsCenter.GetY + (limitsRadi us * 2))\nworldLeft = Point.Make(limitsCenter.GetX - (limitsRadius * 3.Sqrt), limitsCenter.GetY - limitsRadius)\nworldRight = Point.Make(limitsCenter.GetX + (limitsRadius * 3.Sqrt), limitsCenter.GetY - limitsRadius)\n\nworldList = {worldTop, worldLeft, worldRight}\ntinCirList = {{Circle.Make(limitsCenter, limitsRadius * 3.Sqrt), worldList}}\n\nav.ClearStatus\nav.ShowMsg(\"Generating tin...\")\nstatusCount = pointList.Count\neltCount = 0\nfor each insPoint in pointList\n buildList = List.Make\n for each tinSet in tinCirL ist.Clone\n tinCircle = tinSet.Get(0)\n insDist = insPoint.Distance(tinCircle.ReturnCenter)\n if (insDist > tinCircle.GetRadius) then\n continue\n end\n if (insDist = tinCircle.GetRadius) then\n pointError = False\n for each aPoint in tinSet.Get(1)\n if ((aPoint.GetX = insPoint.GetX) and (aPoint.GetY = insPoint.GetY)) then\n av.ClearStatus\n av.ClearMsg\n MsgBox.Error(\"Duplicate input points at:\"++aPoint.GetX.AsString+\",\"++aPoint.GetY.AsString, \"Sub.GetThs nPolygons\")\n return nil\n end\n end\n end\n buildList.Merge(tinSet.Get(1))\n tinCirList.RemoveObj(tinSet)\n end\n buildList.RemoveDuplicates\n buildList = subRadialPointSort.DoIt({buildList, insPoint})\n lastPoint = Point.MakeNull\n for each buildPoint in buildList\n if (lastPoint.IsNull) then\n lastPoint = buildPoint\n continue\n end\n tinDef = {insPoint, lastPoint, buildPoint}\n tinCircle = subGet3PCircle.DoIt(tinDef)\n tinCirList.Add({tinCircle, tinDef})\n las tPoint = buildPoint\n end\n tinDef = {insPoint, buildList.Get(buildList.Count -1), buildList.Get(0)}\n tinCircle = subGet3PCircle.DoIt(tinDef)\n tinCirList.Add({tinCircle, tinDef})\n eltCount = eltCount + 1\n av.SetStatus(eltCount / statusCount * 100)\nend\nav.ClearStatus\nav.ClearMsg \n\nav.ClearStatus\nav.ShowMsg(\"Calculating polygons...\")\nstatusCount = pointList.Count\neltCount = 0\n\nthsnList = List.Make\npointIndex = List.Make\nfor each aPoint in pointList\n thsnSet = List.Make\n clipLimits = False\n for each ti nSet in tinCirList\n tinDef = tinSet.Get(1)\n if (tinDef.Find(aPoint) > -1) then\n tinCircle = tinSet.Get(0)\n thsnVertex = tinCircle.ReturnCenter\n thsnSet.Add(thsnVertex)\n if (clipLimits.Not and limitsPG.Contains(thsnVertex).Not) then\n clipLimits = True\n end\n end\n end\n thsnSet = subRadialPointSort.DoIt({thsnSet, aPoint})\n thsnPolygon = Polygon.Make({thsnSet})\n \n if (clipLimits or thsnPolygon.Intersects(limitsPL)) then\n thsnPolygon = limitsPG.ReturnIntersection(t hsnPolygon)\n end\n\n thsnList.Add(thsnPolygon)\n pointIndex.Add(aPoint)\n eltCount = eltCount + 1\n av.SetStatus(eltCount / statusCount * 100)\nend\nav.ClearStatus\nav.ClearMsg \n\nreturn {thsnList, pointIndex}" ) (Script.82 Name: "Sub.RadialPointSort" SourceCode: "'*Script: Sub.RadialPointSort\npointList = Self.Get(0)\nsortCenter = Self.Get(1)\n\nsortList = List.Make\nfor each aPoint in pointList\n distX = aPoint.GetX - sortCenter.GetX\n distY = aPoint.GetY - sortCenter.GetY\n if (distX.Abs + distY.Abs = 0) then\n sortKey = 0\n else\n sortKey = distY / (distX.Abs + distY.Abs)\n end\n if (distX < 0) then\n sortKey = 2 - sortKey\n elseif (distY < 0) then\n sortKey = 4 + sortKey\n end\n sortKey = sortKey * 90\n\n if (sortList.IsEmpty) then\n sortList.Add({sortKey, aPoint})\n continue\n end\n\n newSet = {sortKey, aPoint}\n\n if (sortKey < sortList.Get(0).Get(0)) then\n sortList.Insert(newSet)\n elseif (sortKey = sortList.Get(0).Get(0)) then\n sortList.Insert(sortList.Get(0))\n sortList.Set(1, newSet)\n elseif (sortKey >= sortList.Get(sortList.Count -1).Get(0)) then\n sortList.Add(newSet)\n else\n indexBase = 0\n indexBound = sortList.Count -1\n addIndex = Number.MakeNull\n while (addIndex.IsNull)\n searchCount = indexBound - indexBase\n if (sea rchCount < 4) then\n for each idxVector in 0 .. searchCount\n binIndex = indexBound - idxVector\n binValue = sortList.Get(binIndex).Get(0)\n if (sortKey >= binValue) then\n addIndex = binIndex + 1\n break\n end\n end\n if (addIndex.IsNull) then\n addIndex = indexBase\n end\n else\n binIndex = indexBase + (searchCount / 2).Round\n binValue = sortList.Get(binIndex).Get(0)\n if (sortKey = binValue) then\n addIndex = binIndex + 1\n elseif (sortKey < binValue) then\n indexBound = binIndex\n elseif (sortKey > binValue) then\n indexBase = binIndex\n end\n end\n end\n sortList.Add(newSet)\n sortList.Shuffle(newSet, addIndex)\n end\nend\n\nradialList = List.Make\nfor each sortSet in sortList\n radialList.Add(sortSet.Get(1))\nend\n\nreturn radialList" ) (Script.83 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.84 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" )