I've made an arcpy script which worked last week, but I placed it somewhere different on my computer. I've made sure all the source files etc. are connected. However now I keep getting an error message when it comes to the erase function, it comes up with the following error:
Traceback (most recent call last):
File "G:\zn\NM\GGB\Applicaties-Admin\Kerngis\ExpImp\Base data\Scripts\List mxd.py", line 22, in <module>
arcpy.Erase_analysis (lyr, Export, Import)
File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\analysis.py", line 176, in Erase
raise e
ExecuteError: ERROR 999999: Error executing function.
The table was not found.
The table was not found. [Kabel_en_leiding_lijnen_Erased]
The table was not found.
The table was not found. [Kabel_en_leiding_lijnen_Erased]
The operation was attempted on an empty geometry.
Failed to execute (Erase).
Failed to execute (Import)
My script is the following:
import arcpy
import arcpy.mapping
Project_number = arcpy.GetParameterAsText(0)
arcpy.env.overwriteOutput = True
mxd = arcpy.mapping.MapDocument("G:\\zn\\NM\\GGB\\Applicaties-Admin\\Kerngis\\ExpImp\\{}\\{}.mxd".format(Project_number, Project_number)) # Uses your currently open MXD
for df in arcpy.mapping.ListDataFrames(mxd, ''): # Loop through dataframes
for lyr in arcpy.mapping.ListLayers(mxd, '', df): # Loop through layers
# Any tools you want to run on each layer go here
Export = "G:\\zn\\NM\\GGB\\Applicaties-Admin\\Kerngis\\ExpImp\\{}\\Export_{}.gdb\\Mask".format(Project_number, Project_number)
Import = "G:\\zn\\NM\GGB\\Applicaties-Admin\\Kerngis\\ExpImp\\{}\\Import_{}.gdb\\{}_Erased"(Project_number, Project_number, lyr)
NewFile = "G:\\zn\\NM\GGB\\Applicaties-Admin\\Kerngis\\ExpImp\\{}\\Import_{}.gdb\\{}_MultipartToSing".format(Project_number, Project_number, lyr)
Merge = "G:\\zn\\NM\GGB\\Applicaties-Admin\\Kerngis\\ExpImp\\{}\\Import_{}.gdb\\{}_Merged".format(Project_number, Project_number, lyr)
arcpy.SelectLayerByLocation_management(lyr, "INTERSECT", Export, "", "NEW_SELECTION", "NOT_INVERT")
arcpy.Erase_analysis (lyr, Export, Import)
arcpy.DeleteFeatures_management (lyr)
arcpy.Append_management(Import, lyr, "NO_TEST")
arcpy.Append_management(NewFile, lyr, "NO_TEST")
I have also tried running these same steps in modelbuilder, to see if it was the script or if something else was going on. The same error occurs, the image below will display my model.
I cannot figure out for the life of me why it is giving me errors. The feature class being used is a line feature class, not sure if that makes a difference.
I am using ArcGIS 10.3.1
print
andarcpy.Exists()
have to say?Export = r"G:\zn\NM\GGB\Applicaties-Admin\Kerngis\ExpImp\{}\Export_{}.gdb\Mask".format(Project_number, Project_number)
); 3) if you can, specify your paths withos.path
; 4) Last but not least: chek if everything (files and folders) exist!