<?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: Tying to allow the user to set their workspace in a custom scirpt tool in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/tying-to-allow-the-user-to-set-their-workspace-in/m-p/1636328#M74537</link>
    <description>&lt;P&gt;Thank you both! I will try both solutions and let you know!&lt;/P&gt;</description>
    <pubDate>Fri, 25 Jul 2025 12:32:38 GMT</pubDate>
    <dc:creator>dcaESRIwvges</dc:creator>
    <dc:date>2025-07-25T12:32:38Z</dc:date>
    <item>
      <title>Tying to allow the user to set their workspace in a custom scirpt tool</title>
      <link>https://community.esri.com/t5/python-questions/tying-to-allow-the-user-to-set-their-workspace-in/m-p/1635549#M74517</link>
      <description>&lt;P&gt;I'm using arcgis pro 3.5.2 and python 3.11.11&lt;/P&gt;&lt;P&gt;The following is how i set up the inital code:&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;# locations of the working stratigraphy data&lt;BR /&gt;&lt;/SPAN&gt;working_strat_data_location = arcpy.GetParameterAsText(&lt;SPAN&gt;0&lt;/SPAN&gt;)&lt;BR /&gt;arcpy.env.workspace = os.path.join(working_strat_data_location, &lt;SPAN&gt;"geodatabase_name.gdb"&lt;/SPAN&gt;)&lt;BR /&gt;arcpy.env.overwriteOutput = &lt;SPAN&gt;True&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;However, when i add a folder paths like: "C:\Users" or "\\NETWORK_1\folder1\folder2\" into a string parameter in the custom script tool, i even tried setting the paramter as a folder. This was not working or it was not setting the workspace to this location.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The only way i got it to work was using this:&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = r"NETWORK_1\folder1\folder2\&lt;SPAN&gt;geodatabase_name.gdb&lt;/SPAN&gt;"&lt;/P&gt;&lt;P&gt;I know the "r" isn't needed as in the past I've been told to never use it, but I want to know what I'm missing in the first block of code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm replacing an old workflow from desktop 10.0 (no longer supported) by creating this custom tool that I'm trying to get to work in Pro. This first step is essential.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jul 2025 16:13:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/tying-to-allow-the-user-to-set-their-workspace-in/m-p/1635549#M74517</guid>
      <dc:creator>dcaESRIwvges</dc:creator>
      <dc:date>2025-07-23T16:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: Tying to allow the user to set their workspace in a custom scirpt tool</title>
      <link>https://community.esri.com/t5/python-questions/tying-to-allow-the-user-to-set-their-workspace-in/m-p/1635559#M74518</link>
      <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I’ve run into this exact issue when modernizing older workflows from ArcMap 10.x to ArcGIS Pro.&lt;/P&gt;&lt;P&gt;The core of the problem is that when you pass a folder path as a parameter and then try to build the full GDB path using os.path.join(), ArcPy doesn’t always behave the way you’d expect — especially if the input path has trailing slashes, or if the geodatabase doesn’t exist yet.&lt;/P&gt;&lt;P&gt;Here's what I usually do to bulletproof it:&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;LI-CODE lang="python"&gt;import os, arcpy

working_folder = arcpy.GetParameterAsText(0)
gdb_name = "geodatabase_name.gdb"
gdb_path = os.path.join(working_folder.strip(), gdb_name)

if arcpy.Exists(gdb_path):
    arcpy.env.workspace = gdb_path
    arcpy.AddMessage(f"Workspace set to: {gdb_path}")
else:
    arcpy.AddError(f"Could not find GDB at: {gdb_path}")&lt;/LI-CODE&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;Make sure your script tool parameter is set to type = &lt;STRONG&gt;Folder (not generic string).&lt;/STRONG&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Always validate the final gdb_path before using it.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;I know people say not to use the r"" prefix — but when hardcoding UNC paths, I still use it out of habit because it avoids weird issues with escape characters.&lt;/P&gt;&lt;P&gt;The reason your arcpy.env.workspace = r"NETWORK_1\folder1\folder2\geodatabase_name.gdb" worked is likely because you bypassed the join logic entirely — which also means you’re avoiding any string formatting mishaps from the input.&lt;/P&gt;&lt;P&gt;So, you’re not doing anything wrong — it’s just that ArcGIS Pro and its newer Python runtime (3.11 now) can be a little less forgiving than ArcMap used to be.&lt;/P&gt;&lt;P&gt;Please let me know if you have further questions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Venkat&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="python"&gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jul 2025 16:34:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/tying-to-allow-the-user-to-set-their-workspace-in/m-p/1635559#M74518</guid>
      <dc:creator>VenkataKondepati</dc:creator>
      <dc:date>2025-07-23T16:34:07Z</dc:date>
    </item>
    <item>
      <title>Re: Tying to allow the user to set their workspace in a custom scirpt tool</title>
      <link>https://community.esri.com/t5/python-questions/tying-to-allow-the-user-to-set-their-workspace-in/m-p/1635632#M74519</link>
      <description>&lt;P&gt;try using&amp;nbsp; pathlib&lt;/P&gt;&lt;LI-CODE lang="c"&gt;from pathlib import Path
working_strat_data_location = Path(arcpy.GetParameterAsText(0))
arcpy.env.workspace = str(working_strat_data_location / "geodatabase_name.gdb")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jul 2025 17:36:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/tying-to-allow-the-user-to-set-their-workspace-in/m-p/1635632#M74519</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2025-07-23T17:36:07Z</dc:date>
    </item>
    <item>
      <title>Re: Tying to allow the user to set their workspace in a custom scirpt tool</title>
      <link>https://community.esri.com/t5/python-questions/tying-to-allow-the-user-to-set-their-workspace-in/m-p/1636328#M74537</link>
      <description>&lt;P&gt;Thank you both! I will try both solutions and let you know!&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jul 2025 12:32:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/tying-to-allow-the-user-to-set-their-workspace-in/m-p/1636328#M74537</guid>
      <dc:creator>dcaESRIwvges</dc:creator>
      <dc:date>2025-07-25T12:32:38Z</dc:date>
    </item>
  </channel>
</rss>

