<?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: Setting multivalue parameters to True in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/setting-multivalue-parameters-to-true/m-p/582021#M45601</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I did just this for a tool last week - I'm at 10.0 and used the ToolValidator, simple changing (or adding) 3 lines:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;class ToolValidator: &amp;nbsp; """Class for validating a tool's parameter values and controlling &amp;nbsp; the behavior of the tool's dialog."""&amp;nbsp;&amp;nbsp; &amp;nbsp; def __init__(self): &amp;nbsp;&amp;nbsp;&amp;nbsp; """Setup arcpy and the list of tool parameters.""" &amp;nbsp;&amp;nbsp;&amp;nbsp; import arcpy &amp;nbsp;&amp;nbsp;&amp;nbsp; self.params = arcpy.GetParameterInfo()&amp;nbsp;&amp;nbsp; &amp;nbsp; def initializeParameters(self): &amp;nbsp;&amp;nbsp;&amp;nbsp; """Refine the properties of a tool's parameters.&amp;nbsp; This method is &amp;nbsp;&amp;nbsp;&amp;nbsp; called when the tool is opened.""" &amp;nbsp;&amp;nbsp;&amp;nbsp; self.params[0].filter.list = ['val1', 'val2', 'val3', 'val4'] &amp;nbsp;&amp;nbsp;&amp;nbsp; return&amp;nbsp;&amp;nbsp; &amp;nbsp; def updateParameters(self): &amp;nbsp;&amp;nbsp;&amp;nbsp; """Modify the values and properties of parameters before internal &amp;nbsp;&amp;nbsp;&amp;nbsp; validation is performed.&amp;nbsp; This method is called whenever a parmater &amp;nbsp;&amp;nbsp;&amp;nbsp; has been changed."""&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if not self.params[0].altered: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.params[0].value = r"'val1';'val2';'val3'" &amp;nbsp;&amp;nbsp;&amp;nbsp; return&amp;nbsp;&amp;nbsp; &amp;nbsp; def updateMessages(self): &amp;nbsp;&amp;nbsp;&amp;nbsp; """Modify the messages created by internal validation for each tool &amp;nbsp;&amp;nbsp;&amp;nbsp; parameter.&amp;nbsp; This method is called after internal validation.""" &amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The line "self.params[0].filter.list = ['val1', 'val2', 'val3', 'val4']" sets my value list (in this case, for the 1st input parameter ([0]), a multivalue param.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The 2-line block sets up the default 3 vals checked on by default - if what is checkmarked by default is 'altered', then that defines the new input:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;if not self.params[0].altered: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.params[0].value = r"'val1';'val2';'val3'"&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As a result, on execution vals 1-3 are on and are fetched correctly at GetParameterAsText and if val4 is checked on, then GetParameterAsText fetches the additional val4.&amp;nbsp; (or if any other combination is chosen, the input is adjusted accordingly)&amp;nbsp; Perfect!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Enjoy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wayne&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 16 Mar 2013 20:32:55 GMT</pubDate>
    <dc:creator>T__WayneWhitley</dc:creator>
    <dc:date>2013-03-16T20:32:55Z</dc:date>
    <item>
      <title>Setting multivalue parameters to True</title>
      <link>https://community.esri.com/t5/python-questions/setting-multivalue-parameters-to-true/m-p/582018#M45598</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all, is there a way to set the default values in a multivalue Parameter to True or Selected? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Mar 2013 23:18:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setting-multivalue-parameters-to-true/m-p/582018#M45598</guid>
      <dc:creator>JonPedder</dc:creator>
      <dc:date>2013-03-14T23:18:23Z</dc:date>
    </item>
    <item>
      <title>Re: Setting multivalue parameters to True</title>
      <link>https://community.esri.com/t5/python-questions/setting-multivalue-parameters-to-true/m-p/582019#M45599</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is your multi-value parameter for a script tool or an add-in component?&amp;nbsp; Can you show the outline for the code where you would like to implement this?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Mar 2013 01:26:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setting-multivalue-parameters-to-true/m-p/582019#M45599</guid>
      <dc:creator>MelanieMaguire</dc:creator>
      <dc:date>2013-03-16T01:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: Setting multivalue parameters to True</title>
      <link>https://community.esri.com/t5/python-questions/setting-multivalue-parameters-to-true/m-p/582020#M45600</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It's for a script tool. I'm using a string parameter with a value list. Right now the value list is generated in teh script tool but could be created using validation class I guess?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have 6 string values that I'd like to set by default to True or Checked. So when the script tool is opened the multivalue string check boxes are selected. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not stuck on string as a type, I could easily select another data type and work with that. Using individual Boolean parameters makes the script tool extend too far (too much screen space), unless there's a way to arrange Boolean within the script tool?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jon&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Mar 2013 19:58:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setting-multivalue-parameters-to-true/m-p/582020#M45600</guid>
      <dc:creator>JonPedder</dc:creator>
      <dc:date>2013-03-16T19:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: Setting multivalue parameters to True</title>
      <link>https://community.esri.com/t5/python-questions/setting-multivalue-parameters-to-true/m-p/582021#M45601</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I did just this for a tool last week - I'm at 10.0 and used the ToolValidator, simple changing (or adding) 3 lines:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;class ToolValidator: &amp;nbsp; """Class for validating a tool's parameter values and controlling &amp;nbsp; the behavior of the tool's dialog."""&amp;nbsp;&amp;nbsp; &amp;nbsp; def __init__(self): &amp;nbsp;&amp;nbsp;&amp;nbsp; """Setup arcpy and the list of tool parameters.""" &amp;nbsp;&amp;nbsp;&amp;nbsp; import arcpy &amp;nbsp;&amp;nbsp;&amp;nbsp; self.params = arcpy.GetParameterInfo()&amp;nbsp;&amp;nbsp; &amp;nbsp; def initializeParameters(self): &amp;nbsp;&amp;nbsp;&amp;nbsp; """Refine the properties of a tool's parameters.&amp;nbsp; This method is &amp;nbsp;&amp;nbsp;&amp;nbsp; called when the tool is opened.""" &amp;nbsp;&amp;nbsp;&amp;nbsp; self.params[0].filter.list = ['val1', 'val2', 'val3', 'val4'] &amp;nbsp;&amp;nbsp;&amp;nbsp; return&amp;nbsp;&amp;nbsp; &amp;nbsp; def updateParameters(self): &amp;nbsp;&amp;nbsp;&amp;nbsp; """Modify the values and properties of parameters before internal &amp;nbsp;&amp;nbsp;&amp;nbsp; validation is performed.&amp;nbsp; This method is called whenever a parmater &amp;nbsp;&amp;nbsp;&amp;nbsp; has been changed."""&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if not self.params[0].altered: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.params[0].value = r"'val1';'val2';'val3'" &amp;nbsp;&amp;nbsp;&amp;nbsp; return&amp;nbsp;&amp;nbsp; &amp;nbsp; def updateMessages(self): &amp;nbsp;&amp;nbsp;&amp;nbsp; """Modify the messages created by internal validation for each tool &amp;nbsp;&amp;nbsp;&amp;nbsp; parameter.&amp;nbsp; This method is called after internal validation.""" &amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The line "self.params[0].filter.list = ['val1', 'val2', 'val3', 'val4']" sets my value list (in this case, for the 1st input parameter ([0]), a multivalue param.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The 2-line block sets up the default 3 vals checked on by default - if what is checkmarked by default is 'altered', then that defines the new input:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;if not self.params[0].altered: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.params[0].value = r"'val1';'val2';'val3'"&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As a result, on execution vals 1-3 are on and are fetched correctly at GetParameterAsText and if val4 is checked on, then GetParameterAsText fetches the additional val4.&amp;nbsp; (or if any other combination is chosen, the input is adjusted accordingly)&amp;nbsp; Perfect!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Enjoy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wayne&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Mar 2013 20:32:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setting-multivalue-parameters-to-true/m-p/582021#M45601</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2013-03-16T20:32:55Z</dc:date>
    </item>
    <item>
      <title>Re: Setting multivalue parameters to True</title>
      <link>https://community.esri.com/t5/python-questions/setting-multivalue-parameters-to-true/m-p/582022#M45602</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Perfect, thanks very much Wayne!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 17 Mar 2013 15:47:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setting-multivalue-parameters-to-true/m-p/582022#M45602</guid>
      <dc:creator>JonPedder</dc:creator>
      <dc:date>2013-03-17T15:47:58Z</dc:date>
    </item>
  </channel>
</rss>

