'--------------------------------- 'Name: grid2shp.bat 'Date: 1-25-01 'Author: Marco Morais ' ' prompts the user for grids on disk ' ' prompts the user if feature type of ' exported grids should be poly or polyline ' ' exports each grid to shapefile ' of same name in same directory ' 'Returns: 'NILL ' 'Called By: 'MANY ' 'Calls: 'None ' 'Arguments: 'None '--------------------------------- MsgBox.Report("grid2shp.bat" + NL + "1. prompts the user for grids on disk" + NL + "2. prompts the user if feature type of" + NL + " exported grids should be poly or polyline" + NL + "3. exports each grid to shapefile of same" + NL + " name in same directory", "About Script....") '--------------------------------------- 'retrieve list of grids to export '--------------------------------------- theExportGridsSrcNameList = SourceDialog.ShowClass("Select the Grid(s) to export as shapefiles", Grid) if ( theExportGridsSrcNameList.Count = 0 ) then return NIL end '--------------------------------------- 'retrieve feature type to be exported '--------------------------------------- isPolygon = MsgBox.YesNo("Do you want to export the Grids to Polygon (YES) or PolyLine (NO) feature types?", "Polygon or PolyLine", TRUE) if ( isPolygon = NIL ) then return NIL end '--------------------------------------- 'retrieve weeding enabled '--------------------------------------- isWeedingEnabled = MsgBox.YesNo("Do you want to enable weeding of features?", "Enable Weeding", TRUE) if ( isWeedingEnabled = NIL ) then return NIL end '--------------------------------------- 'retrieve binary enabled (polyline only) '--------------------------------------- if ( isPolygon = FALSE ) then isBinaryEnabled = MsgBox.YesNo("Do you want to consider all values other than NO DATA as linear features?", "Enable Binary", TRUE) if ( isBinaryEnabled = NIL ) then return NIL end end '--------------------------------------- 'make grids from srcnames and export '--------------------------------------- theExportFTabList = List.Make for each srcn in theExportGridsSrcNameList theGrid = Grid.Make(srcn) if ( theGrid.HasError ) then MsgBox.Error("Grid not able to be created", "Error") return NIL end if ( isPolygon = TRUE ) then theFTab = av.Run("Grid.ConvertToPolygon", {theGrid, (srcn.GetFileName.GetName + ".shp"), isWeedingEnabled}) elseif ( isPolygon = FALSE ) then theFTab = av.Run("Grid.ConvertToPolyLine", {theGrid, (srcn.GetFileName.GetName + ".shp"), isBinaryEnabled, isWeedingEnabled}) end if ( theFTab = NIL ) then MsgBox.Error("Unable to create shapefile for: " + srcn.GetFileName.AsString, "Error") continue end theExportFTabList.Add(theFTab) end av.PurgeObjects return NIL