hi kevin, i really appreciate your reply. a little more elaboration/clarification?yes, my goal is to avoid having to, with each execution of my script, expend the processing time to create a new connection to a layer on which to do the geoprocessing task's work. In other words, avoid this:arcpy.MakeFeatureLayer_management("..mygdb/mydataset/myfeatureclass", outlayer)
where outlayer becomes an instance of arcpy.mapping.layer.So I thought that publishing a geoprocessing service based on a map document with a tool layer would keep the map document's layers in memory, and I could grab them from the map document's arcpy.mapping layers collection after I got hold of the current document with 'CURRENT'.But you've confirmed I can't use 'CURRENT' in a server-based script.I read your reply to mean this - I can get a given layer, for purposes of passing it as an input to a tool that normally requires a layer as input, by passing the name of the layer to that tool. Like:arcpy.Buffer_analysis('layer name in source map doc TOC', '%scratchworkspace%\out.shp', '100 Miles')
Do I have that right?But what I want is this - the code of my script wants to actually use the layer object, not pass it as input to another tool. Specifically in my case, I want my script to loop over the selected rows in the layer in a for loop. So again, how do I get hold of an actual arcpy.mapping.layer instance? Maybe I read your reply to mean:arcpy.MakeFeatureLayer_management("layer name in source map doc TOC", outlayer)
rows = arcpy.SearchCursor(outlayer)
for row in rows:
do stuff with the row
thanks again, MC