' ' Convert polygons to polylines (ESRI script) ' Modified 1 April 2000 ' ' Run from a view with a polygon theme active. ' theView = av.GetActiveDoc thmThemeIn = theView.GetActiveThemes.Get(0) ' Specify the output shapefile... fnDefault = FileName.Make("$HOME").MakeTmp("shape","shp") fnOutput = FileDialog.Put( fnDefault,"*.shp","Output Shape File" ) if (fnOutput = nil) then exit end fnOutput.SetExtension("shp") ftbOutput = FTab.MakeNew( fnOutput, POLYLINE ) ftbOutput.AddFields({Field.Make("ID", #FIELD_LONG, 8, 0)}) ' Use selected shapes if there are any, otherwise iterate ' through the entire FTab... if (thmThemeIn.GetFTab.GetSelection.Count > 0) then colToProcess = thmThemeIn.GetFTab.GetSelection nRecs = colToProcess.Count else colToProcess = thmThemeIn.GetFTab nRecs = colToProcess.GetNumRecords end nCount = 0 nRecsAdded = 0 fldShapeIn = thmThemeIn.GetFTab.FindField("shape") fldShapeOut = ftbOutput.FindField("shape") fldIDOut = ftbOutput.FindField("id") for each r in colToProcess nCount = nCount + 1 av.SetStatus((nCount / nRecs) * 100) shpIn = thmThemeIn.GetFTab.ReturnValue(fldShapeIn,r) ' ' This is the modified line: ' shpNew = Polyline.Make(shpIn.AsList) nRecNew = ftbOutput.AddRecord ftbOutput.SetValue(fldShapeOut,nRecNew,shpNew) ftbOutput.SetValue(fldIDOut,nRecNew,nCount) nRecsAdded = nRecsAdded + 1 end av.SetStatus(100) if (nRecsAdded = 0) then MsgBox.Error("Unable to convert polygons to polylines.", "Convert Polygon to Polyline") exit else MsgBox.Info(nRecsAdded.AsString++"shapes converted.", "Convert Polyline to Polygon") end if (MsgBox.YesNo("Add shapefile as theme to a view?", "Convert Polygon to Polyline", true).Not) then exit end ' Create a list of views and allow the user to choose which view to ' add the new theme to... lstViews = {} for each d in av.GetProject.GetDocs if (d.Is(View)) then lstViews.Add( d ) end end lstViews.Add("") vweAddTo = MsgBox.ListAsString( lstViews,"Add Theme to:", "Convert Polyline to Polygon" ) ' Get the specified view, make the theme, and add it... if (vweAddTo <> nil) then if (vweAddTo = "") then vweAddTo = View.Make vweAddTo.GetWin.Open end thmNew = FTheme.Make( ftbOutput ) vweAddTo.AddTheme( thmNew ) vweAddTo.GetWin.Activate end