Solved! Go to Solution.
## Import standard modules
import sys, os
## Set the product code
import arcinfo
## Import arcpy module and environment module
import arcpy
import arcpy.mapping
from arcpy import env
## Sets the MXD file to the current ArcMap MXD, if run out of ArcMap use the full path to the MXD file
IMXD = arcpy.mapping.MapDocument("CURRENT")
## Set Data Frames for the layer to select from
MDF = arcpy.mapping.ListDataFrames(IMXD, "Main Map")[0]
## Set the Index layers
ILyr = arcpy.mapping.ListLayers(IMXD,"PLSS")[0]
## Set the Section, Township and Range
STR = arcpy.GetParameterAsText(0)
# STR = '5-15-33'
## Create the SQL Query for the sheet number
SheetQry = r"SecTwnRng = '%s'"%(STR)
## Select the Aerial
try:
arcpy.SelectLayerByAttribute_management(ILyr, "NEW_SELECTION", SheetQry)
Num = str(arcpy.GetCount_management(ILyr))
if Num == "0":
arcpy.AddMessage("!! NO CORRESPONDING PLSS AREA EXISTS FOR THIS REQUEST !!")
else:
## Get Extent of Selected Sheet
IExt = ILyr.getSelectedExtent()
## Pan to selected extent
MDF.panToExtent(IExt)
# Get the seperated STR text
SECTWNRNG = STR.split("-")
SEC = SECTWNRNG[0]
TWN = SECTWNRNG[1]
RNG = SECTWNRNG[2]
## Set the S-T-R Text
for SheetNum in arcpy.mapping.ListLayoutElements(IMXD, "TEXT_ELEMENT"):
if SheetNum.text == "SEC TWN RNG":
SheetNum.text = r"%s %s %s"%(SEC, TWN, RNG)
## Refresh data farame
arcpy.RefreshActiveView
arcpy.AddMessage("Please refresh the map on completion")
except:
arcpy.GetMessages()