<?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: parameters, launching from vba code, and more in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/python-parameters-launching-from-vba-code-and-more/m-p/366072#M12593</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Woops my bad...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Good catch!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 01 Nov 2010 18:40:51 GMT</pubDate>
    <dc:creator>ChrisSnyder</dc:creator>
    <dc:date>2010-11-01T18:40:51Z</dc:date>
    <item>
      <title>Python: parameters, launching from vba code, and more</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-parameters-launching-from-vba-code-and-more/m-p/366061#M12582</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello everyone,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Very new to python.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have VBA code that should eventually allow a user to input a dataset (watersheds) and launch python scripts that will calculate various attributes of those watersheds.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The first script I am working on calculates the area of different land cover classes within each watershed by&amp;nbsp; A) intersect watersheds and landcover (both vector) B) Dissolve based on unique watershed and land cover IDs C) export the attribute table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. How do I launch a python script from a VBA code?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. How do I set up the parameters for the script?&amp;nbsp; i.e. get the watersheds and land cover from the vba code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you could point me towards websites/books/anything that may help I would appreciate it, or offer your own insight :).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Oct 2010 19:48:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-parameters-launching-from-vba-code-and-more/m-p/366061#M12582</guid>
      <dc:creator>LornaMurison</dc:creator>
      <dc:date>2010-10-29T19:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: Python: parameters, launching from vba code, and more</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-parameters-launching-from-vba-code-and-more/m-p/366062#M12583</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You should be able to launch the python.exe executable, like you launch any program in VBA. Then pass the script path/name as the first parameter, and then additional parameters.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;On the Python side, import sys and look at sys.argv for the arguments/parameters. You can find more information about that in your favorite manual/documentation - just look for argv!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Nov 2010 08:30:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-parameters-launching-from-vba-code-and-more/m-p/366062#M12583</guid>
      <dc:creator>HugoAhlenius</dc:creator>
      <dc:date>2010-11-01T08:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: Python: parameters, launching from vba code, and more</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-parameters-launching-from-vba-code-and-more/m-p/366063#M12584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;ArcGIS help for 9.3 recommends using gp.GetParameterAsText() instead of sys.argv[] so I am trying to use that.&amp;nbsp; Unless there is a particular reason why one is better than the other.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Below is what I have and although the errors must be painfully obvious to most of you, I cannot figure out how to get the parameter syntax right.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It is the output I am having trouble with.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcgisscripting
gp = arcgisscripting.create(9.3)
Catchments = gp.GetParameterAsText(0)
LandCover = gp.GetParameterAsText(1)
Output = gp.GetParameterAsText(2)
gp.Toolbox = "Analysis"
gp.Intersect ("LandCover; Catchments", "Output + 'output.shp'", "ALL", "", "INPUT")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:00:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-parameters-launching-from-vba-code-and-more/m-p/366063#M12584</guid>
      <dc:creator>LornaMurison</dc:creator>
      <dc:date>2021-12-11T17:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: Python: parameters, launching from vba code, and more</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-parameters-launching-from-vba-code-and-more/m-p/366064#M12585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;FYI: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.GetParameterAsText() is used only when getting arguments from an ArcToolbox tool interface&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;sys.argv[] is used when getting arguments from another "non-toolbox" source. For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#master script (calls 100 instances of "subprocess.py"
subProcessScript = r"C:\temp\subprocess.py"
pythonExePath = r"C:\Python25\python.exe"
rootDir = r"D:\temp"
for tileNumber in range (1,101):
&amp;nbsp;&amp;nbsp; parameterList = [pythonExePath, subProcessScript, rootDir, str(tileNumber)]
&amp;nbsp;&amp;nbsp; os.spawnv(os.P_WAIT, pythonExePath, parameterList)

