I'm in the process of writing a script that will iterate through multiple MXDs and extract the data from layers that are turned on and only data that is within the data frame extent.
Some of the MXDs may have data frames that are not visible on the page. I don't want to extract the data from these data frames. So, I want to write a function that will test whether a data frame is within the page extent.
My first thought was to access the dimensions of the page layout using the page size property of the Map Document. Then I would iterate through each data frame and test the X and Y position and compare them to the page dimensions. In theory, this seemed like a good idea. However, I noticed that the positions change when the anchor point is changed.
Take the following example of an A4 page with four data frames. Two on the page and two off the page:
Focusing on the data frame on the left, I can see that it's off the page. When I look at the X position of the data frame, I can see that it is negative which seems to tell me that it is off the page.
Changing the anchor point, changes the X position:
and
I thought about adding the X position to the width. In the first example, when the anchor is set to bottom left, the X position plus the width is still negative, which would tell me that the data frame is off the page. However, if the anchor point is in the middle, or right, the sum of X position and width is positive, which would falsely indicate that the data frame is on the page.
This gets further complicated when the dataframe is partially overlapping the page. I also haven't gotten into the dataframe on the right or testing Y position, though the logic would be similar.
So, my question is, does there exist a method in arcpy to test if a data frame is on or overlaps a page extent?
I'm using ArcGIS Desktop 10.4.1 Basic.
visible
property to turn on/off instead of, or in addition to, moving them on/off the page. That way you have something simple and reliable to test for.