<?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 How can I get my Script Tool to accept multivalue parameters in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-can-i-get-my-script-tool-to-accept-multivalue/m-p/152415#M11744</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am having all sorts of issues trying to get my stand alone script to be a script tool.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am walking through all the folders, sub folder, gdb, dataset and feature classes.&amp;nbsp; I am having problems with setting my parameter for feature class input in which it doesn't recognize operand and strings if I do the GetParameter() instead of GetParameterAsText(). GetParameterAsText will not let me iterate the multiple feature classes. This is what I have below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #cc7832;"&gt;import &lt;/SPAN&gt;os&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;sys&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;arcpy

&lt;SPAN style="color: #808080;"&gt;#Local Variable
&lt;/SPAN&gt;ws = arcpy.env.workspace = arcpy.GetParameterAsText(&lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;)
walk = arcpy.os.walk(ws)
arcpy.env.overwriteOutput = &lt;SPAN style="color: #8888c6;"&gt;True
&lt;/SPAN&gt;&lt;SPAN style="color: #8888c6;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;# User Input Variable
&lt;/SPAN&gt;fcs = arcpy.GetParameter(&lt;SPAN style="color: #6897bb;"&gt;1&lt;/SPAN&gt;)
&lt;SPAN style="color: #cc7832;"&gt;for &lt;/SPAN&gt;thing &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;fcs:
    arcpy.AddMessage(thing)
company = arcpy.GetParameterAsText(&lt;SPAN style="color: #6897bb;"&gt;2&lt;/SPAN&gt;)
outFolder = arcpy.GetParameterAsText(&lt;SPAN style="color: #6897bb;"&gt;3&lt;/SPAN&gt;)
SQL = arcpy.GetParameterAsText(&lt;SPAN style="color: #6897bb;"&gt;4&lt;/SPAN&gt;)



