Select to view content in your preferred language

Trying to change elementWidth

943
3
03-25-2013 10:31 AM
courtneygarlock
Emerging Contributor
Hi

I'm using the following code:

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Courtney\TEST.mxd")
for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
    if elm.name == "author":
        elm.text = '<dyn type="document" property="author"/>'
        elmWidth = 2.5
        elm.elementPositionX = 3.23
        elm.elementPositionY = 8.54
        print elmWidth

prints 2.5
     
The script runs fine but when I open the mxd the xy position is changed but not the elmWidth, is there another way to change
element width bc I've tried it a bunch of times and nothing works.

Also is there a better script to add title, author, dataframe time to the layout without having to set each xy position and element width?

Thank you
Tags (2)
0 Kudos
3 Replies
LucasDanzinger
Esri Frequent Contributor
If you are working with the 'current' map document, did you make sure to use arcpy.RefreshActiveView()? Also, are you making sure to do mxd.save() at the end?
0 Kudos
courtneygarlock
Emerging Contributor
I am not working in "current" I am working in pywin 2.7  and I do save.mxd() and the width still isn't changing, only the xy position will change.
0 Kudos
JeffBarrette
Esri Regular Contributor
elmWidth = 2.5 should be elm.elementWidth = 2.4

Jeff
0 Kudos