Hey all,
I am totally new to Arcpy/Python and trying to use it in ArcPro.
I have tried the sample code provided by Esri, but cant seem to get my image to update to a new image or to move its XY location. I have an advanced license and am working in a layout. I have tried running the code in the python window and in notebooks. Clearly i am missing something.
aprx = arcpy.mp.ArcGISProject(r"C:\2022_Incidents_Practice\2022_Burbank\projects\2022_ProProjectTemplate.aprx")
lyt = aprx.listLayouts("myLayout")[0]
pic = lyt.listElements("PICTURE_ELEMENT", "TeamLogo")[0]
print(pic)
print(pic.sourceImage)
pic.sourceImage = r"C:\Users\EBall\OneDrive - City of Burbank\Desktop\FireLogo2.jpg"
print(pic.sourceImage)
print(pic.elementPositionX)
print(pic.elementPositionY)
pic.elementPositionX = 4.75
pic.elementPositionY = 10.5
I get the response of:
<arcpy._mp.PictureElement object at 0x000001D84FCF2C08> C:\Users\EBall\OneDrive - City of Burbank\Desktop\FireLogo.jpg
C:\Users\EBall\OneDrive - City of Burbank\Desktop\FireLogo2.jpg 8.57 8.38
so it seems to be seeing the element just fine, but the element doesn't move in layout or update its image.
I've also tried changing to GRAPHIC_ELEMENT
Solved! Go to Solution.
You need to save the project.
aprx.save()
If you're running this in the project you want to change, use "current" instead of the project path, that way you will see the updates in the project.
aprx = arcpy.mp.ArcGISProject("current")
You need to save the project.
aprx.save()
If you're running this in the project you want to change, use "current" instead of the project path, that way you will see the updates in the project.
aprx = arcpy.mp.ArcGISProject("current")
AWESOME, THX!
I had tried something similar to that but must have been off