'***************************************** ' Name: swbp.extract ' Headline: ' Self: ' Returns: ' Description: This program clip a grid Theme ' based on selected polygons in a polygon ' coverage. ' ' Topics: ' Search Keys: ' Requires: ' History: Modified from hydro.ExtByPly ' Modified 4/1/98 by Patrice Melancon to rename the script gridclip.ave. Otherwise, used as it was. '***************************************** theView = av.getactivedoc theThemes = theView.getthemes if (nil = theThemes) then exit end if (theThemes.count < 2) then msgbox.error("At least 2 themes must be in the View","Error") exit end polythemes=list.make gridthemes=list.make for each t in thethemes if (t.getclass.getclassname = "GTheme") then gridthemes.add(t) elseif (t.getftab.findfield("shape").gettype=#field_shapepoly) then polythemes.add(t) end end GridTheme=Msgbox.choiceasstring(gridthemes,"Choose Grid to be clipped?","Clip Grid") if (gridTheme = NIL) then exit end clipTheme=Msgbox.Choiceasstring(polythemes,"Which polygon theme is the clipping theme?","Clip Grid") if (clipTheme = NIL) then exit end '--- build a polygon which is the union of all selected polygons '--- if no polygons are selected, then select all polygons in the '--- clipTheme clipftab=cliptheme.getftab shapefield=clipftab.findfield("Shape") clipselection = clipftab.getselection if (clipselection.count=0) then clipftab.getselection.setall clipftab.updateselection end rec1=clipftab.getselection.getnextset(-1) totalshape=clipftab.returnvalue(shapefield,rec1) for each rec in clipftab.getselection totalshape=totalshape.returnunion(clipftab.returnvalue(shapefield, rec)) end theclipshape = totalshape sourceGrid=GridTheme.GetGrid '--set the extent before extracting ae = theView.GetExtension(AnalysisEnvironment) ae.SetExtent(#ANALYSISENV_VALUE,theclipshape.ReturnExtent) ae.Activate CutGrid=SourceGrid.ExtractByPolygon(theclipshape,prj.makeNull,False) cutFN=av.GetProject.GetWorkDir.MakeTmp(GridTheme.GetName,"") CutGrid.ReName(cutFN) outGTheme=GTheme.Make(CutGrid) outGTheme.SetName(cutFN.getBaseName) theView.AddTheme(outGTheme) outGTheme.SetVisible(true) '' 91. e:\washita\swbpscript\swbp.clipgrid of 67 lines, '' 130. z:\seann\washita\swbpscript\swbp.clipgrid of 68 lines,