2

I need help to identify the data frame (from several data frames) that corresponds to a scale bar in ArcMap?

  • 4
    Zoom in/out on a data frame and see which one changes. How many data frames do you have? (note: there is a View Previous button that will restore your extent to what it was before you zoomed, no damage done)... if your scale bar doesn't change it's because it's been turned into a graphic and doesn't belong to any data frame - that's really bad practice and should be removed. – Michael Stimson May 26 '15 at 5:36
  • And note once you do figure it out, or better yet at time of creation, you can name graphic elements in their properties. That way you could call it dataframe1scalebar or something. Of course, more descriptive names for all elements, including dataframe names (especially with that many) are recommended. – Chris W May 26 '15 at 20:23
1

The suggestion by @MichaelMiles-Stimson is a good one.

Alternatively, you could type some code into the Python window of ArcMap:

mapDoc = arcpy.mapping.MapDocument("CURRENT")
scaleBar = arcpy.mapping.ListLayoutElements(mapDoc,"MAPSURROUND_ELEMENT")[0]
print scaleBar.parentDataFrameName

If your scale bar is the only Map Surround Element in your map then the above will work.

If you have multiple Map Surround Elements then go to the Size & Position tab of the Properties for the Scale Bar and give it a name - in the graphic below I have let it stay as the default of "Scale Line".

enter image description here

Now you will be able to isolate that one Map Surround Element (or at least the first Map Surround Element named "Scale Line") by using:

scaleBar = arcpy.mapping.ListLayoutElements(mapDoc,"MAPSURROUND_ELEMENT","Scale Line")[0]
0

In the table of contents window, when you activate a certain data frame, anything that you do thereafter will correspond to that specific data frame contents. If you add anything it will belong to the activated frame. This might help you in knowing to which data frame will your scale bar belong to when you add. If you have few data frames you could remove the scale bars then add them again with this in mind.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.