This question already has an answer here:
i have managed to create script for search cursor which will replace the text element in one of the template from help provided from my previous question https://gis.stackexchange.com/questions/172544/replacing-text-element-from-feature-class-value-using-arcpy I would like to know how i can specify the predefined template in the script below so that the script automatically load the template..
Currently i am change the template manually. the template is located in my Map template folder inside Arcgis installation directory.
note: this script is used in creating a map printout which also has select by attribute > zoom to selected feature, change view to layout view > update text element > print.
import arcpy mxd = arcpy.mapping.MapDocument(r"Current") table = r"C:\Users\name\Documents\ArcGIS\DATA.gdb\\Layer" # lyr from which data will be pulled value = arcpy.GetParameterAsText(0)# enter UNIQUE_REC from layer query = "\"UNIQUE_REC\" = %s" % (value) # string conversion via str() prior to formatting theseRows = arcpy.SearchCursor(table, query) for row in theseRows: if theseRows: print(row.getValue("LOT")) else: print "CORRECT UNIQUE_REC" for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"): if elm.text == "text7": elm.text = (row.getValue("LOT")) arcpy.RefreshActiveView() del mxd