<?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: How to run a python script in ArcGIS Pro SDK? in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-run-a-python-script-in-arcgis-pro-sdk/m-p/1303227#M9982</link>
    <description>&lt;P&gt;i will try this tomorrow, but it looks like line 22 has a syntax error.&amp;nbsp; Maybe you fixed that already.&lt;/P&gt;</description>
    <pubDate>Mon, 26 Jun 2023 23:51:31 GMT</pubDate>
    <dc:creator>Wolf</dc:creator>
    <dc:date>2023-06-26T23:51:31Z</dc:date>
    <item>
      <title>How to run a python script in ArcGIS Pro SDK?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-run-a-python-script-in-arcgis-pro-sdk/m-p/1299508#M9936</link>
      <description>&lt;P&gt;I am able to get the Geoprocessing tools using C# in ArcGIS Pro SDK to work, but it takes a longer time to figure out the syntax. I decided to write the script in python and use it in my tool. For some reason, it doesn't seem to work. I included my python script below. Thanks for your help! Here is C# code in the CreateModelSoils.class file:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; public void GenModelSoils_py(FeatureLayer aggLayer, FeatureLayer allSoils, string AggField, string outGDB)
        {
            string installPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            string toolboxPath = Path.Combine(installPath, "GenIntersectSort.py");
            var args = Geoprocessing.MakeValueArray(aggLayer, allSoils, AggField, outGDB);
            Geoprocessing.ExecuteToolAsync(toolboxPath, args);
}

           &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I call this method in my ViewModel:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;CreateModelSoils ms = new CreateModelSoils();
ms.GenModelSoils_py(AggregateLayer, AllSoils, SelectedField, outGDB);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Here is the python script I would like to run:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#Import libraries
import arcpy
import os

Def GenIntersectSort(aggLayer,allSoils,aggField,outGDB):
	
	#Setting the environment
	arcpy.env.workspace = outGDB
	arcpy.env.overwriteOutput=1
	
	#Declare variables
	aggLayer = os.path.join(outGDB, "\\" + AggLayer_Name)
	allSoils = os.path.join(outGDB, "\\All_Soils")
	Intersect_Sort = os.path.join(outGDB, "\\Intersect_Sort")
    Model_Soils = os.path.join(outGDB, "\\Model_Soils")

	#Intersect the aggregate layer and All_Soils layers
	in_features = [aggLayer,allSoils]
	Intersect = arcpy.Intersect_analysis(in_features,"memory\\Intersect","ALL","","INPUT")

	#Sort the Intersect_Sort fields
	sort_fields = [[AggField,"ASCENDING"],["MUKEY",""ASCENDING"]]
	Intersect_Sort = arcpy.Sort_management(Intersect,Intersect_Sort,sort_fields)
    
    #Create the Model_Soils layer with ID
    Model_Soils = arcpy.FeatureClassToFeatureLClass_conversion(Intersect_Sort,outGDB,'Model_Soils')
    
    //Clean-Up the Model_Soils fields
    keep_fields = "Element_ID"
    Delete_fields = arcpy.DeleteFields_management(Model_Soils,keep_fields,"KEEP_FIELDS")
   
	
	return Model_Soils&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 00:39:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-run-a-python-script-in-arcgis-pro-sdk/m-p/1299508#M9936</guid>
      <dc:creator>tzz_12</dc:creator>
      <dc:date>2023-06-15T00:39:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to run a python script in ArcGIS Pro SDK?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-run-a-python-script-in-arcgis-pro-sdk/m-p/1300680#M9946</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;There is ArcGIS Pro sdk community sample&amp;nbsp;&amp;nbsp;&lt;A href="https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Geoprocessing/CallScriptFromNet" target="_self"&gt;CallScriptFromNet&lt;/A&gt;&amp;nbsp;. It could help you.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2023 11:52:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-run-a-python-script-in-arcgis-pro-sdk/m-p/1300680#M9946</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2023-06-19T11:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to run a python script in ArcGIS Pro SDK?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-run-a-python-script-in-arcgis-pro-sdk/m-p/1303227#M9982</link>
      <description>&lt;P&gt;i will try this tomorrow, but it looks like line 22 has a syntax error.&amp;nbsp; Maybe you fixed that already.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2023 23:51:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-run-a-python-script-in-arcgis-pro-sdk/m-p/1303227#M9982</guid>
      <dc:creator>Wolf</dc:creator>
      <dc:date>2023-06-26T23:51:31Z</dc:date>
    </item>
  </channel>
</rss>

