<?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>idea Current Project - Environment Variable in ArcGIS Pro Ideas</title>
    <link>https://community.esri.com/t5/arcgis-pro-ideas/current-project-environment-variable/idi-p/1242030</link>
    <description>&lt;P&gt;Noticed that there is no "Current Project" environment variable for geoprocessing. I like to create script tools to streamline workflows and a useful one for me would be to use the current project. I've made a fair number of script tools that need to reference a project and more often than not, the user will want to use it on their current project. If there was a "Current Project" environment variable then the default for a parameter could be set to that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some examples for script tools I've made that would use this.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Export all layouts in a project as a certain format (.pagx, .pdf, .jpg, .aix)&lt;/LI&gt;&lt;LI&gt;Change all data sources in a project to new one.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Image including some of the current environment variables&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BrettFrahm_0-1671205065571.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/58774i8A6CFD7F9BA3DE10/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BrettFrahm_0-1671205065571.png" alt="BrettFrahm_0-1671205065571.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 16 Dec 2022 15:48:18 GMT</pubDate>
    <dc:creator>BrettFrahm</dc:creator>
    <dc:date>2022-12-16T15:48:18Z</dc:date>
    <item>
      <title>Current Project - Environment Variable</title>
      <link>https://community.esri.com/t5/arcgis-pro-ideas/current-project-environment-variable/idi-p/1242030</link>
      <description>&lt;P&gt;Noticed that there is no "Current Project" environment variable for geoprocessing. I like to create script tools to streamline workflows and a useful one for me would be to use the current project. I've made a fair number of script tools that need to reference a project and more often than not, the user will want to use it on their current project. If there was a "Current Project" environment variable then the default for a parameter could be set to that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some examples for script tools I've made that would use this.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Export all layouts in a project as a certain format (.pagx, .pdf, .jpg, .aix)&lt;/LI&gt;&lt;LI&gt;Change all data sources in a project to new one.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Image including some of the current environment variables&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BrettFrahm_0-1671205065571.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/58774i8A6CFD7F9BA3DE10/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BrettFrahm_0-1671205065571.png" alt="BrettFrahm_0-1671205065571.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Dec 2022 15:48:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-ideas/current-project-environment-variable/idi-p/1242030</guid>
      <dc:creator>BrettFrahm</dc:creator>
      <dc:date>2022-12-16T15:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: Current Project - Environment Variable</title>
      <link>https://community.esri.com/t5/arcgis-pro-ideas/current-project-environment-variable/idc-p/1242240#M22589</link>
      <description>&lt;P&gt;Does &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/arcgisproject.htm" target="_self"&gt;this&lt;/A&gt; help?&lt;/P&gt;</description>
      <pubDate>Sun, 18 Dec 2022 12:14:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-ideas/current-project-environment-variable/idc-p/1242240#M22589</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2022-12-18T12:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: Current Project - Environment Variable</title>
      <link>https://community.esri.com/t5/arcgis-pro-ideas/current-project-environment-variable/idc-p/1243797#M22620</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/3515"&gt;@DuncanHornby&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for reaching out. I am indeed using arcpy.mp with ArcGISProject() in my script tools, but the parameter Data Type I need to use in "File" and I can't default "CURRENT" as a choice in python because I need to allow the user to choose other projects. Only option is to set it as a text parameter but then they cant browse through files.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BrettFrahm_0-1672155238980.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/59295i60FC5B2C0E4C3BD3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BrettFrahm_0-1672155238980.png" alt="BrettFrahm_0-1672155238980.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BrettFrahm_1-1672155327825.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/59296iB6AD1E9DE6CC789B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BrettFrahm_1-1672155327825.png" alt="BrettFrahm_1-1672155327825.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2022 15:36:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-ideas/current-project-environment-variable/idc-p/1243797#M22620</guid>
      <dc:creator>BrettFrahm</dc:creator>
      <dc:date>2022-12-27T15:36:35Z</dc:date>
    </item>
    <item>
      <title>Re: Current Project - Environment Variable</title>
      <link>https://community.esri.com/t5/arcgis-pro-ideas/current-project-environment-variable/idc-p/1244775#M22642</link>
      <description>&lt;P&gt;A solution to your dilemma is to have a drop-down with the options "Current" and "other". If they select current then you use the code I had linked to. If other then that enables another parameter which offers up your File parameter. You do all that in the validation code section of your script tool. Enabling/disabling a parameter has the affect of show/hide the parameter.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jan 2023 19:59:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-ideas/current-project-environment-variable/idc-p/1244775#M22642</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2023-01-02T19:59:10Z</dc:date>
    </item>
    <item>
      <title>Re: Current Project - Environment Variable</title>
      <link>https://community.esri.com/t5/arcgis-pro-ideas/current-project-environment-variable/idc-p/1245687#M22719</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/3515"&gt;@DuncanHornby&lt;/a&gt;&amp;nbsp;Thank you for the recommendation. I have attempted to&amp;nbsp; to edit the validation code section to achieve contingent parameters&amp;nbsp; in the past but could not figure it out with the limited documentation I found at the time.&lt;/P&gt;&lt;P&gt;Do you have any validation code examples that show how to hide a parameter and display it based on an option chosen in a previous parameter? I have a lot of use-cases for this. Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2023 17:21:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-ideas/current-project-environment-variable/idc-p/1245687#M22719</guid>
      <dc:creator>BrettFrahm</dc:creator>
      <dc:date>2023-01-05T17:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: Current Project - Environment Variable</title>
      <link>https://community.esri.com/t5/arcgis-pro-ideas/current-project-environment-variable/idc-p/1245847#M22723</link>
      <description>&lt;P&gt;Here is a snippet to get you going:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;class ToolValidator:
    # Class to add custom behavior and properties to the tool and tool parameters.
            
    def __init__(self):
        # set self.params for use in other function
        self.params = arcpy.GetParameterInfo()

    def initializeParameters(self):
        # Customize parameter properties. 
        # This gets called when the tool is opened.
        self.params[2].value = "Regular"
        return

    def updateParameters(self):
        # Modify parameter values and properties.
        # This gets called each time a parameter is modified, before 
        # standard validation.
        if self.params[2].value == "Regular":
            self.params[3].enabled = False
            self.params[4].enabled = True
            self.params[5].enabled = False
        elif self.params[2].value == "Randomly":
            self.params[3].enabled = True
            self.params[4].enabled = False
            self.params[5].enabled = True
            
        return

    def updateMessages(self):
        # Customize messages for the parameters.
        # This gets called after standard validation.
        &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;params[2] is a text parameter with string filter listing only &lt;EM&gt;regular&lt;/EM&gt; or &lt;EM&gt;randomly&lt;/EM&gt;, when you change it on the interface it show/hides parameters 3 or 4.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2023 21:18:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-ideas/current-project-environment-variable/idc-p/1245847#M22723</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2023-01-05T21:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: Current Project - Environment Variable</title>
      <link>https://community.esri.com/t5/arcgis-pro-ideas/current-project-environment-variable/idc-p/1246158#M22727</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/3515"&gt;@DuncanHornby&lt;/a&gt;&amp;nbsp;, worked perfectly! Thank you for that code snippet. Will be using in several tools.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 19:59:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-ideas/current-project-environment-variable/idc-p/1246158#M22727</guid>
      <dc:creator>BrettFrahm</dc:creator>
      <dc:date>2023-01-06T19:59:54Z</dc:date>
    </item>
    <item>
      <title>Re: Current Project - Environment Variable - Status changed to: Already Offered</title>
      <link>https://community.esri.com/t5/arcgis-pro-ideas/current-project-environment-variable/idc-p/1254598#M23142</link>
      <description />
      <pubDate>Thu, 02 Feb 2023 21:09:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-ideas/current-project-environment-variable/idc-p/1254598#M23142</guid>
      <dc:creator>JonathanNeal</dc:creator>
      <dc:date>2023-02-02T21:09:54Z</dc:date>
    </item>
  </channel>
</rss>

