/3.2 (Extension.1 Name: "Get azimuth - distance" FirstRootClassName: "List" Roots: 2 Roots: 3 Roots: 12 Roots: 13 Roots: 14 Version: 32 About: "Get the x, y, distance and azimuth of line segments" InstallScript: 15 UninstallScript: 16 ExtVersion: 1 ) (List.2 ) (List.3 Child: 4 ) (List.4 Child: 5 Child: 9 Child: 11 ) (List.5 Child: 6 Child: 7 Child: 8 ) (AVStr.6 S: "View" ) (AVStr.7 S: "ButtonBar" ) (AVStr.8 S: "getptdata" ) (Butn.9 Help: "Calculate x, y, distance, and azimuth for line segments" HelpTopic: "Calculate x, y, distance, and azimuth for line segments" Icon: 10 Click: "getptdata" ) (AVIcon.10 Name: "Path" Res: "Icons.Path" ) (Numb.11 N: 24.00000000000000 ) (List.12 ) (List.13 ) (Script.14 Name: "getptdata" SourceCode: "theview = av.getactivedoc\nthetheme = MsgBox.Choice(theview.getthemes,\"Select Polygon or Line Theme\", \"Get Vertices\")\nIf (thetheme = nil) then exit end\ntheftab = thetheme.getftab\nif (theftab.GetShapeClass.GetClassName = \"Point\") then\n MsgBox.Error(\"Sorry, the selected theme is does not contain polygons or lines\", \"Get Vertices\")\n exit\n end\nnamefld = MsgBox.Choice(theftab.getfields, \"Select name field for the theme\", \"Get Vertices\")\n\nIf (namefld = nil) then \nexit\nelseif(namefld.asstring = \"Shape\")then\nMsg Box.Error(\"Cannot use Shape as name field\", \"Get Vertices\")\nexit \nend\n\nnametype = namefld.GetType \nshapefld = theftab.findfield(\"shape\")\nsol = \"\"\nwd = av.getproject.getworkdir\nmyfname = (wd.asstring + \"\\lat.dbf\").asfilename\nthevtab = VTab.MakeNew (myfname, dBASE)\n\n\nthetable = Table.Make (theVTab)\nav.getproject.adddoc(thetable)\n\nfdlst = {}\nthevtab.starteditingwithrecovery\n\nnfd = field.Make ( namefld.asstring, nametype , 40, 0 ) \nxfd = field.Make ( \"xcoord\", #FIELD_DECIMAL , 16, 4 ) \nyfd = field.Make ( \"ycoo rd\", #FIELD_DECIMAL , 16, 4 )\ndistfd = field.Make ( \"distance\", #FIELD_DECIMAL, 16, 4 ) \nazifd = field.Make ( \"azimuth\", #FIELD_DECIMAL, 16, 4 ) \nfdlst.add(nfd)\nfdlst.add(xfd)\nfdlst.add(yfd)\nfdlst.add(distfd)\nfdlst.add(azifd)\nthevtab.addfields(fdlst)\n\nthesel = theftab.getselection\nIf (thesel.count = 0) then\n\n \n for each rec in theftab\n ashape = theftab.returnvalue(shapefld, rec)\n aname = theftab.returnvalue(namefld, rec)\n for each part in ashape.aslist\n axold = -999\n ayold = -999\n for each p in part\n \n ax = p.getx\n ay = p.gety\n if( axold = -999 )then\n adist = 0.0\n aazi = 0.0\n else\n axdiff = ax - axold\n aydiff = ay - ayold\n adist = ( (axdiff * axdiff) + (aydiff * aydiff) ).sqrt\n aazit = (aydiff / axdiff).atan\n if( ax > axold )then\n aazi = 90.0 - aazit.asdegrees\n elseif( axold > ax )then\n aazi = 270.0 - aazit.asdegrees\n else\n if( ay > ayold )then\n aazi = 0.0\n else\n aazi = 180.0\n end\n end \n end\n n = thevtab.addrecord\n thevtab.setvalue(nfd, n, aname)\n thevtab.setvalue(xfd, n, ax.asstring)\n thevtab.setvalue(yfd, n, ay.asstring)\n thevtab.setvalue(distfd, n, adist.asstring)\n thevtab.setvalue(azifd, n, aazi.asstring)\n axold = ax\n ayold = ay\n \n end \n end\n \n end\nelse \n for each rec in thesel\n ashape = theftab.returnvalue(shapefld, rec)\n aname = theftab.returnvalue(namefld, r ec)\n for each part in ashape.aslist\n axold = -999\n ayold = -999\n for each p in part\n \n ax = p.getx\n ay = p.gety\n if( axold = -999 )then\n adist = 0.0\n aazi = 0.0\n else\n axdiff = ax - axold\n aydiff = ay - ayold\n adist = ( (axdiff * axdiff) + (aydiff * aydiff) ).sqrt\n aazit = (aydiff / axdiff).atan\n if( ax > axold )then\n aazi = 90.0 - aazit.asdegrees\n elseif( axold > ax )then\n aazi = 270.0 - aazit.asdegrees\n else\n if( ay > ayold )then\n aazi = 0.0\n else\n aazi = 180.0\n end\n end \n end\n n = thevtab.addrecord\n thevtab.setvalue(nfd, n, aname)\n thevtab.setvalue(xfd, n, ax.asstring)\n thevtab.setvalue(yfd, n, ay.asstring)\n thevtab.setvalue(distfd, n, adist.asstring)\n thevtab.setvalue(azifd, n, aazi.asstring)\n axold = ax\n ayold = ay\n \n end \n end\n \n end\nend\n \n\nsaveedits = true\n\ntheVTab.StopEditingWithRecovery(saveEdits)\n'MsgBox.report(sol, \"\")\nadocwi n = thetable.getwin\naDocWin.Activate \n\n\n \n\n\n" ) (Script.15 Name: "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.16 Name: "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" )