/3.0 (Extension.1 Name: "Hydrologic Modeling" Dependencies: "$AVEXT/spatial.avx\n" FirstRootClassName: "List" Roots: 2 Roots: 17 Roots: 18 Roots: 19 Roots: 20 Roots: 21 Roots: 22 Roots: 23 Roots: 24 Roots: 25 Roots: 26 Roots: 27 Roots: 28 Roots: 29 Roots: 30 Roots: 31 Roots: 32 Version: 30 About: "Extends the Spatial Analyst to support hydrologic modeling (v1.1)." InstallScript: 33 UninstallScript: 34 ExtVersion: 1 ) (List.2 Child: 3 Child: 13 Child: 15 ) (PMenu.3 InternalName: "Hydro" Child: 4 Child: 5 Child: 6 Child: 7 Child: 8 Child: 9 Child: 10 Child: 11 Child: 12 Label: "&Hydro" ) (Choice.4 InternalName: "Hydro" Disabled: 1 Help: "Sets flow direction and accumulation themes " Update: "Hydro.PropertiesUpdate" Label: "&Properties..." Click: "Hydro.Properties" Shortcut: "Keys.None" ) (Space.5 InternalName: "Hydro" ) (Choice.6 InternalName: "Hydro" Disabled: 1 Help: "Fills all sinks in a surface grid theme" Update: "Hydro.FillUpdate" Label: "&Fill" Click: "Hydro.Fill" Shortcut: "Keys.None" ) (Space.7 InternalName: "Hydro" ) (Choice.8 InternalName: "Hydro" Disabled: 1 Help: "Calculates flow direction from a filled surface grid theme" Update: "Hydro.DirectionUpdate" Label: "Flow &Direction" Click: "Hydro.Direction" Shortcut: "Keys.None" ) (Choice.9 InternalName: "Hydro" Disabled: 1 Help: "Calculates flow accumulation from a flow direction theme" Update: "Hydro.AccumulationUpdate" Label: "Flow &Accumulation" Click: "Hydro.Accumulation" Shortcut: "Keys.None" ) (Choice.10 InternalName: "Hydro" Disabled: 1 Help: "Calculates upstream or downstream flow length from a flow direction theme" Update: "Hydro.LengthUpdate" Label: "Flow &Length..." Click: "Hydro.Length" Shortcut: "Keys.None" ) (Space.11 InternalName: "Hydro" ) (Choice.12 InternalName: "Hydro" Disabled: 1 Help: "Calculates watersheds from a flow accumulation theme based on a minimum basin size (Set Properties)" Update: "Hydro.WatershedUpdate" Label: "&Watershed..." Click: "Hydro.Watershed" Shortcut: "Keys.None" ) (Tool.13 InternalName: "Hydro" Disabled: 1 Help: "Creates a watershed for a chosen point on a surface grid theme (Set Properties)" Update: "Hydro.WatershedToolUpdate" Icon: 14 Cursor: "Cursors.Default" Apply: "Hydro.WatershedTool" ) (AVIcon.14 Name: "W" Res: "Icons.W" ) (Tool.15 InternalName: "Hydro" Disabled: 1 Help: "Traces the flow path of a point on a surface grid theme (Set Properties)" Update: "Hydro.RaindropToolUpdate" Icon: 16 Cursor: "Cursors.Default" Apply: "Hydro.RaindropTool" ) (AVIcon.16 Name: "R" Res: "Icons.R" ) (Script.17 Name: "Hydro.Accumulation" SourceCode: "' Accumulation script\n\ntheView = av.GetActiveDoc\nthmlist = theView.Getthemes\ngthemelist = {}\nfor each thm in thmlist\n if (thm.is(Gtheme)) then\n gthemelist.add(thm)\n end\nend\nfdgtheme = msgbox.listasstring(gthemelist,\"Select Flow Direction Grid\",\"Flow Accumulation\")\nif (fdgtheme = nil) then\n return nil\nend\nfdgrid = fdgtheme.GetGrid\n\ngthemelist.remove(gthemelist.findbyvalue(fdgtheme))\nweightgtheme = msgbox.listasstring(gthemelist,\"Select Accumulation Weight Grid. Cancel for none\",\"Flow Accumulation\")\nif (weightgtheme <> nil) then\n wgrid = weightgtheme.getgrid\n else\n wgrid = nil\nend\n\nr = fdgrid.FlowAccumulation(wgrid)\n\n' rename data set\naFN = av.GetProject.GetWorkDir.MakeTmp(\"facc\", \"\")\nr.Rename(aFN)\n\n' check if output is ok\nif (r.HasError) then return NIL end\n\n' create a theme \ngthm = GTheme.Make(r) \n\n' set name of theme\ngthm.SetName(\"Flow Accumulation\")\n\n' add theme to the view\ntheView.AddTheme(gthm)\n\n\n\n\n\n\n\n\n\n\n\n\n\n" ) (Script.18 Name: "Hydro.AccumulationUpdate" SourceCode: "' AccumulationUpdate script\n\ntheView = av.GetActiveDoc\nenabled = FALSE\n\n' enable if the active theme is a grid theme\nif (theView.GetActiveThemes.Count = 1) then\n if (theView.GetActiveThemes.Get(0).Is(GTHEME) and\n theView.GetActiveThemes.Get(0).GetGrid.IsInteger) then\n enabled = TRUE\n end\nend\nSELF.SetEnabled(enabled)\n\n" ) (Script.19 Name: "Hydro.Direction" SourceCode: "' Direction script\n\ntheView = av.GetActiveDoc\nt = theView.GetActiveThemes.Get(0)\ng = t.GetGrid\nr = g.FlowDirection(FALSE)\n\n' rename data set\naFN = av.GetProject.GetWorkDir.MakeTmp(\"fdir\", \"\")\nr.Rename(aFN)\n\n' check if output is ok\nif (r.HasError) then return NIL end\n\n' create a theme \ngthm = GTheme.Make(r) \n\n' set name of theme\ngthm.SetName(\"Flow Direction\")\n\n' add theme to the specifiedView\ntheView.AddTheme(gthm)\n\n\n\n\n\n\n\n\n\n\n\n\n" ) (Script.20 Name: "Hydro.DirectionUpdate" SourceCode: "' DirectionUpdate script\n\ntheView = av.GetActiveDoc\nenabled = FALSE\n\n' enable if the active theme is a grid theme\nif (theView.GetActiveThemes.Count = 1) then\n if (theView.GetActiveThemes.Get(0).Is(GTHEME)) then\n enabled = TRUE\n end\nend\nSELF.SetEnabled(enabled)\n\n" ) (Script.21 Name: "Hydro.Fill" SourceCode: "' Fill script\n\ntheView = av.GetActiveDoc\n\n' fill active GTheme\ntheTheme = theView.GetActiveThemes.Get(0)\n\n' fill sinks in Grid until they are gone\nelevGrid = theTheme.GetGrid\nsinkCount = 0\nnumSinks = 0\nwhile (TRUE)\n flowDirGrid = elevGrid.FlowDirection(FALSE)\n sinkGrid = flowDirGrid.Sink\n if (sinkGrid.GetVTab = NIL) then\n ' check for errors\n if (sinkGrid.HasError) then return NIL end\n sinkGrid.BuildVAT\n end\n ' check for errors\n if (sinkGrid.HasError) then return NIL end\n if (sinkGrid.GetVTab <> NIL) then\n theVTab = sinkGrid.GetVTab\n numClass = theVTab.GetNumRecords\n newSinkCount = theVTab.ReturnValue(theVTab.FindField(\"Count\"),0)\n else\n numClass = 0\n newSinkCount = 0\n end\n if (numClass < 1) then\n break\n elseif ((numSinks = numClass) and (sinkCount = newSinkCount)) then\n break\n end\n waterGrid = flowDirGrid.Watershed(sinkGrid)\n zonalFillGrid = waterGrid.ZonalFill(elevGrid)\n fillGrid = (elevGrid < (zonalFillGrid.IsNull.Con(0.AsGrid,zonalFillGrid))).Con(zonalFillGrid,e levGrid)\n elevGrid = fillGrid\n numSinks = numClass\n sinkCount = newSinkCount\nend\n\n' rename data set\naFN = av.GetProject.GetWorkDir.MakeTmp(\"fill\", \"\")\nelevGrid.Rename(aFN)\n\n' create a theme \ntheGTheme = GTheme.Make(elevGrid) \n\n' set name of theme\ntheGTheme.SetName(\"Filled\"++theTheme.GetName)\n\n' add theme to the view\ntheView.AddTheme(theGTheme)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" ) (Script.22 Name: "Hydro.FillUpdate" SourceCode: "' FillUpdate script\n\ntheView = av.GetActiveDoc\nenabled = FALSE\n\n' enable if the active theme is a grid theme\nif (theView.GetActiveThemes.Count = 1) then\n if (theView.GetActiveThemes.Get(0).Is(GTHEME)) then\n enabled = TRUE\n end\nend\nSELF.SetEnabled(enabled)\n\n" ) (Script.23 Name: "Hydro.Length" SourceCode: "' Length script\n\ntheView = av.GetActiveDoc\nt = theView.GetActiveThemes.Get(0)\ng = t.GetGrid\n\n' upstream or downstream\ndownStream = MsgBox.YesNo(\"Calculate length to an outlet?\",\"Flow Length\",TRUE)\nr = g.FlowLength(NIL, downStream.Not)\n\n' rename data set\naFN = av.GetProject.GetWorkDir.MakeTmp(\"flen\", \"\")\nr.Rename(aFN)\n\n' check if output is ok\nif (r.HasError) then return NIL end\n\n' create a theme \ngthm = GTheme.Make(r) \n\n' set name of theme\ngthm.SetName(\"Flow Length\")\n\n' add theme to the view\ntheView.AddThem e(gthm)\n\n\n\n\n\n\n\n\n\n\n\n\n" ) (Script.24 Name: "Hydro.LengthUpdate" SourceCode: "' LengthUpdate script\n\ntheView = av.GetActiveDoc\nenabled = FALSE\n\n' enable if the active theme is a grid theme\nif (theView.GetActiveThemes.Count = 1) then\n if (theView.GetActiveThemes.Get(0).Is(GTHEME) and\n theView.GetActiveThemes.Get(0).GetGrid.IsInteger) then\n enabled = TRUE\n end\nend\nSELF.SetEnabled(enabled)\n\n" ) (Script.25 Name: "Hydro.Properties" SourceCode: "' Properties script\n\ntheView = av.GetActiveDoc\n\n' grab current settings from preference dictionary\nhydroExt = Extension.Find(\"Hydrologic Modeling\")\nif (hydroExt = NIL) then\n MsgBox.Error(\"Cannot find extension!\",\"ERROR\")\n return NIL\nend\nflowDirGThemeName = hydroExt.GetPreferences.Get(\"Flow Direction Property\")\nif (flowDirGThemeName = NIL) then\n flowDirGThemeName = \"\"\nelseif (theView.FindTheme(flowDirGThemeName) = NIL) then\n flowDirGThemeName = \"\"\nend\nflowAccGThemeName = hydroExt.GetPreferences.Get(\"Flow Accumulation Property\")\nif (flowAccGThemeName = NIL) then\n flowAccGThemeName = \"\"\nelseif (theView.FindTheme(flowAccGThemeName) = NIL) then\n flowAccGThemeName = \"\"\nend\n\n' get new properties\nstatus = TRUE\nwhile (status)\n propertiesList = MsgBox.MultiInput(\"Enter properties:\", \"Hydro Properties\", {\"Flow Direction Theme:\", \"Flow Accumulation Theme:\"}, {flowDirGThemeName, flowAccGThemeName})\n if (propertiesList.Count < 2) then return NIL end\n newFlowDirGThemeName = propertiesList.Get(0)\n newFlowAccGThemen ame = propertiesList.Get(1)\n if (theView.FindTheme(newFlowDirGThemeName) <> NIL) then\n if (theView.FindTheme(newFlowDirGThemeName).GetGrid.IsInteger) then\n flowDirOK = TRUE\n flowDirGThemeName = newFlowDirGThemeName\n else\n flowDirOK = FALSE\n MsgBox.Error(\"Flow Direction Theme must contain integer values\",\"Hydro Properties\")\n end\n else\n flowDirOK = FALSE\n MsgBox.Error(\"Flow Direction Theme not found in View\",\"Hydro Properties\")\n end\n if (theView.FindTheme(newFlowAccGThem eName) <> NIL) then\n flowAccOK = TRUE\n flowAccGThemeName = newFlowAccGThemeName\n else\n flowAccOK = FALSE\n MsgBox.Error(\"Flow Accumulation Theme not found in View\",\"Hydro Properties\")\n end\n if (flowDirOK and flowAccOK) then\n status = FALSE\n else\n status = TRUE\n end\nend \n\n' set properties\nhydroExt.GetPreferences.Set(\"Flow Direction Property\",flowDirGThemeName)\nhydroExt.GetPreferences.Set(\"Flow Accumulation Property\",flowAccGThemeName)\n\n\n\n" ) (Script.26 Name: "Hydro.PropertiesUpdate" SourceCode: "' PropertiesUpdate script\n\ntheView = av.GetActiveDoc\nenabled = FALSE\n\n' enable if the view contains at least two grid themes\ntheThemes = theView.GetThemes\nif (theThemes.Count > 1) then\n count = 0\n for each t in theThemes\n if (t.Is(GTHEME)) then\n count = count + 1\n if (count = 2) then\n enabled = TRUE\n break\n end\n end\n end\nend\nSELF.SetEnabled(enabled)\n\n" ) (Script.27 Name: "Hydro.RaindropTool" SourceCode: "' RaindropTool script\n\nav.UseWaitCursor\ntheView = av.GetActiveDoc\n\n' get flow dir from extension preferences\nhydroExt = Extension.Find(\"Hydrologic Modeling\")\nif (hydroExt = NIL) then\n MsgBox.Error(\"Cannot find extension!\",\"Rain Drop Tool\")\n return NIL\nend\nflowDirGThemeName = hydroExt.GetPreferences.Get(\"Flow Direction Property\")\ntheFlowDirGTheme = theView.FindTheme(flowDirGThemeName)\nif (theFlowDirGTheme = NIL) then\n MsgBox.Error(\"Cannot find flow direction theme in view!\",\"Rain Drop Tool\")\n return NIL\n end\ntheFlowDirGrid = theFlowDirGTheme.GetGrid\ntheDisplay = theView.GetDisplay\ntheGridTheme = theView.GetActiveThemes.Get(0)\np = theDisplay.ReturnUserPoint\nl = theGridTheme.GetGrid.ReturnCostPath(theFlowDirGrid, p)\ntheView.GetGraphics.UnselectAll\ngl = GraphicShape.Make(l)\ngp = GraphicShape.Make(p)\ngl.SetSelected(TRUE)\ngp.SetSelected(TRUE)\ntheView.GetGraphics.Add(gl)\ntheView.GetGraphics.Add(gp)\ntheSelectedGraphic = theView.GetGraphics.GetSelected.Get(0)\ntheSelectedGraphic1 = theView.GetGraphics.GetSelected.Ge t(1)\ntheGridTheme.GetGraphics.Add(theSelectedGraphic)\ntheGridTheme.GetGraphics.Add(theSelectedGraphic1)\n\n\n\n\n\n\n" ) (Script.28 Name: "Hydro.RaindropToolUpdate" SourceCode: "' RaindropToolUpdate script\n\ntheView = av.GetActiveDoc\nenabled = FALSE\n\n' enable if the active theme is a grid theme and flow direction property is set qand valid\nif (theView.GetActiveThemes.Count = 1) then\n if (theView.GetActiveThemes.Get(0).Is(GTHEME)) then\n hydroExt = Extension.Find(\"Hydrologic Modeling\")\n if (hydroExt <> NIL) then\n flowDirGThemeName = hydroExt.GetPreferences.Get(\"Flow Direction Property\")\n if (flowDirGThemeName <> NIL) then\n if (theView.FindTheme(flowDirGThemeNam e) <> NIL) then\n enabled = TRUE\n end\n end\n end\n end\nend\nSELF.SetEnabled(enabled)\n\n" ) (Script.29 Name: "Hydro.Watershed" SourceCode: "' Watershed script\n\ntheView = av.GetActiveDoc\nt = theView.GetActiveThemes.Get(0)\ng = t.GetGrid\n\nstatus = TRUE\nwhile (status)\n minSize = MsgBox.Input(\"Enter the stream accumulation value:\", \"Watershed\", \"10000\")\n if (minSize = NIL) then return NIL end\n if (minSize.IsNumber and (minSize.AsNumber > 100)) then\n status = FALSE\n else\n status = TRUE\n MsgBox.Error(\"The minimum accumulation value must be greater than 100\",\"Watershed\")\n end\nend \n\n' get flow dir from extension preferences\nhydroExt = Exte nsion.Find(\"Hydrologic Modeling\")\nif (hydroExt = NIL) then\n MsgBox.Error(\"Cannot find extension!\",\"Watershed\")\n return NIL\nend\nflowDirGThemeName = hydroExt.GetPreferences.Get(\"Flow Direction Property\")\ntheFlowDirGTheme = theView.FindTheme(flowDirGThemeName)\nif (theFlowDirGTheme = NIL) then\n MsgBox.Error(\"Cannot find flow direction theme in view!\",\"Watershed\")\n return NIL\nend\ndirGrid = theFlowDirGTheme.GetGrid\n\nflowaccGThemeName = hydroExt.GetPreferences.Get(\"Flow Accumulation Property\")\ntheaccGTheme = t heview.findTheme(flowaccgthemename)\nif (theaccGTheme = NIL) then\n msgbox.error(\"Cannot find flow direction theme in view\",\"\")\n return nil\nend\n\naccgrid = theAccGTheme.getgrid\n\n' create stream net\nr = (accgrid < minSize.AsNumber.AsGrid).SetNull(1.AsGrid)\n\n\n' create watersheds\nr2 = r.StreamLink(dirGrid)\nr3 = dirGrid.Watershed(r2)\n\n' rename data set\naFN = av.GetProject.GetWorkDir.MakeTmp(\"wat\", \"\")\nr3.Rename(aFN)\n\n' check if output is ok\nif (r3.HasError) then return NIL end\n\n' create a theme \ngthm = GTheme.Ma ke(r3) \n\n' set name of theme\ngthm.SetName(\"Watersheds\")\n\n' add theme to the specifiedView\ntheView.AddTheme(gthm)\n\n" ) (Script.30 Name: "Hydro.WatershedTool" SourceCode: "' WatershedTool script\nav.UseWaitCursor\ntheView = av.GetActiveDoc\ntheDisplay = theView.GetDisplay\ntheGridTheme = theView.GetActiveThemes.Get(0)\np = theDisplay.ReturnUserPoint\ntheGrid = theGridTheme.GetGrid\nmPoint = MultiPoint.Make({p})\ntheSrcGrid = theGrid.ExtractByPoints(mPoint, Prj.MakeNull, FALSE)\n' get flow dir and acc from extension preferences\nhydroExt = Extension.Find(\"Hydrologic Modeling\")\nif (hydroExt = NIL) then\n MsgBox.Error(\"Cannot find extension!\",\"Watershed Tool\")\n return NIL\nend\nflowDirGThe meName = hydroExt.GetPreferences.Get(\"Flow Direction Property\")\ntheFlowDirGTheme = theView.FindTheme(flowDirGThemeName)\nif (theFlowDirGTheme = NIL) then\n MsgBox.Error(\"Cannot find flow direction theme in view!\",\"Watershed Tool\")\n return NIL\nend\ntheFlowDir = theFlowDirGTheme.GetGrid\nflowAccGThemeName = hydroExt.GetPreferences.Get(\"Flow Accumulation Property\")\ntheFlowAccGTheme = theView.FindTheme(flowAccGThemeName)\nif (theFlowAccGTheme = NIL) then\n MsgBox.Error(\"Cannot find flow accumulation theme in view! \",\"Watershed Tool\")\n return NIL\nend\ntheAccum = theFlowAccGTheme.GetGrid\n\n' calc watershed\ntheWater = theFlowDir.Watershed(theSrcGrid.SnapPourPoint(theAccum, 240))\n\n' rename data set\naFN = av.GetProject.GetWorkDir.MakeTmp(\"watt\", \"\")\ntheWater.Rename(aFN)\n\n' check if output is ok\nif (theWater.HasError) then return NIL end\n\n' create a theme \ngthm = GTheme.Make(theWater) \n\n' set name of theme\ngthm.SetName(\"A Watershed\")\n\n' add theme to the specifiedView\ntheView.AddTheme(gthm)\n\n\n" ) (Script.31 Name: "Hydro.WatershedToolUpdate" SourceCode: "' WatershedToolUpdate script\n\ntheView = av.GetActiveDoc\nenabled = FALSE\n\n' enable if the active theme is a grid theme and flow direction property is set qand valid\nif (theView.GetActiveThemes.Count = 1) then\n if (theView.GetActiveThemes.Get(0).Is(GTHEME)) then\n hydroExt = Extension.Find(\"Hydrologic Modeling\")\n if (hydroExt <> NIL) then\n flowDirGThemeName = hydroExt.GetPreferences.Get(\"Flow Direction Property\")\n if (flowDirGThemeName <> NIL) then\n if (theView.FindTheme(flowDirGThemeNa me) <> NIL) then\n flowAccGThemeName = hydroExt.GetPreferences.Get(\"Flow Accumulation Property\")\n if (flowAccGThemeName <> NIL) then\n if (theView.FindTheme(flowAccGThemeName) <> NIL) then\n enabled = TRUE\n end\n end\n end\n end\n end\n end\nend\nSELF.SetEnabled(enabled)\n\n" ) (Script.32 Name: "Hydro.WatershedUpdate" SourceCode: "' WatershedUpdate script\n\ntheView = av.GetActiveDoc\nenabled = FALSE\n\n' enable if the active theme is a grid theme and flow direction property is set qand valid\nif (theView.GetActiveThemes.Count = 1) then\n if (theView.GetActiveThemes.Get(0).Is(GTHEME)) then\n hydroExt = Extension.Find(\"Hydrologic Modeling\")\n if (hydroExt <> NIL) then\n flowDirGThemeName = hydroExt.GetPreferences.Get(\"Flow Direction Property\")\n if (flowDirGThemeName <> NIL) then\n if (theView.FindTheme(flowDirGThemeName) <> NIL) then\n enabled = TRUE\n end\n end\n end\n end\nend\nSELF.SetEnabled(enabled)\n\n" ) (Script.33 Name: "Hydro.Install" SourceCode: "' Install script\n\n' only install user interface components if a project is open\nif (av.GetProject = NIL) then\n return NIL\nend\n\n' only install user interface componets if they have never been loaded\n' into the project\nif (self.GetPreferences.Get(\"Loaded\") = TRUE) then\n return NIL\nend\n\n' write out version number of extension into preference dictionary\nif (self.GetPreferences.Get(\"Version\") = NIL) then\n self.GetPreferences.Add(\"Version\",self.GetExtVersion)\nend\n\n' install interface components into a DocGUI n amed \"View\". If a DocGUI named\n' \"View\" does not exist prompt the user with a list of all DocGUI's of \n' type View and install interface components to all DocGUI selected.\ntheDocGUI = av.GetProject.FindGUI(\"View\")\nif (theDocGUI = NIL) then\n listOfViewDocGUIs = av.GetProject.FindGUIsFor(View)\n installListOfViewDocGUIs = MsgBox.MultiList(listOfViewDocGUIs,\"Choose one or more view document types to add the Hydrologic Modeling interface components to : \",\"Extension Loading\")\nelse\n installListOfViewDocGUIs = {theDocGUI}\nend\nif ((installListOfViewDocGUIs = NIL) or (installListOfViewDocGUIs.Count < 1)) then\n MsgBox.Error(\"Cannot load the interface component of the Hydrologic Modeling extension.\",\"Extension Failure\")\n return NIL\nend\n\nfor each viewDocGUI in installListOfViewDocGUIs\n\n ' Clone widgets to add to project\n extWidgetList = self.Get(0)\n widgetList = extWidgetList.DeepClone\n \n ' place \"Hydro\" menu\n viewMenuBar = viewDocGUI.GetMenuBar\n themeMenu = viewMenuBar.FindByLabel(\"Analysis\")\n hydroMenu = w idgetList.Get(0)\n if (themeMenu = NIL) then\n viewMenuBar.Add(hydroMenu,viewMenuBar.GetControls.Count - 1)\n else\n viewMenuBar.Add(hydroMenu,viewMenuBar.GetControls.Find(themeMenu))\n end\n \n ' place tool\n viewToolBar = viewDocGUI.GetToolBar\n raindropTool = widgetList.Get(1)\n watershedTool = widgetList.Get(2)\n viewToolBar.Add(raindropTool,viewToolBar.GetControls.Count)\n viewToolBar.Add(watershedTool,viewToolBar.GetControls.Count)\n \n ' write out \"Loaded\" into the preference dictionary\n self. GetPreferences.Add(\"Loaded\",TRUE)\n viewDocGUI.SetModified(TRUE)\n \nend" ) (Script.34 Name: "Hydro.Uninstall" SourceCode: "' Uninstall script\n\n' uninstall user interface components if extension is unloaded, not if \n' project is closed\nif (av.GetProject = NIL) then\n return NIL\nend\nif (av.GetProject.IsClosing) then\n return NIL\nend\n\n' get list of all DocGUI's of type View\nlistOfViewDocGUIs = av.GetProject.FindGUIsFor(View)\n\n' uninstall from all DocGUI's of type View\nfor each viewDocGUI in listOfViewDocGUIs\n \n ' uninstall tools\n viewToolBar = viewDocGUI.GetToolBar\n t = viewToolBar.FindByName(\"Hydro\")\n while (t <> NIL)\n vi ewToolBar.Remove(t)\n t = viewToolBar.FindByName(\"Hydro\")\n end\n \n ' uninstall Hydro menu\n viewMenuBar = viewDocGUI.GetMenuBar\n m = viewMenuBar.FindByName(\"Hydro\")\n while (m <> NIL)\n viewMenuBar.Remove(m)\n m = viewMenuBar.FindByName(\"Hydro\")\n end\n \n ' uninstall any other choice on a menu\n for each aMenu in viewMenuBar.GetControls.Clone\n c = aMenu.FindByName(\"Hydro\")\n while (c <> NIL)\n aMenu.Remove(c)\n c = aMenu.FindByName(\"Hydro\")\n end\n if (aMenu.GetControls.Count = 0) then\n viewMenuBar.Remove(aMenu)\n end\n end\n \n ' let project know that the viewDocGUI has been modified\n viewDocGUI.SetModified(TRUE)\nend\n\n" )