&lt;SPAN style="color: #808080;"&gt;#Walks through the top folder down to each sub-folder listing all feature class
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;for &lt;/SPAN&gt;dirpath&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;dirnames&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;filenames &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;walk:
    &lt;SPAN style="color: #cc7832;"&gt;for &lt;/SPAN&gt;dirname &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;dirnames:
        arcpy.env.workspace = os.path.join(dirpath&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;dirname) &lt;SPAN style="color: #808080;"&gt;#Changes workspace enviroment to see each directory path/ directory name
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;        #print arcpy.env.workspace 
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;        &lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;for &lt;/SPAN&gt;ds &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;arcpy.ListDatasets(&lt;SPAN style="color: #a5c261;"&gt;''&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #aa4926;"&gt;feature_type&lt;/SPAN&gt;=&lt;SPAN style="color: #a5c261;"&gt;"feature"&lt;/SPAN&gt;):
            &lt;SPAN style="color: #cc7832;"&gt;for &lt;/SPAN&gt;fc &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;arcpy.ListFeatureClasses(&lt;SPAN style="color: #a5c261;"&gt;''&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;''&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;ds):
                &lt;SPAN style="color: #cc7832;"&gt;for &lt;/SPAN&gt;x &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;fcs:
                    outshape = x + &lt;SPAN style="color: #a5c261;"&gt;"_" &lt;/SPAN&gt;+ company + &lt;SPAN style="color: #a5c261;"&gt;"_" &lt;/SPAN&gt;+ time.strftime(&lt;SPAN style="color: #a5c261;"&gt;"%m%d%y"&lt;/SPAN&gt;) + &lt;SPAN style="color: #a5c261;"&gt;"_" &lt;/SPAN&gt;+ &lt;SPAN style="color: #a5c261;"&gt;".shp"
&lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;                    &lt;/SPAN&gt;outpath = os.path.join(outFolder&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;outshape)
                    &lt;SPAN style="color: #cc7832;"&gt;if &lt;/SPAN&gt;x &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;fc:
                        arcpy.Select_analysis(x&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;outpath&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;SQL)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 08:10:21 GMT</pubDate>
    <dc:creator>SheilaNguyen1</dc:creator>
    <dc:date>2021-12-11T08:10:21Z</dc:date>
    <item>
      <title>How can I get my Script Tool to accept multivalue parameters</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-get-my-script-tool-to-accept-multivalue/m-p/152415#M11744</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am having all sorts of issues trying to get my stand alone script to be a script tool.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am walking through all the folders, sub folder, gdb, dataset and feature classes.&amp;nbsp; I am having problems with setting my parameter for feature class input in which it doesn't recognize operand and strings if I do the GetParameter() instead of GetParameterAsText(). GetParameterAsText will not let me iterate the multiple feature classes. This is what I have below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #cc7832;"&gt;import &lt;/SPAN&gt;os&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;sys&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;arcpy

&lt;SPAN style="color: #808080;"&gt;#Local Variable
&lt;/SPAN&gt;ws = arcpy.env.workspace = arcpy.GetParameterAsText(&lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;)
walk = arcpy.os.walk(ws)
arcpy.env.overwriteOutput = &lt;SPAN style="color: #8888c6;"&gt;True
&lt;/SPAN&gt;&lt;SPAN style="color: #8888c6;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;# User Input Variable
&lt;/SPAN&gt;fcs = arcpy.GetParameter(&lt;SPAN style="color: #6897bb;"&gt;1&lt;/SPAN&gt;)
&lt;SPAN style="color: #cc7832;"&gt;for &lt;/SPAN&gt;thing &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;fcs:
    arcpy.AddMessage(thing)
company = arcpy.GetParameterAsText(&lt;SPAN style="color: #6897bb;"&gt;2&lt;/SPAN&gt;)
outFolder = arcpy.GetParameterAsText(&lt;SPAN style="color: #6897bb;"&gt;3&lt;/SPAN&gt;)
SQL = arcpy.GetParameterAsText(&lt;SPAN style="color: #6897bb;"&gt;4&lt;/SPAN&gt;)



&lt;SPAN style="color: #808080;"&gt;#Walks through the top folder down to each sub-folder listing all feature class
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;for &lt;/SPAN&gt;dirpath&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;dirnames&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;filenames &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;walk:
    &lt;SPAN style="color: #cc7832;"&gt;for &lt;/SPAN&gt;dirname &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;dirnames:
        arcpy.env.workspace = os.path.join(dirpath&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;dirname) &lt;SPAN style="color: #808080;"&gt;#Changes workspace enviroment to see each directory path/ directory name
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;        #print arcpy.env.workspace 
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;        &lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;for &lt;/SPAN&gt;ds &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;arcpy.ListDatasets(&lt;SPAN style="color: #a5c261;"&gt;''&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #aa4926;"&gt;feature_type&lt;/SPAN&gt;=&lt;SPAN style="color: #a5c261;"&gt;"feature"&lt;/SPAN&gt;):
            &lt;SPAN style="color: #cc7832;"&gt;for &lt;/SPAN&gt;fc &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;arcpy.ListFeatureClasses(&lt;SPAN style="color: #a5c261;"&gt;''&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;''&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;ds):
                &lt;SPAN style="color: #cc7832;"&gt;for &lt;/SPAN&gt;x &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;fcs:
                    outshape = x + &lt;SPAN style="color: #a5c261;"&gt;"_" &lt;/SPAN&gt;+ company + &lt;SPAN style="color: #a5c261;"&gt;"_" &lt;/SPAN&gt;+ time.strftime(&lt;SPAN style="color: #a5c261;"&gt;"%m%d%y"&lt;/SPAN&gt;) + &lt;SPAN style="color: #a5c261;"&gt;"_" &lt;/SPAN&gt;+ &lt;SPAN style="color: #a5c261;"&gt;".shp"
&lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;                    &lt;/SPAN&gt;outpath = os.path.join(outFolder&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;outshape)
                    &lt;SPAN style="color: #cc7832;"&gt;if &lt;/SPAN&gt;x &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;fc:
                        arcpy.Select_analysis(x&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;outpath&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;SQL)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:10:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-get-my-script-tool-to-accept-multivalue/m-p/152415#M11744</guid>
      <dc:creator>SheilaNguyen1</dc:creator>
      <dc:date>2021-12-11T08:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get my Script Tool to accept multivalue parameters</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-get-my-script-tool-to-accept-multivalue/m-p/152416#M11745</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have to know how your multivalue parameter is set up.&lt;/P&gt;&lt;P&gt;It is described here.&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/arcpy/get-started/working-with-multivalue-inputs.htm" title="https://pro.arcgis.com/en/pro-app/arcpy/get-started/working-with-multivalue-inputs.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Working with multivalue inputs—ArcPy Get Started | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Toss in print statements to see what the values of your parameters are.&amp;nbsp; Don't be surprised it they aren't python list, but semicolon delimited text strings&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;a &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'a;b;c;d'&lt;/SPAN&gt;

a&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;";"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'a'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'b'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'c'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'d'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:10:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-get-my-script-tool-to-accept-multivalue/m-p/152416#M11745</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T08:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get my Script Tool to accept multivalue parameters</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-get-my-script-tool-to-accept-multivalue/m-p/152417#M11746</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sheila,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dan's response above will sort you out with regards to listing the input string values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your script could also be improved by using:&amp;nbsp;&lt;/P&gt;&lt;PRE style="color: #a9b7c6; background-color: #2b2b2b; border: 0px; font-size: 9.8pt;"&gt;walk = arcpy.da.walk(ws)&lt;/PRE&gt;&lt;P&gt;instead of...&lt;/P&gt;&lt;PRE style="color: #a9b7c6; background-color: #2b2b2b; border: 0px; font-size: 9.8pt;"&gt;walk = arcpy.os.walk(ws)&lt;/PRE&gt;&lt;P&gt;arcpy.da.walk() is&amp;nbsp;typically recommended as&amp;nbsp;"&lt;EM&gt;&lt;SPAN class="" style="color: #4d4d4d; background-color: #fefefe; font-size: 14px;"&gt;os.walk&lt;/SPAN&gt;&lt;/EM&gt;&lt;SPAN style="color: #4d4d4d; background-color: #fefefe;"&gt;&lt;EM&gt;&amp;nbsp;is file based and does not recognize database contents such as geodatabase feature classes, tables, or rasters&lt;/EM&gt;". This can simplify your script as you can include the&amp;nbsp;&lt;SPAN class=""&gt;datatype&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;nbsp;parameter&amp;nbsp;within&amp;nbsp;the 'walk' function call&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #4d4d4d; background-color: #fefefe;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4d4d4d; background-color: #fefefe;"&gt;&lt;A class="link-titled" href="https://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-data-access/walk.htm" title="https://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-data-access/walk.htm"&gt;Walk—Help | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4d4d4d; background-color: #fefefe;"&gt;Hope this helps&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jan 2020 05:07:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-get-my-script-tool-to-accept-multivalue/m-p/152417#M11746</guid>
      <dc:creator>JoshuaWatson1</dc:creator>
      <dc:date>2020-01-03T05:07:45Z</dc:date>
    </item>
  </channel>
</rss>

