Select to view content in your preferred language

arcpy copy/paste text element within an MXD

714
1
10-28-2010 09:45 AM
RyanKelley
Deactivated User
I am posting this question here as well the Map Automation Forum, since it pertains to python and this forum seems to get a lot more action.

My previous post (in the Map Automation Forum) 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.


To keep things simple, I have a text element in my MXD called "StateText1".

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.

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

n = 1
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" + str(n):
            ###(HELP) copy text string to x,y and assign elm.text = str("StateText" + str(n + 1)) 
            if elm.text == "StateText" + str(n):
                elm.text = (str(stateValue) + "\n")
                elm.elementPositionX = xState
    y = y - 0.25
    elm.elementPositionY = y
    n = n + 1
    row = rows.next()
0 Kudos
1 Reply
RyanKelley
Deactivated User
I came up with a working solution....

Still wondering if you can copy/paste though...?
0 Kudos