<?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: arcpy.mp.ArcGISProject('CURRENT') works but arcpy.mp.ArcGISProject(project_path) does not. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-mp-arcgisproject-current-works-but-arcpy-mp/m-p/1298265#M67944</link>
    <description>&lt;P&gt;Are you getting an error message?&lt;/P&gt;</description>
    <pubDate>Mon, 12 Jun 2023 18:56:01 GMT</pubDate>
    <dc:creator>BlakeTerhune</dc:creator>
    <dc:date>2023-06-12T18:56:01Z</dc:date>
    <item>
      <title>arcpy.mp.ArcGISProject('CURRENT') works but arcpy.mp.ArcGISProject(project_path) does not.</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mp-arcgisproject-current-works-but-arcpy-mp/m-p/1298252#M67943</link>
      <description>&lt;P&gt;I have created a script to add images into a map. Both&amp;nbsp;arcpy.mp.ArcGISProject('CURRENT') and&amp;nbsp; arcpy.mp.ArcGISProject(project_path) allow me to access the project and print the current layers but using the path does not allow me to add data in. Here is my script:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;tif_folder = r"C:\folder"

# Set aprx as your current project
aprx = arcpy.mp.ArcGISProject('CURRENT') 
#aprx = arcpy.mp.ArcGISProject('project_path')

# Get the map from the project using the index for a given map
map = aprx.listMaps()[0]  

#assign existing layers
existinglayernames = [l.name for l in map.listLayers()]
print(f'existinglayernames: {existinglayernames}')

#add files that are not in the project yet
for file in os.listdir(tif_folder):
    fName, fExt = os.path.splitext(file)
    if fExt != '.tif' or fName + fExt in existinglayernames:
        #  Skip this file and continue to the next one
        continue
    filepath = os.path.join(tif_folder, file)
    map.addDataFromPath(filepath)
    print(f'File name: {fName}')
    
&lt;/LI-CODE&gt;&lt;P&gt;Both options print the existing layers and the layers that are being added. but,&amp;nbsp;&amp;nbsp;the path does not actually add the file.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 18:45:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mp-arcgisproject-current-works-but-arcpy-mp/m-p/1298252#M67943</guid>
      <dc:creator>ZacharyKasson</dc:creator>
      <dc:date>2023-06-12T18:45:06Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mp.ArcGISProject('CURRENT') works but arcpy.mp.ArcGISProject(project_path) does not.</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mp-arcgisproject-current-works-but-arcpy-mp/m-p/1298265#M67944</link>
      <description>&lt;P&gt;Are you getting an error message?&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 18:56:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mp-arcgisproject-current-works-but-arcpy-mp/m-p/1298265#M67944</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2023-06-12T18:56:01Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mp.ArcGISProject('CURRENT') works but arcpy.mp.ArcGISProject(project_path) does not.</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mp-arcgisproject-current-works-but-arcpy-mp/m-p/1298292#M67945</link>
      <description>&lt;P&gt;This is expected behavior, &lt;EM&gt;current&lt;/EM&gt; is different to a file path.&lt;/P&gt;&lt;P&gt;When you use &lt;EM&gt;current&lt;/EM&gt;, ArcGIS knows that you want to work with the currently opened project. When you use a file path, ArcGIS loads that project into RAM, without actually opening it in the application. IT does all its operations on that copy in RAM, regardless of whether you currently have opened that project or not.&lt;/P&gt;&lt;P&gt;Your code works perfectly fine. Just add that piece at the end of it and then take a look at the copy:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;aprx.saveACopy(r"project_folder\ProjectCopy")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can also use the save() method, but for that to work, you need to call the script from outside the current project.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 19:33:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mp-arcgisproject-current-works-but-arcpy-mp/m-p/1298292#M67945</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-06-12T19:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mp.ArcGISProject('CURRENT') works but arcpy.mp.ArcGISProject(project_path) does not.</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mp-arcgisproject-current-works-but-arcpy-mp/m-p/1300367#M67987</link>
      <description>&lt;P&gt;No error, just no action.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2023 19:44:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mp-arcgisproject-current-works-but-arcpy-mp/m-p/1300367#M67987</guid>
      <dc:creator>ZacharyKasson</dc:creator>
      <dc:date>2023-06-16T19:44:20Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mp.ArcGISProject('CURRENT') works but arcpy.mp.ArcGISProject(project_path) does not.</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mp-arcgisproject-current-works-but-arcpy-mp/m-p/1300378#M67989</link>
      <description>&lt;P&gt;I appreciate the response. Won't that just save another copy? I am pulling imagery files in so many copies will take up a lot of data.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I could save a copy and delete the old one, but will it save the entire project or just that map (I have multiple maps).&lt;/P&gt;&lt;P&gt;Also how well would creating a copy really do as a tool because that is the end goal.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2023 19:53:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mp-arcgisproject-current-works-but-arcpy-mp/m-p/1300378#M67989</guid>
      <dc:creator>ZacharyKasson</dc:creator>
      <dc:date>2023-06-16T19:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.mp.ArcGISProject('CURRENT') works but arcpy.mp.ArcGISProject(project_path) does not.</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-mp-arcgisproject-current-works-but-arcpy-mp/m-p/1300500#M67991</link>
      <description>&lt;P&gt;Yes, or will create a copy, of the whole project. It shouldn't take up too much space, because it doesn't copy the tater data.&lt;/P&gt;&lt;P&gt;As I said, you can also use the aprx.save() method, but only if you don't have that project open.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Jun 2023 11:02:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-mp-arcgisproject-current-works-but-arcpy-mp/m-p/1300500#M67991</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-06-17T11:02:48Z</dc:date>
    </item>
  </channel>
</rss>

