gwilkins58

Python and ArcGIS Runtime

Discussion created by gwilkins58 on Feb 19, 2014
Latest reply on Feb 19, 2014 by gwilkins58
Hi,

I'm new to using python and ArcGIS together and really struggling with something which I'm not entirely sure is possible. I'm really hoping somebody out there has managed to do similar or could please point me to some useful reference material.

We are looking to allow users to run python scripts within our application built upon the ArcGIS Runtime.

Having trawled around I found an article which says that (theoretically!) it is possible to run .py scripts in the ArcGIS Runtime by essentially calling them from a geoprocessing package containing the following code.

filename = arcpy.GetParameterAsText(0)
execfile(filename, {'__file__': filename})


This works perfectly for very simple python scripts but my problem comes that anything that attempts to operate on the map (such as adding or querying a layer or even querying the map ) simply fails.

I can't seem to access anything map related!

The same scripts work perfectly in the Python window in ArcMap (an example below), but run as a py script = nothing.

import arcpy
import ctypes

mxd = arcpy.mapping.MapDocument("CURRENT")
nam = mxd.activeDataFrame.name

ctypes.windll.user32.MessageBoxA(0, nam, "Dialog Title", 1)


Are there any limitations or approaches I should be aware of?

We really need the ability to run python scripts in our application :(

Apologies if this is not the right forum to post on, but could someone please help!

Much appreciated,

Gary

Outcomes