The script I'm writing requires a specific attribute of the building polygon that the data frame extent is currently focused on. Is there a way to grab this data?


In ArcGIS 10, you can use arcpy.mapping to do this. It would look something like:

mapdoc = arcpy.mapping.MapDocument("current")
dataframe = arcpy.mapping.ListDataFrames(mapdoc, mapdoc.activeView)[0]
extent = dataframe.extent

You can then pass the extent in as parameters to GP tools etc.

  • After you've got the active extent, you can get feature attributes by using Select Layer By Location (tinyurl.com/298khqo) – scw Jul 31 '10 at 21:07
  • Where would I input the active extent in this tool? SelectLayerByLocation_management (in_layer, {overlap_type}, {select_features}, {search_distance}, {selection_type}) For overlap_type, I'm using COMPLETELY_WITHIN, but according to the documentation, I can only select features from the in_layer that are completely within a polygon, not an extent. – Tanner Aug 7 '10 at 21:22
  • As far as I know, it should still work as an input there. Try it out. – Jason Scheirer Aug 9 '10 at 11:33
  • The extent you process over is an ArcGIS environment variable. You can set that with python before you run whatever other tools you'll use. See help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//… – Paulo Raposo Nov 2 '15 at 5:30

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.