Geoprocessing Service shows same output although input changes

1329
0
01-29-2016 08:39 AM
ionarawilson
New Contributor III

Hi, I need to know the scale of an mxd in a web application. For that I am running  a geoprocessing service. I need to know the scale when there is a definition query and the map zooms in to that feature. I can see in the message that the scale changes, but the output in the web application is always the same scale, although the input feature changes. What am I doing wrong? Thank you for any help.

import arcpy

import os

import uuid

# Input Layout template

Layout_Template = arcpy.GetParameterAsText(0)

if Layout_Template == '#' or not Layout_Template:

    Layout_Template = "StewardshipTractBoundaryMap"

layouttemplatemxd = Layout_Template

templatePath = 'D:/ArcGISData/Geoprocessing_Examples/Advanced_HighQualityPrinting3'

Selecting_Features = arcpy.GetParameterAsText(1)

Input_Polygons = "Stewardship"

mxd0 = arcpy.mapping.MapDocument(r"D:\ArcGISData\Geoprocessing_Examples\Advanced_HighQualityPrinting3\\" + layouttemplatemxd + ".mxd")

df1 = arcpy.mapping.ListDataFrames(mxd0, "DataFrame1")[0]

mxd0.activeView = df1

lyr1 = arcpy.mapping.ListLayers(mxd0, Input_Polygons, df1)[0]

lyr1.definitionQuery = ""

lyr1.definitionQuery = '"PlanID" = \'%s\'' % Selecting_Features

df1.panToExtent(lyr1.getSelectedExtent())

lyr1.getExtent()

lyr1extent = lyr1.getExtent()

df1.extent = lyr1extent

Scale = str(df1.scale)

arcpy.RefreshTOC()

arcpy.RefreshActiveView()

mxd0.save()

arcpy.SetParameterAsText(2, Scale)

lyr1.definitionQuery = ""

arcpy.RefreshTOC()

arcpy.RefreshActiveView() 

arcpy.AddMessage(Scale)

mxd0.save()

del mxd0, df1, lyr1

Tags (1)
0 Kudos
0 Replies