I have a python script which dies after the first iteration. It dies on the second feature class to coverage. This also happened in modelbuilder, which is why I went to python hoping it would go away. I can create the coverage on the layer that crashes the script in the standalone tool, but once in the script, after the first iteration, it dies. It makes me think that there is something being held on to in memory by the script or modelbuilder that I am not aware of.
I have tried repairing geometry of the input dataset; ensuring it is singlepart; name chages. None has worked.
View image for error in image. It says invalid topology, but it works fine standalone.
import arcinfo, arcpy, os, sys
from arcpy import env
print 'Starting....'
env.OverWriteOutput = True
arcpy.SetProduct("ArcInfo")
import datetime
import time
ts = time.time()
st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
print st
tbx = arcpy.ImportToolbox(r"C:\Program Files (x86)\ArcGIS\Desktop10.1\ArcToolbox\Toolboxes\Coverage Tools.tbx", "COVG")
SDE = "C:\\Users\\david\\AppData\\Roaming\\ESRI\\Desktop10.1\\ArcCatalog\\p747.sde"
AVI = r"C:\david\delete\AVI.shp"
#AVI = "G:\\ALPAC\\Projects\\P747\\3_Landbase\\Processing\\AVI\\AVI_20141216_Only_polynum.shp"
FMUs = r"C:\david\delete\fmus2.shp"
#FMUs = r"\\silver\\clients\Projects\P747\3_Landbase\LB1\FileGeodatabase\All_Data\All_Data.gdb\ALPAC_Data\Administrative_FMUs"
GDB1 = "\\\\silver\\clients\\Projects\\P747\\3_Landbase\\LB1\\Temp\\"
FCView = "\\\\silver\\clients\\Psrojects\\P747\\3_Landbase\\LB1\\TEMP\\FCView.lyr"
LayerU = r"G:\Projects\P747\3_Landbase\LB1\Multiunion\TEMP\Union_Fwrd"
OutLOC = "\\\\silver\\clients\\Projects\\P747\\3_Landbase\\LB1\\multiunion\\m_20150129\\"
TableView = "\\\\silver\\client\\Projects\\P747\\3_Landbase\\LB1\\Temp\\Tableview.lyr"
FieldMappings = arcpy.FieldMappings()
FieldMap1 = arcpy.FieldMap()
#arcpy.RepairGeometry_management(FMUs)
if arcpy.Exists(FCView):
arcpy.Delete_management(FCView)
arcpy.MakeFeatureLayer_management(FMUs, FCView)
FieldMap1.addInputField(FMUs, 'FMU_NAME')
FieldMappings.addFieldMap(FieldMap1)
r = 1
for row in arcpy.SearchCursor(FCView):
objectid = str(row.getValue("FMU_NAME"))
#print '"FMU_NAME"= {}'.format(objectid)
print 'Working on ' + objectid
FMUNAME = GDB1 + "FMU_" + objectid + ".shp"
AVINAME = GDB1 + "AVI_" + objectid + ".shp"
OUTCOV = OutLOC+ "MU_" + objectid
OUTCOVPOLY = OutLOC+ "MU_" + objectid + " POLYGON"
if arcpy.Exists(FMUNAME):
arcpy.Delete_management(FMUNAME)
if arcpy.Exists(AVINAME):
arcpy.Delete_management(AVINAME)
if arcpy.Exists(OUTCOV):
arcpy.Delete_management(OUTCOV)
if arcpy.Exists(GDB1+ "MUa_" + objectid):
arcpy.Delete_management(GDB1+ "MUa_" + objectid)
if arcpy.Exists(GDB1+ "FMU_" + objectid):
arcpy.Delete_management(GDB1+ "FMU_" + objectid)
if arcpy.Exists(TableView):
arcpy.Delete_management(TableView)
if arcpy.Exists(GDB1 + "AVICV_" + objectid):
arcpy.Delete_management(GDB1 + "AVICV_" + objectid)
if arcpy.Exists(GDB1 + "AVIa_" + objectid + ".shp"):
arcpy.Delete_management(GDB1 + "AVIa_" + objectid + ".shp")
arcpy.SelectLayerByAttribute_management(FCView, "NEW_SELECTION", '"FMU_NAME"=' + "'" + objectid + "'")
print 'Creating FMU shape and coverage for clipping'
arcpy.FeatureClassToFeatureClass_conversion(FCView , GDB1, "FMU_" + objectid, "#", FieldMappings)
arcpy.FeatureclassToCoverage_conversion(FMUNAME + " POLYGON", GDB1 + "FMU_" + objectid, "", "DOUBLE")
print 'Running clips'
arcpy.Clip_COVG(LayerU, GDB1 + "FMU_" + objectid, GDB1+ "MUa_" + objectid)
arcpy.Clip_analysis(AVI, FMUNAME, GDB1 + "AVI_" + objectid)
#print 'Repairing geometry'
#arcpy.RepairGeometry_management(GDB1 + "AVI_" + objectid + ".shp")
print 'Turn AVI into coverage'
#ERROR OCCURS HERE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
arcpy.FeatureclassToCoverage_conversion(AVINAME + " POLYGON", GDB1 + "AVICV_" + objectid, "", "DOUBLE")
print 'Unioning the ' + objectid + " datasets"
arcpy.Union_COVG(GDB1 + "AVICV_" + objectid, GDB1+ "MUa_" + objectid, OutLOC + "MU_" + objectid)
#print 'Running multi-part to single-part'
#arcpy.MultipartToSinglepart_management(GDB1 + "AVIa_" + objectid + ".shp", GDB1 + "AVI_" + objectid)
print 'Calculating fields'
arcpy.MakeTableView_management(OUTCOV +'\\polygon', TableView)
arcpy.AddField_management(TableView, "MKey", "LONG", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
arcpy.CalculateField_management(TableView, "MKey", "( " + str(r) + " * 1000000 ) + !FID!", "PYTHON", "")
arcpy.AddField_management(TableView, "AreaHA", "DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
arcpy.CalculateField_management(TableView, "AreaHA", "!shape.area@hectares!", "PYTHON", "")
print 'Deleting fields'
arcpy.DeleteField_management(TableView, "U20#;U20-ID;U19#;U19-ID;U18#;U18-ID)
#print 'Deleting fields'
#if arcpy.Exists(SDE + objectid + "_tables_v2"):
# arcpy.Delete_management(SDE + objectid + "_tables_v2")
#print 'Table to table'
#arcpy.TableToTable_conversion(TableView, SDE2, objectid + "_tables_v2")
#print 'Deleting fields'
#arcpy.DeleteField_management(TableView, "FEATURE_TY;NAME;TS_BUFF;PLOT_TYPE;DISP_NUM;DISP_TYPE;LANDBASE;RIVBRK;FMU_NAME;MOSA;SLOPE;FIRE_NUMBE;BURNCODE;BURN_CLASS;YEAR;RFMA_NAME;HYD_FEAT;CRPRO_NAME;TYPE;PPA_STAT;DIDS_NUM;DIDS_TYPE;ID;WTRSHED;FN_TYPE;FN_NAME;MUNIC_TYPE;MUNIC_NAME;FMA_STATUS;FEATURE_NA;DFA_STATUS;HY_DIST;HY_SRCE;HY_FEATURE;POLYGON;OWNER_1;STATUS;OWNERSHIP;CATEGORY;OPEN_NUM;COWPER_LOS;RSIID;POLY_NUM")
ts = time.time()
st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
print st
print 'Next....'
r += 1
python 2.7, Arcinfo license and 10.2 Arc
subprocess
(e.g. geonet.esri.com/thread/49275) and I started to investigate that once a few years ago but I think I found that upping the RAM solved my issues and so I abandoned that effort.