I'm trying to use ArcPy in ArcMap, so Python 2.7, to automate the basics for the maps I make on a daily basis. Rather than having myself setout certain elements I want Python via the ArcMap API to do it for me.

So far I have the maps created, datasource, extent sorted, captions updated etc. Now I turn to the grid and scale bar.

In my script the layout view is set to the extent of a feature class (plus a buffer either side), this means the scale bar and graticule grid changes based on the extent.

How do I get access to the properties in the scalebar/grid?

When it comes to captions I use the following and update the placeholder text:

for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
    if elm.text == current_text:
        elm.text = text

I've seen in 2010 posts that ArcPy is not yet ready for altering scale bar and grid properties, has the situation changed?

Using this I can get to the width parameter but I want to set the division value

for elm in arcpy.mapping.ListLayoutElements(mxd, "MAPSURROUND_ELEMENT"):
  • 1
    Which 2010 posts have you seen? If I were trying to do this today I would look at ArcGIS Pro, ArcPy and CIM.
    – PolyGeo
    Oct 9, 2022 at 11:30
  • Not all aspects of ArcMap mapping elements were exposed to Python -- some can only be addressed by ArcObjects. Far more of the Pro mapping rewrite was made available to Python. You're now at the cusp between "late adopter" and "left behind" with respect to ArcGIS Pro. You should probably at least test it out before the voice is taken from you.
    – Vince
    Oct 9, 2022 at 12:37
  • @PolyGeo there were a few posts asking about this, since they said it was not yet possible I moved on. Oct 9, 2022 at 15:31
  • @Vince I'm not sure what you are really talking about, but yes we will be moving on to Pro in due course, but for now I'm trying to get things to work in ArcMap. Oct 9, 2022 at 15:34


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.