<?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: Python with IESRIScriptEngine in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/python-with-iesriscriptengine/m-p/208285#M5423</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi both,&lt;/P&gt;&lt;P&gt;Sorry for not responding sooner - I've only just worked out how to reply (the reply button doesn't work!)&lt;/P&gt;&lt;P&gt;I actually opened this up as a support ticket with Esri, and they have filed a couple of bugs/enhancements relating to it. As you say, it looks as though this interface isn't actually supported for Python.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Alexander&lt;/STRONG&gt; - thanks, well spotted! I was assuming that any output that's normally written to the screen by Python would be automatically passed back, but I can see that doesn't entirely make sense...&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Duncan&lt;/STRONG&gt; - what I'm trying to do is dependent on having information pass from Python to VB.net within the same ArcMap session (for example, so I can tell which Data Driven Page is currently in view). I think I'm right in saying that all the methodologies described at your first link launch a new ArcMap session? Or am I missing something obvious?&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;&lt;P&gt;Roland.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 11 Mar 2016 17:15:47 GMT</pubDate>
    <dc:creator>RolandMartin</dc:creator>
    <dc:date>2016-03-11T17:15:47Z</dc:date>
    <item>
      <title>Python with IESRIScriptEngine</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/python-with-iesriscriptengine/m-p/208282#M5420</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Has anyone figured out how to correctly use Python with the IESRIScriptEngine in .NET? The documentation isn't particularly detailed. Through guesswork, I've come up with this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Dim pointer(1) As IntPtr&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;pointer(0) = Runtime.InteropServices.Marshal.AllocHGlobal(4)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Dim engine As IESRIScriptEngine = New ESRIScriptEngine&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;With engine&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; .Language = "python"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; .AddCode("import arcpy")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; .AddCode("mxd = arcpy.mapping.MapDocument(""CURRENT"")")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; .AddCode("mxd.dataDrivenPages.currentPageID = " &amp;amp; id)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; .Run("", pointer)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;End With&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code runs if you encapsulate it in a Try/Catch block, but the pointer isn't working, which means it throws an error every time it runs. Not a major problem in this instance, but it means I can't get any variables passed back from the script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Roland.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Feb 2016 16:54:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/python-with-iesriscriptengine/m-p/208282#M5420</guid>
      <dc:creator>RolandMartin</dc:creator>
      <dc:date>2016-02-02T16:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: Python with IESRIScriptEngine</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/python-with-iesriscriptengine/m-p/208283#M5421</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Roland,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You are not returning anything from your script.&amp;nbsp; I believe that you may want to place a return statement in there to see some sort of output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Feb 2016 13:53:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/python-with-iesriscriptengine/m-p/208283#M5421</guid>
      <dc:creator>AlexanderNohe1</dc:creator>
      <dc:date>2016-02-12T13:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: Python with IESRIScriptEngine</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/python-with-iesriscriptengine/m-p/208284#M5422</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is an interesting question as I have never used that Interface. You are right there is no help in the API about this, in fact a quick Google returned this question as the top ranking page about IESRIScriptEngine! So I'm guessing no one in ESRI or the entire planet is using this interface other than you Roland! You are clearly ahead of the curve!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I tried to have a play and I could not even create the object, it would return a Com Exception error on the second line&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pESRIScriptEngine As IESRIScriptEngine&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;pESRIScriptEngine = New ESRIScriptEngine&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've not attempted to delve too deep into this but this &lt;A href="https://social.msdn.microsoft.com/Forums/vstudio/en-US/88a6ea68-f476-4231-822f-27fabe59f458/error-80040154-retreiving-com-class-factory?forum=vbgeneral"&gt;page&lt;/A&gt; suggests one possible cause is that it is referencing other DLL's. As there is no information, no discussion (other than this page), no advice, no sample code, nothing about this Interface I wonder if it is sensible to continue with it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This &lt;A href="http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#/Leveraging_ArcPy_in_a_NET_application/000100000m0s000000/"&gt;page&lt;/A&gt;​ talks about running arcpy from within a .Net application, may be that is the way to go?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Feb 2016 10:53:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/python-with-iesriscriptengine/m-p/208284#M5422</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2016-02-15T10:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: Python with IESRIScriptEngine</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/python-with-iesriscriptengine/m-p/208285#M5423</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi both,&lt;/P&gt;&lt;P&gt;Sorry for not responding sooner - I've only just worked out how to reply (the reply button doesn't work!)&lt;/P&gt;&lt;P&gt;I actually opened this up as a support ticket with Esri, and they have filed a couple of bugs/enhancements relating to it. As you say, it looks as though this interface isn't actually supported for Python.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Alexander&lt;/STRONG&gt; - thanks, well spotted! I was assuming that any output that's normally written to the screen by Python would be automatically passed back, but I can see that doesn't entirely make sense...&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Duncan&lt;/STRONG&gt; - what I'm trying to do is dependent on having information pass from Python to VB.net within the same ArcMap session (for example, so I can tell which Data Driven Page is currently in view). I think I'm right in saying that all the methodologies described at your first link launch a new ArcMap session? Or am I missing something obvious?&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;&lt;P&gt;Roland.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Mar 2016 17:15:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/python-with-iesriscriptengine/m-p/208285#M5423</guid>
      <dc:creator>RolandMartin</dc:creator>
      <dc:date>2016-03-11T17:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: Python with IESRIScriptEngine</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/python-with-iesriscriptengine/m-p/208286#M5424</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes it is not obvious if you can run the code from within an application and reference the opened MXD. The only thing I can say is give it a go. In arcpy you reference the opened MXD with the word CURRENT. That may work? More information can be found &lt;A href="http://desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-mapping/mapdocument-class.htm"&gt;here&lt;/A&gt;​.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Mar 2016 10:35:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/python-with-iesriscriptengine/m-p/208286#M5424</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2016-03-14T10:35:30Z</dc:date>
    </item>
  </channel>
</rss>

