0

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.

  • 2
    How do you know nothing has updated? Are you opening the Project (ArcGIS Pro) after updating the script? If you currently have Pro open you won't see any updates happen, you need to close/restart. Also have you done a print(newpath) to ensure the paths are correct? – KHibma Aug 14 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.