Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Python script to enter name string

$
0
0
I am attempting to write a Python script that selects a record in the attribute table, zooms to the selected feature, and prompts the user to enter their name. The name field already exists in the attribute table as a string type. How would I get the script to prompt the user to enter their name?Then, have the information they enter stored in the attribute table? I am going to have the users run the script from ArcToolbox. I have tried the python addin to toolbar/button. But, was unable to prompt the user to enter their name or zoom to selected feature without manually selecting the feature.

Code:

import arcpy

#Variables
Parcels = arcpy.GetParameterAsText(0)
arcpy.AddMessage(Parcels)

mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, "Parcels", df)[0]
arcpy.AddMessage(lyr.name)

#Logic
try:
        whereClause = "RENUM = "+Parcels+""
        arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", whereClause)

        df.extent = lyr.getSelectedExtent()
        df.scale = df.scale*1.1

except:
        print arcpy.GetMessages()


Viewing all articles
Browse latest Browse all 2485

Trending Articles