I am wondering if it is possible to build a zoom to geoprocessing service without using 'current' for the MXD variable in Python? Using 'current' my tool works in ArcMap, but not in my geoprocessing service.

Here is my code that work fine locally in ArcMap:

import arcpy

dataframe = arcpy.mapping.ListDataFrames(MXD, "Web Mercator")[0]   

When I publish my service, the zoom feature no longer works. I have read online that you can't use 'current' in a geoprocessing service, that's fine. When I enter the path to the MXD, the zoom function no longer works.

  • Is there a way to use a variable as 'current' with the mxd path in it?
    – Emily
    Apr 18 '12 at 16:12
  • I don't know much about GP services, but since it is server side, not client side, doesn't that mean it is unable to affect/interact with the current map document/active view?
    – blah238
    Apr 18 '12 at 23:20

I think you need to set the path to your map - CURRENT only works if you're in ArcMap.


From the code supplied in the question it is not possible to see how you can tell that the zoom is not working when you specify the mxd (which is the way I do this) rather than CURRENT.

Perhaps include an MXD.save(), MXD.SaveACopy(...), or an arcpy.mapping.ExportToPDF(...) to "trap" the result.

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.