2 Replies Latest reply on Dec 6, 2012 6:07 AM by dabera

    inserting text in map layout

    dabera
      Hi Guys,

      I was wondering if it is possible to insert all possible values of a loop into map layout as a text element. The script I have prints only one value or line. Here is part of my code. Thanks for your help !!

      Daniel A.

      arcpy.AddMessage('Adding Text Elements...')  arcpy.AddMessage('*************************')  # search input feature rows=arcpy.SearchCursor(inputFc)  # Retrieve the first record from the list row=rows.next()  # set field value list FieldValList = []  # loop through the field ATS while row:       feat=row.shape             total=total+feat.area       ATS = row.getValue("ATS")                             # make sure its unique       if not ATS in FieldValList:                     FieldValList.append(ATS)                                                                                                                                   # next field       row=rows.next()                                                                      # add text elemets to the map layout        for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):           if elm.name == "ATSList":                 elm.elementPositionX = 6.5                 elm.elementPositionY = 1.0                 for ATS in FieldValList:                                elm.text = "Within Theoretical: " + "\n" + ATS
        • Re: inserting text in map layout
          mzcoyle
          I know there is a better way to do this, I just can't remember what it is. Something like this should get the result you want I believe.

              for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):         if elm.name == "ATSList":             elm.elementPositionX = 6.5             elm.elementPositionY = 1.0             entry = "\r\n".join(FieldValList)             elm.text = "Within Theoretical:\r\n{0}".format(entry)


          Edit: Maybe that is better

          Edit2: If they are not string values in your list try this.
          "\r\n".join(map(str, FieldValList))
          • Re: inserting text in map layout
            dabera
            Perfect !!!!! This is exactly what I was looking for.

            Thanks Mathew.