<?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 Pass multiple parameters into script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/pass-multiple-parameters-into-script/m-p/1124014#M63181</link>
    <description>&lt;P&gt;I have the following basic code, I need to be able to run the script to select either 1 features or multiple features based on what is provided from arcpy.GetParameterAsText(0)&lt;/P&gt;&lt;P&gt;I have the arcpy.GetParameterAsText(0) set as 'Any Value' and for the data type parameter properties MultiValue set to 'Yes' but I keep getting the error. I am guessing that my whereClause is incorrect and if so how can I get to work?&lt;/P&gt;&lt;P&gt;PLATNAME field is a text field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error;&lt;/P&gt;&lt;P&gt;ERROR 000358: Invalid expression&lt;BR /&gt;Failed to execute (SelectLayerByAttribute)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Script code;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

mxd = arcpy.mapping.MapDocument('CURRENT')   
df = arcpy.mapping.ListDataFrames(mxd, "Layers") [0]   
lyr = arcpy.mapping.ListLayers(mxd, "Subs")[0]

search_string = arcpy.GetParameterAsText(0)
search_string = search_string.split(";")
search_string = ["'{0}'".format(v) for v in search_string]
whereClause = "{0} IN ({1})".format("PLATNAME", ",".join(search_string))

arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION",whereClause )  
with arcpy.da.SearchCursor(lyr, ["SHAPE@","PLATNAME"]) as cursor:   
    for row in cursor:  
        df.extent = row[0].extent   
        df.scale = df.scale * 5   
        arcpy.RefreshActiveView() &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 08 Dec 2021 21:01:14 GMT</pubDate>
    <dc:creator>2Quiker</dc:creator>
    <dc:date>2021-12-08T21:01:14Z</dc:date>
    <item>
      <title>Pass multiple parameters into script</title>
      <link>https://community.esri.com/t5/python-questions/pass-multiple-parameters-into-script/m-p/1124014#M63181</link>
      <description>&lt;P&gt;I have the following basic code, I need to be able to run the script to select either 1 features or multiple features based on what is provided from arcpy.GetParameterAsText(0)&lt;/P&gt;&lt;P&gt;I have the arcpy.GetParameterAsText(0) set as 'Any Value' and for the data type parameter properties MultiValue set to 'Yes' but I keep getting the error. I am guessing that my whereClause is incorrect and if so how can I get to work?&lt;/P&gt;&lt;P&gt;PLATNAME field is a text field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error;&lt;/P&gt;&lt;P&gt;ERROR 000358: Invalid expression&lt;BR /&gt;Failed to execute (SelectLayerByAttribute)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Script code;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

mxd = arcpy.mapping.MapDocument('CURRENT')   
df = arcpy.mapping.ListDataFrames(mxd, "Layers") [0]   
lyr = arcpy.mapping.ListLayers(mxd, "Subs")[0]

search_string = arcpy.GetParameterAsText(0)
search_string = search_string.split(";")
search_string = ["'{0}'".format(v) for v in search_string]
whereClause = "{0} IN ({1})".format("PLATNAME", ",".join(search_string))

arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION",whereClause )  
with arcpy.da.SearchCursor(lyr, ["SHAPE@","PLATNAME"]) as cursor:   
    for row in cursor:  
        df.extent = row[0].extent   
        df.scale = df.scale * 5   
        arcpy.RefreshActiveView() &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Dec 2021 21:01:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/pass-multiple-parameters-into-script/m-p/1124014#M63181</guid>
      <dc:creator>2Quiker</dc:creator>
      <dc:date>2021-12-08T21:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: Pass multiple parameters into script</title>
      <link>https://community.esri.com/t5/python-questions/pass-multiple-parameters-into-script/m-p/1124124#M63185</link>
      <description>&lt;P&gt;I would simply dump out the variables and see what they look like - something like this (this is in a python toolbox?)&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.AddMessage("search_string: " + search_string)
arcpy.AddMessage("whereClause: " + whereClause)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Dec 2021 00:17:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/pass-multiple-parameters-into-script/m-p/1124124#M63185</guid>
      <dc:creator>DonMorrison1</dc:creator>
      <dc:date>2021-12-09T00:17:12Z</dc:date>
    </item>
    <item>
      <title>Re: Pass multiple parameters into script</title>
      <link>https://community.esri.com/t5/python-questions/pass-multiple-parameters-into-script/m-p/1124895#M63225</link>
      <description>&lt;P&gt;Thank you for suggesting the print/add message, seems I always forget to do that. Turns out that line 9 puts extra set of apostrophes in the string , ''Rosedown sub''. I made changes to line 9.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Change line 9 from&lt;/P&gt;&lt;LI-CODE lang="python"&gt;earch_string = ["'{0}'".format(v) for v in search_string]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;to&lt;/P&gt;&lt;LI-CODE lang="c"&gt;earch_string = ["{0}".format(v) for v in search_string]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Dec 2021 16:05:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/pass-multiple-parameters-into-script/m-p/1124895#M63225</guid>
      <dc:creator>2Quiker</dc:creator>
      <dc:date>2021-12-10T16:05:54Z</dc:date>
    </item>
  </channel>
</rss>

