AnsweredAssumed Answered

Selecting multiple subsets

Question asked by on Sep 18, 2012
Latest reply on Sep 19, 2012 by csny490
Zooming to full extent when optional parameter values  are not entered.  Can anybody tell me why this is?

Thanks in advance...

import arcpy  def main():     arcpy.AddMessage("Starting")      # Get and set variables     sub = arcpy.GetParameterAsText(0)     unit = arcpy.GetParameterAsText(1)     blk = arcpy.GetParameterAsText(2)     lot = arcpy.GetParameterAsText(3)     layer_name = "tax_acct"     df_name = "Layers"       arcpy.AddMessage(sub)     arcpy.AddMessage(unit)     arcpy.AddMessage(blk)     arcpy.AddMessage(lot)          # Define mxd, df and lyr objects     mxd = arcpy.mapping.MapDocument("CURRENT")     df = arcpy.mapping.ListDataFrames(mxd, df_name)[0]     lyr = arcpy.mapping.ListLayers(mxd, layer_name, df)[0]      arcpy.AddMessage(      # Create where clause for selection     query = "SUBDIVISIO = '%s'" % (sub)     query1 = "UNIT_NUMBE = '%s'" % (unit)     query2 = "BLOCK_NUMB = '%s'" % (blk)     query3 = "LOT_NUMBER = '%s'" % (lot)      arcpy.AddMessage(query)     arcpy.AddMessage(query1)     arcpy.AddMessage(query2)     arcpy.AddMessage(query3)                    arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", query)     arcpy.SelectLayerByAttribute_management(lyr, "SUBSET_SELECTION", query1)     arcpy.SelectLayerByAttribute_management(lyr, "SUBSET_SELECTION", query2)     arcpy.SelectLayerByAttribute_management(lyr, "SUBSET_SELECTION", query3)          # Set df extent to layer selection     df.extent = lyr.getSelectedExtent()     arcpy.RefreshActiveView()      arcpy.AddMessage("Completed")   main()