' Name: View.ShapeToGenerate ' ' Title: Exports active theme to ARC/INFO export format ' ' Topics: GeoData ' ' Description: Exports the active themes to ARC/INFO Export (Generate) ' format files. Each active theme will require the user to specify an ' output file name. The format of the export file with be either POINT, ' LINE, or POLYGON depending upon the type of Shape Field found in the ' Theme FTab (the Enum Type FieldEnum). ' ' The user will be prompted for the field from which to create IDs in ' the generate file. If is selected the ID for the feature will ' be set to the current FTab record number. ' ' In the case of overlapping polygons, the data should be further ' converted into an ARC/INFO region coverage with the REGIONCLASS ' command. ArcView polygon shapes may need to be modeled in ARC/INFO as ' regions to handle the case of polygons with multiple parts. ' ' Following conversion of the generate file to an ARC/INFO coverage ' the Theme's FTab can be exported to an INFO file that can be joined to ' the coverage Feature Attribute Table (FAT) to restore all attributes as ' found in the original Theme. Consult ARC/INFO command documentation for ' JOINITEM and related commands. ' ' When creating polygon format Generate files the AUTO keyword is used ' along with the feature ID to indicate that labels will be automatically ' created when coverages are imported using ARC/INFO Generate. Consult ' the ARC/INFO Generate documentation for additional options and discussion. ' ' Requires: A View must be the active document. ' ' Self: ' ' Returns: ' ' View should be the Active Document ' theView = av.GetActiveDoc ' Establish output precision... ' Script.The.SetNumberFormat( "d.dddddd" ) for each t in theView.GetActiveThemes defaultName = FN.Make("$HOME").MakeTmp(t.GetName.LCase,"gen") ungenFileName = FileDialog.Put( defaultName,"*.gen","Export"++t.GetName ) if (ungenFileName = nil) then exit else exportFile = LineFile.Make(ungenFileName, #FILE_PERM_WRITE) end ' The ARC/INFO generate format uses the ID number of the feature ' in the export file to provide a means for joining attributes. ' When the generate file is converted to an ARC/INFO coverage the ID ' as found in the generate file will be used as the ID in the coverage ' feature attribute table (the .AAT or .PAT). Allow the user to specify ' the ID field to use or default to the record number.... ' fieldList = t.GetFTab.GetFields.Clone fieldList.Insert( "" ) idField = MsgBox.ChoiceAsString( fieldList, "Select ID field for export file:","Choose ID Field" ) if ( idField = nil ) then exit elseif ( idField = "" ) then useID = false else useID = true end theFTab = t.GetFTab shapeField = theFTab.FindField( "Shape" ) shapeType = shapeField.GetType numRecs = theFTab.GetNumRecords av.ShowStopButton av.ShowMsg( "Exporting"++t.GetName+"..." ) for each recNum in theFTab currentShape = theFTab.ReturnValue( shapeField, recNum ) if ( useID ) then id =theFTab.ReturnValueString( idField, recNum ) else id = (recNum + 1).SetFormat("d").AsString end if (shapeType = #FIELD_SHAPEPOINT) then ' ARC/INFO POINT format export file... ' Xvalue = currentShape.GetX.AsString Yvalue = currentShape.GetY.AsString outputLine = id+", "+Xvalue+", "+Yvalue exportFile.WriteElt( outputLine ) elseif (shapeType = #FIELD_SHAPEMULTIPOINT) then ' ARC/INFO POINT format export file... ' pointList = currentShape.AsList for each pt in pointList Xvalue = pt.GetX.AsString Yvalue = pt.GetY.AsString outputLine = id+", "+Xvalue+", "+Yvalue exportFile.WriteElt( outputLine ) end elseif (shapeType = #FIELD_SHAPELINE) then ' ARC/INFO LINE format export file... ' exportFile.WriteElt( id ) shapeList = currentShape.AsList for each shapePart in shapeList for each xyPoint in shapePart outputLine = xyPoint.GetX.AsString+", " +xyPoint.GetY.AsString exportFile.WriteElt( outputLine ) end exportFile.WriteElt( "END" ) end elseif (shapeType = #FIELD_SHAPEPOLY) then ' ARC/INFO POLYGON format export file... ' exportFile.WriteElt( id ) 'automatic label generation flag... shapeList = currentShape.AsList kt = 1 for each shapePart in shapeList if (kt > 1) then exportFile.WriteElt( "-9999" ) ' this is the code for holes in polygons end for each xyPoint in shapePart outputLine = xyPoint.GetX.AsString+", " +xyPoint.GetY.AsString exportFile.WriteElt( outputLine ) end exportFile.WriteElt( "END" ) kt = kt + 1 end end progress = (recNum / numRecs) * 100 proceed = av.SetStatus( progress ) if ( proceed.Not ) then av.ClearStatus av.ShowMsg( "Stopped" ) exit end end exportFile.WriteElt( "END" ) exportFile.Close av.ClearStatus av.ClearMsg end