MMilos

Python script that works in ArcMap, failes in ArcGIS Server

Discussion created by MMilos on Aug 29, 2013
Latest reply on Sep 9, 2013 by MMilos
Hello,


I am new to python, and I am trying to learn it through my daily work.
I need a function that will take a string parameter and look into a feature class, find the object and change the extent of the map...this is a function I need on the server.

Here is my code, that works in ArcMap, but I cannot get it to work in Silverlight Viewer:


import arcpy
from arcpy import env 
mxd = arcpy.mapping.MapDocument('CURRENT')
df = arcpy.mapping.ListDataFrames(mxd) [0]
field = "FNUMBER"
value = arcpy.GetParameterAsText(0)
where = "%s = '%s'" % (field,value)
for row in arcpy.SearchCursor(r"C:\Users\Administrator\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\Connection.sde\FCL_POLES",where):
    df.extent = row.SHAPE.extent #Set the dataframe extent to the extent of the feature
    df.scale = df.scale * 1.07#Optionally give the shape a bit of padding around the edges

    arcpy.RefreshActiveView()



When I try to reference the mxd as a UNC path, nothing happens (both ArcMAp and Server):
mxd = arcpy.mapping.MapDocument("//testSERVER/SHARE/OBJECTS.mxd")


Please advise.
Thanks in advance,
M.


ps. I forgot to mention that the version of ArcGIS is v10.

Outcomes