<?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 satisfy Python Script Tool required parameter with optional boolean? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-satisfy-python-script-tool-required/m-p/488688#M38204</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@ Ian - Thanks for your reply. There's a couple of different reasons for this. Firstly, the tool I'm making is not necessarily for people who are GIS savvy, ergo they may not know where/what their default gdB is, or how to find it. Also, being as how selecting a gdB path is subject to the most recently viewed folder (i.e., when selecting the folder button, it will not necessarily show the defaulted path, but rather the last path accessed), I want a quick and easy way to fill the folder with the default path by clicking the check-box. Lastly, I understand what I'm asking isn't exactly practical, I'm more just curious as to how one would go about doing this. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 13 Jul 2015 20:15:41 GMT</pubDate>
    <dc:creator>LanceWilson</dc:creator>
    <dc:date>2015-07-13T20:15:41Z</dc:date>
    <item>
      <title>How to satisfy Python Script Tool required parameter with optional boolean?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-satisfy-python-script-tool-required/m-p/488684#M38200</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm using ArcGIS for Desktop 10.3.0.4322&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a script tool which requires a parameter in the GUI (folder path to a gdB, via GetParameterAsText) so that a later process can be saved there. The thing I want to do is make an Optional Boolean parameter, that when checked, automatically fills in the folder path gdB parameter. The boolean text asks the user, "Use default workspace?", to which if they check the box (boolean == True), then the folder path parameter will be automatically defaulted (saving the user a small amount of time). I have already created the boolean parameter in the script tool, I am however unaware of how to "fill in" the required parameter based on the user's boolean. Thanks in advance for any help/tips!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code Snippet:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Ask user to select the Geodatabase workspace to use for data output
&amp;nbsp;&amp;nbsp;&amp;nbsp; userWorkspace = arcpy.GetParameterAsText(0)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Ask user if they want to use default workspace (boolean)
&amp;nbsp;&amp;nbsp;&amp;nbsp; useDefault = arcpy.GetParameterAsText(1)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # If user wants default workspace, then give it to the required parameter (0)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if useDefault == True:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = path
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Set workspace environment based upon user's choice
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = userWorkspace&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Test_Script_Tool2.jpg" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/116990_Test_Script_Tool2.jpg" style="height: auto;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:29:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-satisfy-python-script-tool-required/m-p/488684#M38200</guid>
      <dc:creator>LanceWilson</dc:creator>
      <dc:date>2021-12-11T21:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to satisfy Python Script Tool required parameter with optional boolean?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-satisfy-python-script-tool-required/m-p/488685#M38201</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;why create a Boolean Parameter, when you can have the default workspace as the default value for the workspace parameter?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could set the default value when creating the script tool and the user would have the option to change it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//00150000000n000000" title="http://resources.arcgis.com/en/help/main/10.1/index.html#//00150000000n000000"&gt;ArcGIS Help 10.1&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jul 2015 19:46:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-satisfy-python-script-tool-required/m-p/488685#M38201</guid>
      <dc:creator>IanMurray</dc:creator>
      <dc:date>2015-07-13T19:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to satisfy Python Script Tool required parameter with optional boolean?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-satisfy-python-script-tool-required/m-p/488686#M38202</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What may work for you is &lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//00150000000t000000"&gt;script tool validation&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jul 2015 19:50:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-satisfy-python-script-tool-required/m-p/488686#M38202</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2015-07-13T19:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to satisfy Python Script Tool required parameter with optional boolean?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-satisfy-python-script-tool-required/m-p/488687#M38203</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can probably use a tool validator to satisfy the required condition. Honestly I would just make the parameter optional because the user isn't required to interact with it to set it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jul 2015 19:50:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-satisfy-python-script-tool-required/m-p/488687#M38203</guid>
      <dc:creator>FreddieGibson</dc:creator>
      <dc:date>2015-07-13T19:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to satisfy Python Script Tool required parameter with optional boolean?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-satisfy-python-script-tool-required/m-p/488688#M38204</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@ Ian - Thanks for your reply. There's a couple of different reasons for this. Firstly, the tool I'm making is not necessarily for people who are GIS savvy, ergo they may not know where/what their default gdB is, or how to find it. Also, being as how selecting a gdB path is subject to the most recently viewed folder (i.e., when selecting the folder button, it will not necessarily show the defaulted path, but rather the last path accessed), I want a quick and easy way to fill the folder with the default path by clicking the check-box. Lastly, I understand what I'm asking isn't exactly practical, I'm more just curious as to how one would go about doing this. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jul 2015 20:15:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-satisfy-python-script-tool-required/m-p/488688#M38204</guid>
      <dc:creator>LanceWilson</dc:creator>
      <dc:date>2015-07-13T20:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to satisfy Python Script Tool required parameter with optional boolean?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-satisfy-python-script-tool-required/m-p/488689#M38205</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As &lt;A href="https://community.esri.com/migrated-users/14792" target="_blank"&gt;Freddie Gibson&lt;/A&gt; says, use tool validation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;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 parameter
&amp;nbsp;&amp;nbsp;&amp;nbsp; has been changed."""
&amp;nbsp;&amp;nbsp;&amp;nbsp; if self.params[1].value == True:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.params[0].value = arcpy.env.workspace
&amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.)&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="117112" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/117112_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2.) &lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/117132_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:29:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-satisfy-python-script-tool-required/m-p/488689#M38205</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2021-12-11T21:29:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to satisfy Python Script Tool required parameter with optional boolean?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-satisfy-python-script-tool-required/m-p/488690#M38206</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Great, thank you very much for the walk-through explanation. Thanks to everyone for helping point me to 'Tool Validation', which I wasn't very familiar with.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jul 2015 21:38:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-satisfy-python-script-tool-required/m-p/488690#M38206</guid>
      <dc:creator>LanceWilson</dc:creator>
      <dc:date>2015-07-13T21:38:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to satisfy Python Script Tool required parameter with optional boolean?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-satisfy-python-script-tool-required/m-p/488691#M38207</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just finally realized this, after running my tool a few times. Checking the optional box does indeed automatically make the text reflect that of the default gdB workspace. However, now when I don't check it and put in the path to a different gdB, it still goes saves to the default gdB, and in the processing window states 'false' for parameter [0] and 'true' for [1], which I don't understand because [0] is not a boolean, it is a workspace directory. Going to write in some extra code to see if that helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again Darren!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jul 2015 18:49:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-satisfy-python-script-tool-required/m-p/488691#M38207</guid>
      <dc:creator>LanceWilson</dc:creator>
      <dc:date>2015-07-15T18:49:02Z</dc:date>
    </item>
  </channel>
</rss>

