AnsweredAssumed Answered

Return value of a variable

Question asked by cfoster15 on Apr 3, 2012
Latest reply on Apr 10, 2012 by cfoster15
I have a script for Parcel Noticing , it uses a subject parcel, determines its size, and then starts selecting parcels within a specified radius.  If 31 parcels are not captured within the initial radius, then the radius increases by 25 feet until 31 total parcels are selected. 
I am enclosing the script and have a question, I want to start scripting the mapping portion of the noticing and would like to use the distance of the final radius later on, but can not figure out how to capture this number.  Will someone please look at this and try to provide some feedback?

import arcpy  layer = arcpy.GetParameterAsText(0) apn = arcpy.GetParameterAsText(1) mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames (mxd, "LAYERS")[0]  def select_parcels(layer, distance):     while True:         print_search_distance(distance)         arcpy.SelectLayerByLocation_management(layer, "WITHIN_A_DISTANCE", layer, "%i Feet"%(distance),"NEW_SELECTION")         if get_count(layer):             r = arcpy.GetCount_management(layer)             cnt = int(r.getOutput(0))             print "%i Features selected at a distance of %i Feet."%(cnt, distance)             arcpy.AddMessage("%i Features selected at a distance of %i Feet."%(int(cnt),distance))             break         layer = reselect(layer, selstring)         distance += 25 ## End select_parcels function  def get_count(layer):     result = arcpy.GetCount_management(layer)     if int(result.getOutput(0)) >= 31:         return True     else:         return False ## End get_count function  def reselect(layer, selection_string):     arcpy.SelectLayerByAttribute_management(layer,'CLEAR_SELECTION')     arcpy.SelectLayerByAttribute_management(layer, "NEW_SELECTION", selection_string)     return layer ## End clear_selection function  def print_search_distance(distance):     arcpy.AddMessage('Searching %i Feet'%(distance))   arcpy.AddMessage(apn) selstring = """TAG = '{0}'""".format(apn) arcpy.AddMessage("Selection string = " + selstring)  if not arcpy.Describe(layer).datatype == 'FeatureLayer':     layer = arcpy.MakeFeatureLayer_management(layer, 'flayer')  arcpy.SelectLayerByAttribute_management(layer, "NEW_SELECTION", selstring)  rows = arcpy.SearchCursor(layer) n = 0 val = 0.0 for row in rows:     val = val + row.tmp_pacres     n = n + 1  arcpy.AddMessage("Sum of PACRES = " + str(val)) if n > 1:     arcpy.Message("More than one record found")   if val <= 1.0:     select_parcels(layer, 300) elif (val > 1.0 and val <= 40.0):     select_parcels(layer, 600) else:     select_parcels(layer, 1200)