Python Selection fix

385
0
02-01-2011 05:34 AM
brooksderting
New Contributor
I have been working on this script to be able to do simple searches of a field in a feature class, what I am trying to do is first Clear Selection, then Select a new feature (using a input box) then zoom to that selected record.
Thanks for any help that can be given.

Here is what I have so far but I am getting an error on it.
# ---------------------------------------------------------------------------
# PIN Findtest.py
# Created on: 2011-02-01 09:37:00.00000
#   (generated by ArcGIS/ModelBuilder)
# Usage: PIN Findtest <Expression>
# Description:
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy

# Load required toolboxes
arcpy.ImportToolbox("C:/Documents and Settings/bderting/Application Data/ESRI/Desktop10.0/ArcToolbox/My Toolboxes/xFindTools.tbx")

# Clear Selection
arcpy.SelectLayerByAttribute_management ("Parcels", "CLEAR_SELECTION", "")

# Script arguments
Expression = arcpy.GetParameterAsText(0)
if Expression == '#' or not Expression:
    Expression = "PIN LIKE '%%'" # provide a default value if unspecified

# Local variables:
Parcels__2_ = "Parcels"
Parcels = Expression

# Process: Select Layer By Attribute
arcpy.SelectLayerByAttribute_management(Parcels__2_, "NEW_SELECTION", Expression)

# Process: Zoom
arcpy.gp.toolbox = "C:/Documents and Settings/bderting/Application Data/ESRI/Desktop10.0/ArcToolbox/My Toolboxes/xFindTools.tbx";
# Warning: the toolbox C:/Documents and Settings/bderting/Application Data/ESRI/Desktop10.0/ArcToolbox/My Toolboxes/xFindTools.tbx DOES NOT have an alias.
# Please assign this toolbox an alias to avoid tool name collisions
# And replace arcpy.gp.Zoom(...) with arcpy.Zoom_ALIAS(...)
arcpy.gp.Zoom()
Tags (2)
0 Kudos
0 Replies