<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ArcGIS Runtime and Python in ArcGIS Runtime SDK for WPF (Retired) Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/arcgis-runtime-and-python/m-p/514637#M2643</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Gary, somebody from Esri will be able to confirm, but your current approach won't work. within ArcMap the python execution has access to the variables and objects that are part of ArcMap. This is not the case with Runtime. You have to compare the geoprocessing package as something that run remotely, like on ArcGIS server. It doesn't know anything about your environment, so you will need to pass along the necessary information to the script to let it execute.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 20 Feb 2014 06:25:23 GMT</pubDate>
    <dc:creator>BKuiper</dc:creator>
    <dc:date>2014-02-20T06:25:23Z</dc:date>
    <item>
      <title>ArcGIS Runtime and Python</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/arcgis-runtime-and-python/m-p/514636#M2642</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We are looking to allow users to run python scripts within our application built upon the ArcGIS Runtime.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;filename = arcpy.GetParameterAsText(0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;execfile(filename, {'__file__': filename})&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;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. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can't seem to access anything map related!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The same scripts work perfectly in the Python window in ArcMap (an example below), but run as a py script = nothing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import ctypes&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;nam = mxd.activeDataFrame.name&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ctypes.windll.user32.MessageBoxA(0, nam, "Dialog Title", 1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Are there any limitations or approaches I should be aware of?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We really need the ability to run python scripts in our application &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Apologies if this is not the right forum to post on, but could someone please help!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Much appreciated,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Gary&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Feb 2014 08:04:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/arcgis-runtime-and-python/m-p/514636#M2642</guid>
      <dc:creator>GaryWilkins</dc:creator>
      <dc:date>2014-02-19T08:04:49Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Runtime and Python</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/arcgis-runtime-and-python/m-p/514637#M2643</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Gary, somebody from Esri will be able to confirm, but your current approach won't work. within ArcMap the python execution has access to the variables and objects that are part of ArcMap. This is not the case with Runtime. You have to compare the geoprocessing package as something that run remotely, like on ArcGIS server. It doesn't know anything about your environment, so you will need to pass along the necessary information to the script to let it execute.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Feb 2014 06:25:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/arcgis-runtime-and-python/m-p/514637#M2643</guid>
      <dc:creator>BKuiper</dc:creator>
      <dc:date>2014-02-20T06:25:23Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Runtime and Python</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/arcgis-runtime-and-python/m-p/514638#M2644</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Bjorn,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sadly that makes sense - I thought I was perhaps asking too much of it. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Would you be able to&amp;nbsp; point me in the right direction on what information I need to pass in about the environment to a script? I'm assuming I need to pass this information as parameters.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Most (but not all) of our data is contained in an MPK file loaded into the application - could I somehow point the script to the same MPK file?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Gary&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Feb 2014 06:49:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/arcgis-runtime-and-python/m-p/514638#M2644</guid>
      <dc:creator>GaryWilkins</dc:creator>
      <dc:date>2014-02-20T06:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Runtime and Python</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/arcgis-runtime-and-python/m-p/514639#M2645</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi Bjorn,&lt;BR /&gt;&lt;BR /&gt;Sadly that makes sense - I thought I was perhaps asking too much of it. &lt;BR /&gt;&lt;BR /&gt;Would you be able to&amp;nbsp; point me in the right direction on what information I need to pass in about the environment to a script? I'm assuming I need to pass this information as parameters.&lt;BR /&gt;&lt;BR /&gt;Most (but not all) of our data is contained in an MPK file loaded into the application - could I somehow point the script to the same MPK file?&lt;BR /&gt;&lt;BR /&gt;Thanks for your help.&lt;BR /&gt;&lt;BR /&gt;Gary&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; you can query your layers through &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/runtime-wpf/concepts/index.html#/Querying_and_searching_overview/0170000000m4000000/"&gt;Query Task&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;You should check Runtime samples installed with runtime SDK as It covers alot of concepts.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you want to pass features to your GP tool you can use FeatureSet or RecordSet to pass a specific layer/table to your script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It's similar to Silverlight API.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/runtime-wpf/concepts/index.html#/Geoprocessing_task_parameters/01700000009s000000/"&gt;http://resources.arcgis.com/en/help/runtime-wpf/concepts/index.html#/Geoprocessing_task_parameters/01700000009s000000/&lt;/A&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="https://developers.arcgis.com/silverlight/sample-code/start.htm#ClipFeatures"&gt;https://developers.arcgis.com/silverlight/sample-code/start.htm#ClipFeatures&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 23 Feb 2014 07:50:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/arcgis-runtime-and-python/m-p/514639#M2645</guid>
      <dc:creator>AhmedEl-Sisi</dc:creator>
      <dc:date>2014-02-23T07:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Runtime and Python</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/arcgis-runtime-and-python/m-p/514640#M2646</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I can't seem to access anything map related!&lt;BR /&gt;&lt;BR /&gt;The same scripts work perfectly in the Python window in ArcMap (an example below), but run as a py script = nothing.&lt;BR /&gt;&lt;BR /&gt;Code:&lt;BR /&gt;import arcpy&lt;BR /&gt;import ctypes&lt;BR /&gt;&lt;BR /&gt;mxd = arcpy.mapping.MapDocument("&lt;STRONG&gt;CURRENT&lt;/STRONG&gt;")&lt;BR /&gt;nam = mxd.activeDataFrame.name&lt;BR /&gt;&lt;BR /&gt;ctypes.windll.user32.MessageBoxA(0, nam, "Dialog Title", 1)&lt;BR /&gt;Are there any limitations or approaches I should be aware of?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Gary, have you tried to replace "CURRENT" with the full folder path to your *.mxd Map document? Current refers to the "current" document opened in ArcMap. Since you are running the Python script outside ArcMap, it probably has no knowledge what "current" is.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 23 Feb 2014 10:36:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/arcgis-runtime-and-python/m-p/514640#M2646</guid>
      <dc:creator>MarcoBoeringa</dc:creator>
      <dc:date>2014-02-23T10:36:30Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Runtime and Python</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/arcgis-runtime-and-python/m-p/514641#M2647</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ahmed's approach will work. Marco's approach not. You will need to explain a bit more about what you are trying to achieve. Based on that we can advise you what the best approach is. There are all kinds of services available, as Ahmed pointed out, that you can directly use on the layers within your application. In other cases you might need to go to GPKs, and depending on what you want it can be really easy to complex.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Feb 2014 06:20:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-wpf-retired-questions/arcgis-runtime-and-python/m-p/514641#M2647</guid>
      <dc:creator>BKuiper</dc:creator>
      <dc:date>2014-02-24T06:20:07Z</dc:date>
    </item>
  </channel>
</rss>

