I am beginner in ArcGIS Pro and I am trying to expand into using python with ArcGIS Pro. I have a working script that will update a specified text element in all layouts in ArcGIS Pro, in my case it's a project name.
project_name = 'Test Project' aprx = arcpy.mp.ArcGISProject("CURRENT") for lyt in aprx.listLayouts(): for elm in lyt.listElements("TEXT_ELEMENT", "Project Name"): elm.text = project_name aprx.save()
My problem comes when I try to run the script outside of a running ArcGIS Pro instance and use the APRX path rather than "Current" in arcpy.mp.ArcGISProject()
import arcpy project_number = "12345" project_name = "Test Project" project_number_group = project_number[:2] newpath = "N:\\Projects\\" + project_number_group + "000\\" + project_number + "_" + project_name.replace(" ","_") aprx = arcpy.mp.ArcGISProject(newpath + "\\APRX\\Project_Figures.aprx") for lyt in aprx.listLayouts(): for elm in lyt.listElements("TEXT_ELEMENT", "Project Name"): elm.text = project_name aprx.save()
The odd thing is when I go line by line things appear to be normal, the aprx variable calls the correct project, the path appears correctly, it's just nothing actually updates when I run it. No errors spit out either, so I am at a loss currently.