Dynamic text

842
2
10-15-2013 07:56 PM
PhilCadorette
New Contributor
Hello, I have hit a wall and would like to see if anyone has any ideas for this. I need to make a map template using three fc layers
with specific field attributes from each layer to be positioned at specific locations but nowhere near the symbols. So far I have used one layer as the data driven page so I can access the " <dyn type="page" property="attribute" field="?" domainlookup="True"/>" and joined the other two layers. The problem seems to be that when I make and edit to any of the other joined layers and refreshed the dataframe only some of the field attributes are updated and of course some of the key ones I need don't.

What I am doing is making a custom legend using a word table inserted as an object into the pagelayout and position the dynamic text where they need to be. The field attributes are NOT being symbolized but are used as information about specific data. I have looked at modelbuilder and python as much I can but don't see how to show the text individually and dynamically, sometimes we have to go and edit these maps several times as the information is given to us. To compound matters I only have a esri basic arcmap license.


Thanks in advance for any and all suggestions.
0 Kudos
2 Replies
CPoynter
Occasional Contributor III
You will need to access the "TEXT_ELEMENT" or elements as you have three using arcpy. Basis included here for a single element and a single featureclass.

import arcpy

fc = r"D:\Data.shp"

fieldList = [f.name for f in arcpy.ListFields(fc, "*")]
for field in fieldList:

    queryStr = "\"" + field + "\" > 0"

    mxd = arcpy.mapping.MapDocument(r"D:\MyMXD.mxd")

    elm = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT")[0]
    elm.text = "Title or something: " + field

    df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]

    for lyr in arcpy.mapping.ListLayers(mxd, "", df):
            if lyr.name == "Data":

                if lyr.supports("DEFINITIONQUERY"):
                    lyr.definitionQuery = queryStr

    arcpy.RefreshActiveView()

    arcpy.mapping.ExportToPDF(mxd, r"D:\Data" + "\\" + field + ".pdf")

del mxd


This pulls the field names and applies the "DEFINITIONQUERY" to the data, but might be adaptable to pulling attributes.

Regards,

Craig

p.s. If applying "DEFINITIONQUERY" to multiple FCs with same attribute values consider:

for value in uniqueValues:
  queryStr = "\"" + field + "\" = '" + str(value) + "'"

  df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
  for lyr in arcpy.mapping.ListLayers(mxd, "", df):
    if lyr.name == "FC1" or lyr.name == "FC2" or lyr.name == "FC3":
      lyr.definitionQuery = queryStr
0 Kudos
PhilCadorette
New Contributor
Thanks for your reply, this formed the building blocks to move on. I now have a working python script that does what I need it to do and room to expand.

phil
0 Kudos