refreshing text element in python

3355
2
Jump to solution
04-21-2015 04:47 PM
KendrickSchuett
New Contributor II

I am sorry for asking I am sure someone has asked this but I can't seem to find the answer and i am new enough to arcmap and python I can't see my issue.....

So I am wanting to run a loop that changes a text element prior to being exported to .PNG

hourdriver = range(2)
for step in hourdriver:
    for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
        if elm.name == "TIME_DESC":
            print "Found it"
            elm.text = "New Text"
            print elm.text # This results in "New Text" but on the map it stays as "TIME" which was the original text

mxd.save # I have tried save and refreshactiveiew at several points in the loop with no real result. 
arcpy.RefreshActiveView()

my print statements returns the correct text but the text element in the map does not update. as you can see i have tried saving and refreshing the active view.....  here is the print out put that I get

Found it
New Text
Found it
New Text

I was thinking about clone and delete but that seems like a strange way to go about refreshing a text element. Any help would be appreciated i am sure it is something simple i am missing. Thank you for your time.

0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Emeritus

mxd.save()

look closely ..​

View solution in original post

2 Replies
DanPatterson_Retired
MVP Emeritus

mxd.save()

look closely ..​

KendrickSchuett
New Contributor II

DOH..... sorry i came from vb and i am lazy when i deal with stuff beacuse i am used to VS doing stuff for me. Thanks again

0 Kudos