I am probably making a simple mistake but can't seem to figure it out, only a beginner.The Select By Location Script is working and it exports to excel when it is run from Python GUI, it also works in ArcGIS when i use the Pyton Shell but when i try to make a tool out of it in ArcGIS it does not work. The error was ERROR 000714, which the help says there is an error in the script. If it works in Python GUI and in ArcGIS Python Shell (picture below) , why does this error appear when i try to run the custom tool? any ideas?
import arcpy
arcpy.env.workspace = "Z:\GIS TEST\Select_by_Location"
BOL='Breakout_Location.shp'
arcpy.MakeFeatureLayer_management('Bld_Locations.shp', 'Bld_Locations_lyr')
arcpy.SelectLayerByLocation_management('Bld_Locations_lyr', "WITHIN_A_DISTANCE", 'Breakout_Location.shp', "2000 Meters", "NEW_SELECTION")
arcpy.SetParameterAsText(0, BOL)
arcpy.MakeFeatureLayer_management('Bld_Locations.shp', 'Bld_Locations2_lyr')
arcpy.SelectLayerByLocation_management('Bld_Locations_lyr', "WITHIN_A_DISTANCE", 'RiversITM.shp', "100 Meters", "ADD_TO_SELECTION")
CSVFile = 'Z:\\Excel.csv'
fields = [f.name for f in arcpy.ListFields('Bld_Locations_lyr')]
for i,f in enumerate(fields):
if f == 'Shape' or f == 'Shape_Length' or f == 'OBJECTID':
del fields[i]
with open(CSVFile, 'w') as f:
f.write(','.join(fields)+'\n') #csv headers
with arcpy.da.SearchCursor('Bld_Locations_lyr', fields) as cursor:
for row in cursor:
f.write(','.join([str(r) for r in row])+'\n')
There will only be one input into the Custom Tool, that is why i only used one parameter.