I have something that works but i am not sure if this is correct or if there is an easier way of doing this.Any input would be gratefully appreciated please.
import arcpy, string, os
arcpy.env.overwriteOutput = True
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, "TAXLOTS")[0]
arcpy.env.workspace = os.path.dirname(mxd.filePath)
wp = os.path.dirname(mxd.filePath)
value = arcpy.GetParameterAsText(0)
if value == "#" or value == "":
value = None
if value:
arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", "\"DXF_TEXT\" = '" + str(value) +"'")
else:
arcpy.AddError("no value")
df.extent = lyr.getSelectedExtent()
df.scale = 24000
if int(arcpy.GetCount_management("TAXLOTS").getOutput(0)) > 0:
arcpy.Select_analysis("TAXLOTS", "SUBJECT_PROPERTY")
del mxd, wp,
mxd = arcpy.mapping.MapDocument("CURRENT")
lyr = arcpy.mapping.ListLayers(mxd, "SUBJECT_PROPERTY")[0]
lyrpath = lyr.workspacePath
#data_path = os.path.dirname(lyrpath)
wp = os.path.dirname(mxd.filePath)
SP = "SUBJECT_PROPERTY"
lyr.replaceDataSource(wp, "SHAPEFILE_WORKSPACE", SP, True )
arcpy.RefreshActiveView()
arcpy.RefreshTOC()