/3.2 (Extension.1 Name: "LineSlope Analyst Extension" Dependencies: "$AVEXT/spatial.avx\n" FirstRootClassName: "List" Roots: 2 Roots: 3 Roots: 21 Roots: 22 Roots: 23 Roots: 24 Roots: 25 Roots: 26 Roots: 27 Roots: 28 Version: 32 About: "Calculates the slope of lines based on a value grid.\nCalculation by elevation difference and distance along the line.\nBy Phil Hurvitz \nCreation date: 2003.04.14\nCreated from: lineslope_builder_20030410b.apr" InstallScript: 29 UninstallScript: 30 ExtVersion: 1 ) (List.2 ) (List.3 Child: 4 Child: 13 ) (List.4 Child: 5 Child: 9 Child: 12 ) (List.5 Child: 6 Child: 7 Child: 8 ) (AVStr.6 S: "View" ) (AVStr.7 S: "ButtonBar" ) (AVStr.8 S: "View.LineSlopeCalculator" ) (Butn.9 Help: "LineSlope//Calculates slope for each line." Tag: "LSSpace" ObjectTag: 10 Update: "View.LineSlopeButtonUpdate" Icon: 11 Click: "View.LineSlopeCalculator" ) (AVStr.10 S: "PMHxx12345A" ) (AVIcon.11 Name: "SortDescending2" Res: "Icons.SortDescending2" ) (Numb.12 N: 25.00000000000000 ) (List.13 Child: 14 Child: 18 Child: 20 ) (List.14 Child: 15 Child: 16 Child: 17 ) (AVStr.15 S: "Table" ) (AVStr.16 S: "ButtonBar" ) (AVStr.17 S: "Table.LineSlope.Pegger_Add_on" ) (Butn.18 Icon: 19 Click: "Table.LineSlope.Pegger_Add_on" ) (AVIcon.19 Name: "P" Res: "Icons.P" ) (Numb.20 N: 25.00000000000000 ) (List.21 ) (List.22 ) (Script.23 Name: "View.LineSlopeCalculator" SourceCode: "'-----------------------------\n' Calculates the slope of lines based on an underlying grid theme\n' Phil Hurvitz \n\n'-----------------------------\n' Get the title of the ArcView app window \ntheTitle = av.GetName\n\n'-----------------------------\n' Get themes in the view\nviewThe = av.GetActiveDoc\nunitsLinear = viewThe.GetUnits\nif ( unitsLinear = #UNITS_LINEAR_UNKNOWN ) then\n MsgBox.Error ( \"View Properties > Map Units must be set!\", \"\" )\n Return Nil\nend\n\ntheThemes = viewThe.GetThemes \n\n'-----------------------------\n' Bail if there are no themes\nif (theThemes.Count = 0) then\n Return Nil\nend\n\n'-----------------------------\n' Make empty lists of the line themes\ntheLThemes = {}\n\n'-----------------------------\n' Populate the line and grid themes lists\nfor each theTheme in theThemes\n if (theTheme.GetSrcName.GetSubName.Lcase.Left(3) = \"arc\") then\n theLThemes.Add(theTheme)\n end\nend\n\n'-----------------------------\n' Bail if we don't have Line theme\nif (theLThemes.Count = 0) then\n Return Nil\nend\n\n'-----------------------------\n' get grid themes\nlistGThemes = av.Run ( \"00.View.GetGThemes\", Nil )\n\n'-----------------------------\n' Bail if we don't have grid themes\nif (listGThemes.Count = 0) then\n Return Nil\nend\n\n'-----------------------------\n' Get the line theme\ntheLTheme = MsgBox.ListAsString(theLThemes, \"Select line theme\", \"Select\")\n\n'-----------------------------\n' Bail if the line theme is not selected\nif (theLTheme = Nil) then\n Return Nil\nend\n\n'-----------------------------\n ' side slope\nstrSideSlopeDist = MsgBox.Input ( \"Side slope distance\", \"Enter distance in current map units\", \"60\" )\nif ( strSideSlopeDist = Nil ) then\n Return Nil\nend\n\nif ( strSideSlopeDist.IsNumber.Not ) then\n MsgBox.Error ( \"Side slope distance must be numeric.\", \"\" )\n Return Nil\nelse\n numSideSlopeDist = strSideSlopeDist.AsNumber\nend\n\n'-----------------------------\n' Get the Line theme's FTab\ntheFTab = theLTheme.GetFTab\n\n'-----------------------------\n' Bail if the line FTab cannot be edited\nif (theFT ab.CanEdit) then\n theFTabIsEditable = theFTab.IsEditable\nelse\n MsgBox.Error(\"Cannot edit the Line theme table\", \"Error\")\n Return Nil\nend\n\n'-----------------------------\n' get the grid theme\nthemeGrid = MsgBox.ListAsString ( listGThemes, \"Select Z-value grid theme\", \"Select\" )\n\n'-----------------------------\n' Get the extents of the themes\ntheGridExtent = themeGrid.ReturnExtent\ntheLineExtent = theLTheme.ReturnExtent\n\n'-----------------------------\n' Check to see if the themes share the same space\nif (t heGridExtent.IntersectWith(theLineExtent) = Nil) then\n MsgBox.Error(\"Themes do not overlap\", \"Error\")\n Return Nil\nend\n\n'-----------------------------\n' Make the line FTab editable if necessary\nif (theFTabIsEditable.Not) then\n theFTab.SetEditable(True)\nend\n\n'-----------------------------\nlistFieldsToAdd = {}\n\n' Add the slope field if necessary\ntheSlopeField = theFTab.FindField (\"Lin_slp_pc\")\nif (theSlopeField = Nil) then\n theSlopeField = Field.Make(\"Lin_slp_pc\", #FIELD_DECIMAL, 6, 1)\n listFieldsToA dd.Add ( theSlopeField )\nend\n\n' Add the side slope field if necessary\ntheSideSlopeField = theFTab.FindField (\"Sid_slp_pc\")\nif (theSideSlopeField = Nil) then\n theSideSlopeField = Field.Make(\"Sid_slp_pc\", #FIELD_DECIMAL, 6, 1)\n listFieldsToAdd.Add ( theSideSlopeField )\nend\n\n' Add the length field if necessary\ntheLengthField = theFTab.FindField (\"Length\")\nif (theLengthField = Nil) then\n theLengthField = Field.Make(\"Length\", #FIELD_DECIMAL, 16, 2)\n listFieldsToAdd.Add ( theLengthField )\nend\n\n\ntheFTab.Ad dFields( listFieldsToAdd )\n\n\n'-----------------------------\n' Get selected records or the full set\nif (theFTab.GetNumSelRecords > 0) then\n theSelection = theFTab.GetSelection\n theCount = theSelection.Count\nelse\n theSelection = theFTab\n theCount = theFTab.GetNumRecords\nend \n \n'-----------------------------\n' Get the shape field from the line FTab\ntheShapeField = theFTab.FindField(\"Shape\")\n\n'-----------------------------\n' Show the stop button\n'av.ShowStopButton\n\n'-----------------------------\n' Init ialize the record number counter\ntheRecNum = 0\n\n' Calculate slope for each line\nfor each theRec in theSelection \n\n '-----------------------------\n 'doMore = av.SetWorkingStatus \n 'if (not doMore) then \n ' break \n 'end\n\n theRecNum = theRecNum + 1\n \n '-----------------------------\n ' Set the application window title \n av.SetName\n (\"Calculating slope. Progress:\" ++ \n ((theRecNum / theCount) * 100).SetFormat(\"dd\").AsString + \"%\")\n \n '---------------------------- -\n 'Get the line\n theLine = theFTab.ReturnValue(theShapeField, theRec)\n \n '-----------------------------\n ' Get the starting and ending points\n theP0 = theLine.Along(0)\n theP1 = theLine.Along(100)\n numX0 = theP0.GetX\n numY0 = theP0.GetY\n numX1 = theP1.GetX\n numY1 = theP1.GetY\n numXDelta = numX1 - numX0\n numYDelta = numY1 - numY0\n \n '-----------------------------\n ' Get the Z values at the start and end\n theZ0 = av.Run (\"00.View.GetGridCellValue\", {theP0, themeGrid})\n theZ 1 = av.Run (\"00.View.GetGridCellValue\", {theP1, themeGrid}) \n\n \n '-----------------------------\n ' If either of the Z values is null, continue\n ' or else calculate the slope\n if ((theZ0 = Nil) or (theZ1 = Nil)) then\n theFTab.SetValue(theSlopeField, theRec, -99.9)\n else\n \n ' Get the Z difference\n theZDiff = (theZ0 - theZ1).Abs\n \n ' Get the line length\n theLength = theLine.ReturnLength\n \n ' Calculates the slope of the line in percent\n theSlope = (theZDiff / theLength) * 100\n \n ' Places the value back on the table\n theFTab.SetValue(theLengthField, theRec, theLength)\n theFTab.SetValue(theSlopeField, theRec, theSlope)\n \n end\n\n '-----------------------------\n ' side slopes\n ' get the central point on the line\n pointMid = theLine.Along ( 50 )\n numXMid = pointMid.GetX\n numYMid = pointMid.GetY\n \n ' get the angle of the overall line to get the perpendicular\n numRadians = ( numYDelta / numXDelta ).Atan\n numRadia nsPerpendicular = numRadians + ( number.GetPi / 2 )\n \n numX10 = numXMid + ( numRadiansPerpendicular.Cos * numSideSlopeDist )\n numY10 = numYMid + ( numRadiansPerpendicular.Sin * numSideSlopeDist )\n numX20 = numXMid - ( numRadiansPerpendicular.Cos * numSideSlopeDist )\n numY20 = numYMid - ( numRadiansPerpendicular.Sin * numSideSlopeDist )\n \n point10 = Point.Make ( numX10, numY10 ) \n point20 = Point.Make ( numX20, numY20 )\n\n '-----------------------------\n ' Get the Z values at the start a nd end of the side slope lines\n numZ10 = av.Run (\"00.View.GetGridCellValue\", {point10, themeGrid})\n numZ20 = av.Run (\"00.View.GetGridCellValue\", {point20, themeGrid})\n\n '-----------------------------\n ' If either of the Z10 or Z20 values is null, continue\n ' or else calculate the slope\n if (( numZ10 = Nil ) or (numZ20 = Nil )) then\n theFTab.SetValue(theSideSlopeField, theRec, -99.9)\n else\n \n ' Get the Z difference\n numZDiffSideSlope = ( numZ20 - numZ10 ).Abs\n \n ' Get the line length\n numLengthSideSlope = numSideSlopeDist * 2\n \n ' Calculates the slope of the line in percent\n numSideSlope = (numZDiffSideSlope / numLengthSideSlope) * 100\n \n ' Places the value back on the table\n theFTab.SetValue(theSideSlopeField, theRec, numSideSlope)\n \n end \n \nend\nav.ClearStatus\n\n'-----------------------------\n' Go back to previous edit state\ntheFTab.SetEditable(theFTabIsEditable)\n\n'-----------------------------\n' Report\nMsgBox.Info ( \"Proce ss complete. Null slope coded as -99\", \"\" )\n\n'-----------------------------\n' Restore the title of the application window\nav.SetName(\"ArcView GIS 3.2\")" ) (Script.24 Name: "View.LineSlopeButtonUpdate" SourceCode: "' Check to see if line and (Surface or Grid) themes exist\n' To turn on the button\n\n'-----------------------------\n' Get the controls\ntheCtrls = {}\ntheControls = av.GetActiveGUI.GetButtonBar.GetControls\nfor each theCtrl in theControls\n if (theCtrl.GetObjectTag <> Nil) then\n if (theCtrl.GetObjectTag.Left(10) = \"PMHxx12345\") then\n theCtrls.Add(theCtrl)\n end\n end\nend\n\n'-----------------------------\n' Turn off if no Spatial or 3D\nif ((Extension.Find(\"Spatial Analyst\") = Nil) and\n (Extens ion.Find(\"3D Analyst\") = Nil)) then\n for each theCtrl in theCtrls\n theControlEnabledState = False\n theCtrl.SetEnabled(theControlEnabledState)\n end\n Return Nil\nend\n\n\n'-----------------------------\n' Set off to begin\ntheControlEnabledState = FALSE\n\n'-----------------------------\n' turn on if there is one line theme\nfor each t in av.GetActiveDoc.GetThemes\n if (t.GetSrcName.GetSubName.LCase.Left(3) = \"arc\") then\n theControlEnabledState = TRUE\n break\n end\nend\n\n'-------------------- ---------\n' turn each control on\nfor each theCtrl in theCtrls\n theCtrl.SetEnabled(theControlEnabledState)\nend\n\n'-----------------------------\n' If the control is off, exit\nif (theControlEnabledState.Not) then\n Return Nil\nend\n\n'----------------------------\n' If Spatial is on\nif ((Extension.Find(\"Spatial Analyst\") <> Nil) and\n (Extension.Find(\"3D Analyst\") <> Nil)) then\n\n theScript = Script.Make\n (\n \"theCtrls = Self.Get(0)\" + nl +\n \"theControlEnabledState = Self.Get(1)\" + nl +\n \"theView = av.GetActiveDoc\" + nl +\n \"for each t in theView.GetThemes\" + nl +\n \" if ( (t.Is(GTHEME)) or (t.Is(STheme)) ) then \" + nl +\n \" theControlEnabledState = TRUE\" + nl +\n \" break\" + nl +\n \" else \" + nl +\n \" theControlEnabledState = FALSE\" + nl +\n \" end\" + nl +\n \"end\" + nl +\n \n \"for each theCtrl in th eCtrls\" + nl +\n \" theCtrl.SetEnabled(theControlEnabledState)\" + nl +\n \"end\" + nl + \n \n \"\")\n \n theScript.DoIt({theCtrls, theControlEnabledState})\n\n'----------------------------\n' If Spatial is on\nelseif ((Extension.Find(\"Spatial Analyst\") <> Nil) and\n (Extension.Find(\"3D Analyst\") = Nil)) then\n\n theScript = Script.Make\n (\n \"theCtrls = Self.Get(0)\" + nl +\n \"theControlEnabledState = Self.Get(1)\" + nl +\n \"theView = av.GetActiveDoc\" + nl +\n \"for each t in theView.GetThemes\" + nl +\n \" if (t.Is(GTHEME)) then \" + nl +\n \" theControlEnabledState = TRUE\" + nl +\n \" break\" + nl +\n \" else \" + nl +\n \" theControlEnabledState = FALSE\" + nl +\n \" end\" + nl +\n \"end\" + nl +\n \n \"for each theCtrl in theCtrls\" + nl +\n \" theCtrl.Set Enabled(theControlEnabledState)\" + nl +\n \"end\" + nl + \n \n \"\")\n \n theScript.DoIt({theCtrls, theControlEnabledState})\n \n \n\n'----------------------------\n' If 3D is on\nelseif ((Extension.Find(\"Spatial Analyst\") = Nil) and\n (Extension.Find(\"3D Analyst\") <> Nil)) then\n\n\n theScript = Script.Make(\n \"theCtrls = Self.Get(0)\" +nl +\n \"theControlEnabledState = Self.Get(1)\" +nl +\n \"theView = av.GetActiveDoc\" + nl +\n \"for each t in theView.GetThemes\" + nl +\n \" if (t.Is(STheme)) then \" + nl +\n \" theControlEnabledState = TRUE\" + nl +\n \" break\" + nl +\n \" else \" + nl +\n \" theControlEnabledState = FALSE\" + nl +\n \" end\" + nl + \n \"end\" + nl +\n \n \"for each theCtrl in theCtrls\" + nl +\n \" theCtrl.SetEnabled(theControlEnabledState)\" + nl +\n \"end\" + nl + \n \n \"\")\n \n theScript.DoIt({theCtrls, theControlEnabledState})\n\nend\n" ) (Script.25 Name: "00.View.GetGridCellValue" SourceCode: "thePoint = Self.Get(0)\ntheGTheme = Self.Get(1)\ntheGrid = theGTheme.GetGrid\nReturn theGrid.CellValue(thePoint, Prj.MakeNull)\n" ) (Script.26 Name: "00.View.GetGThemes" SourceCode: "' Get themes in the view \ntheThemes = av.GetActiveDoc.GetThemes \n' Get the GThemes \nlistGThemes = {} \nfor each theTheme in theThemes \n if (theTheme.Is(GTheme)) then \n listGThemes.Add(theTheme) \n end \nend \nReturn listGThemes\n" ) (Nil.27 ) (Script.28 Name: "Table.LineSlope.Pegger_Add_on" SourceCode: "' adds and calculates \n\n' SlopeClass (1 = 0-25%, 2 = 25-45%, 3 = >45%)\n' based on LineSlope's SideSlope values\n\n' add a Grade field (null values)\n' -9999 to 1000 = 5 wide\n\n' add a cost field (null values)\n' $10,000,000.00 is 11 wide w 2 decimals\n\n\n' add \"Road_name\" field based on shapefile name\n\n\n\n\n'--------------------------\n' get the VTab\ntableThe = av.GetActiveDoc\n\nftabThe = tableThe.GetVTab\n\n'--------------------------\n' side slope field\nfieldSideSlope = ftabThe.FindField ( \"sid_slp_pc\" )\nif ( fieldSi deSlope = Nil ) then\n MsgBox.Error ( \"No side slope field. Must Run LineSlope Extension.\", \"\" )\n Return Nil\nend\n\n'--------------------------\n' can it be edited\nif ( ftabThe.CanEdit.Not ) then\n MsgBox.Error ( \"Can not edit table.\", \n \"Check file type or permissions.\" )\n Return Nil\nend\n\n'--------------------------\n' fields\nlistFieldsToAdd = {}\n\nfieldGrade = ftabThe.FindField ( \"Grade\" )\nif ( fieldGrade = Nil ) then\n fieldGrade = Field.Make ( \"Grade\", #FIELD_DECIMAL, 5, 0 )\n listFieldsToAdd.Add ( fie ldGrade )\nend\n\nfieldSlopeClass = ftabThe.FindField ( \"SlopeClass\" )\nif ( fieldSlopeClass = Nil ) then\n fieldSlopeClass = Field.Make ( \"SlopeClass\", #FIELD_DECIMAL, 2, 0 )\n listFieldsToAdd.Add ( fieldSlopeClass )\nend\n\nfieldCost = ftabThe.FindField ( \"Cost\" )\nif ( fieldCost = Nil ) then\n fieldCost = Field.Make ( \"Cost\", #FIELD_DECIMAL, 11, 2 )\n listFieldsToAdd.Add ( fieldCost )\nend\n\n' how wide?\nfnBaseName = ftabThe.GetSrcName.GetFileName.GetBaseName.Substitute ( \".shp\", \"\" )\nnumWidth = fnBaseName.Count\nfi eldName = ftabThe.FindField ( \"Road_Name\" )\nif ( fieldName = Nil ) then\n fieldName = Field.Make ( \"Road_Name\", #FIELD_CHAR, numWidth, 0 )\n listFieldsToAdd.Add ( fieldName )\nend\n\n'--------------------------\n' is the VTAb editable?\nif ( ftabThe.IsEditable ) then\n boolEditState = True\nelse\n boolEditState = False \n ftabThe.SetEditable ( True )\nend\n\n'--------------------------\n' add the fields\nftabThe.AddFields ( listFieldsToAdd )\n\n'--------------------------\n' edit selection or all?\nbmSel = ftabThe.GetSele ction\nif ( ftabThe.GetSelection.Count = 0 ) then\n bmSel = ftabThe\nend\n\n'--------------------------\n' calculate values\nfor each numRec in bmSel\n\n ' slopes\n if (\n ( ftabThe.ReturnValue ( fieldSideSlope, numRec ) >= 0 ) and\n ( ftabThe.ReturnValue ( fieldSideSlope, numRec ) < 25 )\n ) then\n ftabThe.SetValue ( fieldSlopeClass, numRec, 1 )\n elseif (\n ( ftabThe.ReturnValue ( fieldSideSlope, numRec ) >= 25 ) and\n ( ftabThe.ReturnValue ( fieldSideSlope, numRec ) < 45 )\n ) then\n ftabThe.SetValue ( fieldSlopeClass, numRec, 2 )\n elseif\n ( ftabThe.ReturnValue ( fieldSideSlope, numRec ) >= 45 ) then\n ftabThe.SetValue ( fieldSlopeClass, numRec, 3 )\n else\n ftabThe.SetValue ( fieldSlopeClass, numRec, -9 )\n end\n\nend\n\n' calculate name\nftabThe.Calculate ( fnBaseName.Quote, fieldName )\n\n\n'--------------------------\n' return to previous edit state\nftabThe.SetEditable ( boolEditState )\n" ) (Script.29 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 ' find the location of the \"Help.Tool\" button\n theHelpControl = theControlSet.FindByScript(\"Help.Tool\")\n theHelpControlPosition = theControlSet.GetControls.Find(theHelpControl)\n theSpace = Space.Make\n theSpace.SetObjectTag(\"PMHxx12345A\")\n theControlSet.Add(theSpace,theHelpControlPosition - 1)\n theControl.SetObjectTag(\"PMHxx12345B\")\n theControlSet.Add(theControl,theHelpControlPosition - 1)\n \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 m Menu=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 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 control Index\n theCindex=totalControl.get(2)\n\n 'Find the DocGUI\n theControlDoc=av.getproject.findGUI(aControl.get(0))\n if (theControlDoc=NIL) t hen \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)).GetToolBar\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 them selves\n" ) (Script.30 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\nend\n \n' Remove any control with the ObjectTag I set\ntheControls = theControlSet.GetControls\nfor each theCtrl in theControls.Clone\n if (theCtrl.GetObjectTag <> Nil) then\n if (theCtrl.GetObjectTag.Left(10) = \"PMHxx12345\") then\n theControlSet.Remove(theCtrl)\n end\n end\nend\n\n\n'And the scripts delete themselves\n\n\nav.getproject.setmodified(true)\n" )