On the second iteration of the loop starting line 7 I get the following error. Everything works as intended on the first iteration. Any ideas on why this is failing the second time around?
Error:
Runtime error Traceback (most recent call last): File "", line 10, in File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\management.py", line 7221, in SelectLayerByAttribute raise e ExecuteError: ERROR 000622: Failed to execute (Select Layer By Attribute). Parameters are not valid. ERROR 000628: Cannot set input into parameter in_layer_or_view.
Code:
mxd = arcpy.mapping.MapDocument("CURRENT")
ObjIDs = []
with arcpy.da.SearchCursor('sLineGravityMain_L', 'OBJECTID') as SCur:
for SRow in SCur:
ObjIDs.append(SRow[0])
for ObjID in ObjIDs:
tmpLyr = 'temp' + str(ObjID)
arcpy.MakeFeatureLayer_management(PathToFC,tmpLyr,'"OBJECTID"=%d' % ObjID)
arcpy.SelectLayerByAttribute_management('sLineGravityMain_L',"NEW_SELECTION", '"OBJECTID"=%d' % ObjID)
arcpy.SelectLayerByLocation_management('sManhole_P', "INTERSECT",tmpLyr,"","NEW_SELECTION","")
arcpy.Delete_management(tmpLyr, 'GPFeatureLayer')
FYI, PathToFC is a placeholder, I have the full path passed in for the actual code. The in_layer for MakeFeatureLayer_management is the 'sLineGravityMain_L' feature class.
sLineGravityMain_L
layer or similar?