Good afternoon allHaving some issues with the Select By Location function returning an odd error message that I can't shake out.I'm pretty confident it's falling over on the first half of the if..else command. This is in there to differentiate between features which need to be checked with a buffer distance and those that don't (this bit of code will be iterated through all the features in a dataset individually).Code (or snippets of):sqlquery = OIDFieldName + "=" + str(oid)
dataset_tocheck_lyr = arcpy.MakeFeatureLayer_management(dataset_tocheck, "dataset_tocheck_lyr", "\"sqlquery\"")
themelocation_lyr = arcpy.MakeFeatureLayer_management(themelocation, "themelocation_lyr") #create temp layer of theme location
bufferdist = str(int(overlayfeature.DIST)) + " Meters"
.
.
.
if int(overlayfeature.DIST) == 0:
arcpy.SelectLayerByLocation_management(themelocation_lyr, "INTERSECT", dataset_tocheck_lyr, "","NEW_SELECTION")
output_text.write("Buffer is zero, not factoring into SBL\n\n")
else:
arcpy.SelectLayerByLocation_management(themelocation_lyr, "INTERSECT", dataset_tocheck_lyr, "\"bufferdist\"", "NEW_SELECTION")
output_text.write("Buffer is not zero, factoring additional string into SBL\n\n")
Error:Traceback (most recent call last):
File "C:\Python26\ArcGIS10.0\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript
exec codeObject in __main__.__dict__
File "U:\PythonValuesChecking\Python Scripts\ValuesChecker.py", line 74, in <module>
arcpy.SelectLayerByLocation_management(themelocation_lyr, "INTERSECT", dataset_tocheck_lyr, "","NEW_SELECTION")
File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\management.py", line 4381, in SelectLayerByLocation
raise e
ExecuteError: ERROR 999999: Error executing function.
An invalid SQL statement was used.
An invalid SQL statement was used.
An invalid SQL statement was used.
An invalid SQL statement was used.
Failed to execute (SelectLayerByLocation).
This has thrown a few other problems at me, which I have so far been able to solve, but this one has got me stuffed.Any thoughts?