Hi everyone,
I've written a stand-alone arcpy script to modifiy a layout in ArcGIS Pro.
It works great except for the PICTURE_ELEMENT and I don't find what I am doing wrong.
My purpose is to change the logo in my layout. In my script, I change the sourceImage and then I save a copy of my aprx.
When I open the aprx file, the logo has not change but if I check In the PICTURE_ELEMENT properties the image source has been correctly modified and if I press enter the the logo changes.
What am I missing?
Thank you
Hey @magdatopa_ratp
Could it be that the project isn't being fully saved or maybe it needs reloaded, arcpy has a feature to force a save on the project which would end up refreshing the logo.
Also, would it be possible to link a bit of the code that you're having issue with?
Cody
Thank you for trying to help me. As requested, here are some lines of my script :
#UPDATING LOGO
logo_file= INPUT_PATH + "newlogo.png"
logo="LOGO_COM"
lyt_logo=lyt.listElements('PICTURE_ELEMENT',logo)[0]
lyt_logo.sourceImage = logo_file
#saving a copy of my project
aprx.saveACopy(OUTPUT_PATH)
I also make changes in various TEXT_ELEMENTs of my layout and that works great. The only issue I have is the logo that doesn't refresh...
Hey @magdatopa_ratp
Maybe try and make a change to the logo and revert it to simulate the interaction?
#UPDATING LOGO
logo_file= INPUT_PATH + "newlogo.png"
logo="LOGO_COM"
lyt_logo=lyt.listElements('PICTURE_ELEMENT',logo)[0]
lyt_logo.sourceImage = logo_file
original_x = lyt_logo.elementPositionX
lyt_logo.elementPositionX = original_x + 0.001 # Small nudge
lyt_logo.elementPositionX = original_x # Revert back
#saving a copy of my project
aprx.saveACopy(OUTPUT_PATH)
Cody
I'm going to try it out. I'll let you know...
Thanks
@CodyPatterson unfortunately, it didn't change anything.
The image source is updated but the logo does not refresh.
Thanks for trying, the idea was great.
Found this topic :
Layout Picture Element Method SetSourcePath Doesn'... - Page 2 - Esri Community
Same problem, supposed to be fixed in a 3.0 patch.
I am currently using ArcGIS Pro 3.0. Maybe my problem would be fixed if I upgrade my version?