#subprocess program (subprocess.py)
rootDir = sys.argv[1]
tileNumber = sys.argv[2]
os.mkdir(rootDir + "\\tile_" + str(tileNumber)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:00:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-parameters-launching-from-vba-code-and-more/m-p/366064#M12585</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-11T17:00:49Z</dc:date>
    </item>
    <item>
      <title>Re: Python: parameters, launching from vba code, and more</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-parameters-launching-from-vba-code-and-more/m-p/366065#M12586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is Output = gp.GetParameterAsText(2) a featureclass output?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If so:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.Intersect ("LandCover; Catchments", Output, "ALL", "", "INPUT") #don't put quotes around the variable because if you do, it just becomes a string...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If Output is the directory where "output.shp" will be stored, then:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.Intersect ("LandCover; Catchments", Output + "\\output.shp", "ALL", "", "INPUT")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You might want to consider making a toolbox GUI, then there is easy control over the "types" of parameters (e.g. Folder vs. a FeatureClass vs. a Raster).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Nov 2010 17:38:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-parameters-launching-from-vba-code-and-more/m-p/366065#M12586</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2010-11-01T17:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: Python: parameters, launching from vba code, and more</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-parameters-launching-from-vba-code-and-more/m-p/366066#M12587</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for your help,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It's supposed to be a feature class output.&amp;nbsp; But... if i set the script parameter as an output, it no longer shows up on the tool dialog.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I still get the following error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;class 'arcgisscripting.ExecuteError'&amp;gt;: Failed to execute. Parameters are not valid.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000732: Input Features: Dataset Catchments #;LandCover # does not exist or is not supported&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000735: Output Feature Class: Value is required&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (Intersect).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcgisscripting
gp = arcgisscripting.create(9.3)
Catchments = gp.GetParameterAsText(0)
LandCover = gp.GetParameterAsText(1)
Output = gp.GetParameterAsText(2)
gp.Toolbox = "Analysis"
gp.workspace = "F:\Hydrology_Tools\Data"
gp.Intersect ("Catchments; LandCover", Output, "ALL", "", "INPUT")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:00:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-parameters-launching-from-vba-code-and-more/m-p/366066#M12587</guid>
      <dc:creator>LornaMurison</dc:creator>
      <dc:date>2021-12-11T17:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: Python: parameters, launching from vba code, and more</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-parameters-launching-from-vba-code-and-more/m-p/366067#M12588</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;your code of:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.Intersect ("Catchments; LandCover", Output, "ALL", "", "INPUT")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;should be:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.Intersect (Catchments + ";" LandCover, Output, "ALL", "", "INPUT")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When you used "Catchments; LandCover"&amp;nbsp; in your code, you are using the string equivalent instead of the variables (formatted as a string in order to be used in the tool).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Nov 2010 17:52:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-parameters-launching-from-vba-code-and-more/m-p/366067#M12588</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2010-11-01T17:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: Python: parameters, launching from vba code, and more</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-parameters-launching-from-vba-code-and-more/m-p/366068#M12589</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That makes sense...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I was looking at an example that got the files from the string path name.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now I get this error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;type 'exceptions.SyntaxError'&amp;gt;: invalid syntax (&amp;lt;string&amp;gt;, line 7)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (Intersect).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcgisscripting
gp = arcgisscripting.create(9.3)
Catchments = gp.GetParameterAsText(0)
LandCover = gp.GetParameterAsText(1)
Output = gp.GetParameterAsText(2)
gp.Toolbox = "Analysis"
gp.Intersect (Catchments + ";" LandCover, Output, "ALL", "", "INPUT")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:00:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-parameters-launching-from-vba-code-and-more/m-p/366068#M12589</guid>
      <dc:creator>LornaMurison</dc:creator>
      <dc:date>2021-12-11T17:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: Python: parameters, launching from vba code, and more</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-parameters-launching-from-vba-code-and-more/m-p/366069#M12590</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here's how I would do it:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcgisscripting
gp = arcgisscripting.create(9.3)
gp.overwriteoutput = True
catchmentsFC = gp.GetParameterAsText(0) #in a toolbox GUI, this should be Type = FeatureLayer
landCoverFC = gp.GetParameterAsText(1) #in a toolbox GUI, this should be Type = FeatureLayer
outputFC = gp.GetParameterAsText(2) #in a toolbox GUI, this should Type = FeatureClass
gp.Intersect_Analysis (catchmentsFC + ";" landCoverFC, outputFC, "ALL", "", "INPUT")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:00:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-parameters-launching-from-vba-code-and-more/m-p/366069#M12590</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-11T17:00:57Z</dc:date>
    </item>
    <item>
      <title>Re: Python: parameters, launching from vba code, and more</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-parameters-launching-from-vba-code-and-more/m-p/366070#M12591</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I used the exact code you posted.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I still got the same error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;type 'exceptions.SyntaxError'&amp;gt;: invalid syntax (&amp;lt;string&amp;gt;, line 7)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (Intersect).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The parameters in the Toolbox GUI are Feature Layer Input, Feature Layer Input, Feature Class Output.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Nov 2010 18:16:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-parameters-launching-from-vba-code-and-more/m-p/366070#M12591</guid>
      <dc:creator>LornaMurison</dc:creator>
      <dc:date>2010-11-01T18:16:01Z</dc:date>
    </item>
    <item>
      <title>Re: Python: parameters, launching from vba code, and more</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-parameters-launching-from-vba-code-and-more/m-p/366071#M12592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There was a "+" missing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I got it to work!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Nov 2010 18:24:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-parameters-launching-from-vba-code-and-more/m-p/366071#M12592</guid>
      <dc:creator>LornaMurison</dc:creator>
      <dc:date>2010-11-01T18:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: Python: parameters, launching from vba code, and more</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-parameters-launching-from-vba-code-and-more/m-p/366072#M12593</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Woops my bad...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Good catch!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Nov 2010 18:40:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-parameters-launching-from-vba-code-and-more/m-p/366072#M12593</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2010-11-01T18:40:51Z</dc:date>
    </item>
  </channel>
</rss>

