ryankelley001

arcpy copy/paste text element within MXD?

Discussion created by ryankelley001 on Oct 28, 2010
Latest reply on Oct 29, 2010 by ryankelley001
My previous post regarding adding a text report of attribute data to an area in an MXD didn't yield any response, and probably isn't possible, so I am taking a new approach.

I have a text element in my MXD called "StateText".

When my cursor grabs the State attribute, it can replace that text string with the State.  What I want to be able to do is, if there is more than one record, copy/paste that string (and rename it before I assign the value) to an x,y location. My python loop can then populate accordingly.  Of course I would need to rename that pasted text string before changing the text, so the text strings remain unique.

rows = arcpy.SearchCursor("lyr_sort")
row = rows.next()

xState = 9.2
y = 9.25

while row:
    stateValue = row.getValue("PROJECT_STATE")
    for elm in MAP.ListLayoutElements(MXD, "TEXT_ELEMENT"):
        if elm.text == "StateText":
            #copy value here to something unique
            elm.text = (str(stateValue) + "\n")
            elm.elementPositionX = xState
            elm.elementPositionY = str(y - 0.25)
    row = rows.next()

Outcomes