0

The arcpy snippet below is intended to generate a list of technicians scheduled to work, and then generates a unique feature layer for each one's stops.

fcStops = "TaskRoute1016"
with arcpy.da.SearchCursor(fcStops, "AssignedEngineers") as cursor:
 TechList = sorted({row[0] for row in cursor})
print "Technicians today:"
for Technician in TechList:
 subsetSQL = "AssignedEngineers = '{}'".format(Technician)
 TechLayer = "Tech {}".format(Technician)
 arcpy.MakeFeatureLayer_management(fcStops, TechLayer, subsetSQL)
 print(" {}: {} stops".format(Technician, arcpy.GetCount_management(TechLayer).getOutput(0)))

It works perfectly once (selects just his stops, makes a feature layer, prints out the count), but only once. After the first iteration, I get:

Runtime error Traceback (most recent call last):
File "<string>", line 5, in <module>
File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\management.py", line 6043, in MakeFeatureLayer
 raise e ExecuteError: 
ERROR 000622: Failed to execute (Make Feature Layer). Parameters are not valid. 
ERROR 000628: Cannot set input into parameter in_features.

The 000628 error says "The syntax used for the parameter is invalid for the parameter type" -- I'm not sure what's changing in my syntax, however, since the in_features variable should still be fcStops each time through the loop. If it's working once, why not multiple times?

I am running this in the Python window in ArcMap 10.2.1.

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Oct 16, 2014 at 12:06
5
  • Do you have any NULL values in your AssignedEngineers field? Commented Oct 16, 2014 at 12:13
  • No. Some of the names do have spaces, but that includes the first one (which executes without problems) Commented Oct 16, 2014 at 12:16
  • Wouldn't the loop try to create several layers for each technician if each technician has several tasks? Techlist should have duplicates removed. On the other hand, if that is the problem you would have error on parameter output layer already exists. Commented Oct 16, 2014 at 13:08
  • TechList only has unique values. Commented Oct 16, 2014 at 13:17
  • 1
    I have a suspicion that you are encountering the same issue as in gis.stackexchange.com/questions/15800/…. I think this is an issue that I too have encountered and resolved using @Blah238's solution of deleting the feature layer before trying to recreate it. Commented Oct 16, 2014 at 21:55

1 Answer 1

3

I'm not sure why, maybe a memory issue, but you need to use the full file path to the feature class you are creating the feature layer on. So for fcStops, put the full file path, not just the layer name from ArcMap.

I tested it on my machine, and it failed with the same error when I used the layer in the TOC, but worked fine when I used the full path.

fcStops = "FULL PATH\\TaskRoute1016"
with arcpy.da.SearchCursor(fcStops, "AssignedEngineers") as cursor:
 TechList = sorted({row[0] for row in cursor})
print "Technicians today:"
for Technician in TechList:
 subsetSQL = "AssignedEngineers = '{}'".format(Technician)
 TechLayer = "Tech {}".format(Technician)
 arcpy.MakeFeatureLayer_management(fcStops, TechLayer, subsetSQL)
 print(" {}: {} stops".format(Technician, arcpy.GetCount_management(TechLayer).getOutput(0)))
answered Oct 16, 2014 at 14:56
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.