Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am wondering if it is possible to build a zoom to geoprocessing service without using 'current' for the mxd variable in pyhton. Using 'current' my tool works in arcmap, but not in my gp service. here is my code that work fine locally in arc map

import arcpy

MXD=arcpy.mapping.MapDocument('current')

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

dataframe.zoomToSelectedFeatures()

arcpy.RefreshActiveView()

whe I publish my service, the zoom feature no longer works. I have read online that you cant use 'current' in a gp service, thats fine. When I enter the path to the mxd, the zoom function no longer works?

share|improve this question
    
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
add comment

2 Answers

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

MXD=arcpy.mapping.MapDocument(r'C:\data\new.mxd')

I hope that helps!

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.