<?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: Set default values for parameters in toolbox for each user? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/set-default-values-for-parameters-in-toolbox-for/m-p/1359451#M69381</link>
    <description>&lt;P&gt;Worked like a charm.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;'''getParameterInfo()'''
        folder = os.path.expandvars("%APPDATA%\\Esri\ArcGISPro")
        config_path = os.path.join(folder, "zoomToTRS_Config.txt")
        # Check config file for values, use as default. 
        if os.path.exists(config_path):
            with open(config_path, "r") as file:
                    line = file.readline().split(",")
                    param0.value = line[0]
                    param1.value = line[1]
'''Execute'''

        #Save default State and Meridian Value.
        folder = os.path.expandvars("%APPDATA%\\Esri\ArcGISPro")
        config_path = os.path.join(folder, "zoomToTRS_Config.txt")
        # Write/Overwrite if the toggle is turned on.
        if parameters[6].value == True:
            with open(config_path, "w") as file:
                file.write(f"{parameters[0].valueAsText},{parameters[1].valueAsText}")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 12 Dec 2023 16:06:23 GMT</pubDate>
    <dc:creator>AlfredBaldenweck</dc:creator>
    <dc:date>2023-12-12T16:06:23Z</dc:date>
    <item>
      <title>Set default values for parameters in toolbox for each user?</title>
      <link>https://community.esri.com/t5/python-questions/set-default-values-for-parameters-in-toolbox-for/m-p/1356016#M69322</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;We have a custom toolbar that references a toolbox on a network drive somewhere. I was wondering if it's possible at all for users to set defaults for the tool individually? That is, each user's preferred values for the parameters would be saved for them.&lt;/P&gt;&lt;P&gt;For example, one tool zooms to PLSS Township sections. The first parameter is the user's state (California, Oregon, etc), and the second is the meridian. It's pretty annoying to always have to pick your state every time, but the tool is available for every user in our agency across the country.&lt;/P&gt;&lt;P&gt;I don't think this is possible, but if someone could surprise me, that'd be awesome.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2023 22:27:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-default-values-for-parameters-in-toolbox-for/m-p/1356016#M69322</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2023-12-01T22:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: Set default values for parameters in toolbox for each user?</title>
      <link>https://community.esri.com/t5/python-questions/set-default-values-for-parameters-in-toolbox-for/m-p/1356033#M69323</link>
      <description>&lt;P&gt;You can do this by:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Looking for a text file with config options in a known location and populating those values in the tool's validation section if they exist, and&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;Writing the user's chosen values to said config file if no default value exists.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;For the location of the file, the best practice for Windows is to use a folder with your team's name in the %APPDATA% folder, which is set per user. You can get the config file like so:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import os
from os import path
folder = path.expandvars("%APPDATA%\\AlfredSoft")
if not path.exists(folder):
    os.mkdir(folder)
config_path = path.join(folder, "tool_config.json")  # Or whatever format works for you
if path.exists(config_path):
    with open(config_path) as config:
        pass  # Work with the file here!&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;As for creating or editing the config file, you should do that in the tool itself or in the validator's updateParameters method, depending on how you want to lay your code out. If you get reading working then writing shouldn't be much more work.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2023 23:15:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-default-values-for-parameters-in-toolbox-for/m-p/1356033#M69323</guid>
      <dc:creator>DavidSolari</dc:creator>
      <dc:date>2023-12-01T23:15:37Z</dc:date>
    </item>
    <item>
      <title>Re: Set default values for parameters in toolbox for each user?</title>
      <link>https://community.esri.com/t5/python-questions/set-default-values-for-parameters-in-toolbox-for/m-p/1359451#M69381</link>
      <description>&lt;P&gt;Worked like a charm.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;'''getParameterInfo()'''
        folder = os.path.expandvars("%APPDATA%\\Esri\ArcGISPro")
        config_path = os.path.join(folder, "zoomToTRS_Config.txt")
        # Check config file for values, use as default. 
        if os.path.exists(config_path):
            with open(config_path, "r") as file:
                    line = file.readline().split(",")
                    param0.value = line[0]
                    param1.value = line[1]
'''Execute'''

        #Save default State and Meridian Value.
        folder = os.path.expandvars("%APPDATA%\\Esri\ArcGISPro")
        config_path = os.path.join(folder, "zoomToTRS_Config.txt")
        # Write/Overwrite if the toggle is turned on.
        if parameters[6].value == True:
            with open(config_path, "w") as file:
                file.write(f"{parameters[0].valueAsText},{parameters[1].valueAsText}")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2023 16:06:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-default-values-for-parameters-in-toolbox-for/m-p/1359451#M69381</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2023-12-12T16:06:23Z</dc:date>
    </item>
  </channel>
</rss>

