ArcPy: Issue with MXD="CURRENT" and DataFrame for Tool

Discussion created by ryankelley001 on Sep 24, 2010
Latest reply on Sep 27, 2010 by jbarrette-esristaff
I have written a script that calculates acres or miles for layers in my MXD.  When I copy and paste the code from my Python textfile into the arcpy window, it runs great and executes (I have static arguments) when testing.

However, when I turn this script into a tool, I get an error (000714)... which basically tells you there is an error with your script. I have tried both system arguments and static arguments. I do have bacground processing turned off.

After trying to troubleshoot the issue, it does not like:

MXD = arcpy.mapping.MapDocument("CURRENT")
DF = arcpy.mapping.ListDataFrames(MXD)[0]

If I point my MXD to an existing MXD on disk, it gets through that line of code, but still stops at the DF part.

I guess I am not toally sure how the tool talks top the MXD.  It would only make sense to me that having a "CURRENT" mxd would allow for buttons, tools, etc. to execute in any ArcMap session.

Any help would be greatly appreciated!!

Ryan Kelley
Portland, OR