'TAKES A DBF FILE WITH FIELDS NAMED X AND Y (AS POINTS ALONG THE ATREAM SECTION) AND OUTPUTS A SHAPEFILE WITH THE FILEDS - AVERAGE DEPTH, CROSS-SECTIONAL AREA AND WETTED PERIMETER 'LOADING SCRIPTS ' 1. Double-click on an empty area on the bar containing all buttons, The "Customize" dialog appears ' 2. In the "Type" pull-down, select "View" ' 3. In the "Category" pull-down, select "Buttons", The display right below the pull down changes to show an array of buttons ' 4. Slide the scrollbar (below the button display) to the right and select the last button by clicking on it, Now click on "New" ' 5. A new blank button appears. Double-click on the blank area to the right of the entry "Click" (just below the button display) ' 6. The "Script Manager" Dialog appears, Click on "New", Enter any name in the input box that appears (prefix it with "Z_" so that it goes in the last) ' 7. A new blank script document (With the name just specified) appears. Delete whatever is on it... ' 8. Either copy-paste this ENTIRE script on the document, or, click on the button with the open-folder icon (tooltip reads "Load text file") and navigate to this file ' 9. Either done, click on the button with the tick-mark icon ("compile"). If spatial analyst is not loaded, there will be some error message, Load it ' 10. After the script is compiled (the tick-mark buton should be grayed out), close the script window and return to the view ' 11. Click on the new button to run the script theView = av.GetActiveDoc TheFiles=FileDialog.ReturnFiles({"*.dbf"},{"Cross-section file"},"Specify cross Section DBF",0) for each TheFile in TheFiles FileBase=TheFile.GetBaseName.AsString FileStub=FileBase.Left(FileBase.Count-4) TheLF =LineFile.Make((FileStub+"_Data.txt").AsFileName, #FILE_PERM_WRITE) TheFtab =Ftab.MakeNew((FileStub+"_Poly.shp").AsFileName, Polygon) AreaFld=Field.Make("Area",#FIELD_DECIMAL,12,6) PeriFld=Field.Make("Peri",#FIELD_DECIMAL,12,6) WPeriFld=Field.Make("W_Peri",#FIELD_DECIMAL,12,6) SecWFld=Field.Make("S_Width",#FIELD_DECIMAL,12,6) ADepFld=Field.Make("Av_Dep",#FIELD_DECIMAL,12,6) FieldList={AreaFld,PeriFld,WPeriFld,SecWFld,ADepFld} TheFtab.AddFields(FieldList) TheVtab=VTab.Make(TheFile,FALSE,FALSE) XField=TheVtab.FindField("X") YField=TheVtab.FindField("Y") PointList={} for each rec in TheVtab TheX=TheVtab.ReturnValue(XField,rec) TheY=TheVtab.ReturnValue(YField,rec) PointList.Add(Point.Make(TheX,TheY)) end avDep=0 toDep=0 for each pt in PointList intY=pt.GetY toDep=toDep+intY end avDep=toDep/PointList.Count X1=PointList.Get(0).GetX X2=PointList.Get(PointList.Count-1).GetX SecW=X2-X1 ThePoly=Polygon.Make({PointList}) TheRec=TheFtab.AddRecord TheFtab.SetValue(TheFtab.FindField("Shape"),TheRec,ThePoly) TheArea=TheFtab.ReturnValue(TheFtab.FindField("Shape"),TheRec).ReturnArea ThePeri=TheFtab.ReturnValue(TheFtab.FindField("Shape"),TheRec).ReturnLength TheFtab.SetValue(AreaFld,TheRec,TheArea) TheFtab.SetValue(PeriFld,TheRec,ThePeri) TheFtab.SetValue(WPeriFld,TheRec,ThePeri-SecW) TheFtab.SetValue(SecWFld,TheRec,SecW) TheFtab.SetValue(ADepFld,TheRec,avDep) TheFtab.SetEditable(FALSE) ' TheView.AddTheme(FTheme.Make(TheFtab)) TheLF.WriteELT("Cross-Sectional Area: "+TheArea.AsString) TheLF.WriteELT("Cross-Section Perimeter: "+ThePeri.AsString) TheLF.WriteELT("Wetted Perimeter: "+(ThePeri-SecW).AsString) TheLF.WriteELT("Width of Cross-Section: "+SecW.AsString) TheLF.WriteELT("Average Depth: "+avDep.AsString) end