AnsweredAssumed Answered

How to make a Map Document (.mxd) a "Workspace" to do Geoprocessing

Question asked by shieldr on Sep 25, 2014
Latest reply on Sep 25, 2014 by mbabinski1988

I am trying to build some tools using Toolbox and Python for users who are in the ArcMap environment, in an ArcMap session. So the first thing I want to to is get a list of the feature classes and/or layers in the current "Data Frame", pass them into the Toolbox as a parameter, so that the user can then pick one (or more) of them and then begin doing stuff like comparing attributes between 2 feature classes and so forth.


But the problem or challenge is that a "Workspace" is a file folder or a Geodatabase or similar and NOT a "Data Frame". And this is not handy, because to the user, the "Data Frame" is, in fact a storage place for the things they wish to do geoprocessing against.


Does anyone have any ideas for developing a framework for using the Map Document, instead of traditional "Workspaces", as a place to assemble various feature classes, tables, etc. from various domains, file folders, file geodatabases, etc.?


Conceptually, I need to do something like this:


import arcpy
mxd = arcpy.mapping.MapDocument

arcpy.env.workspace = mxd


And this, so I can start doing things like creating lists and other sorts of things, but in the context of the map as the current workspace.