Select to view content in your preferred language

Layout Picture Element Method SetSourcePath Doesn't Update Picture

2284
14
09-28-2022 09:19 AM
Jimmy_Simpson
Regular Contributor

The layout PictureElement SetSourcePath method only updates the path in element properties, but not the picture in the layout. If you click inside the source path in the element properties, the picture does chance. However I am trying to automate this process across multiple pictures in multiple layouts and this workaround is time consuming.

I have tried forcing the layout to refresh after the update

layoutView.Refresh());

 without success. I also contacted support and they submitted a BUG and someone posted the workaround below:

To refresh the layout and update the pictures, add these lines after changing the layout:

//Force layout refresh var lyt_cim = lyt.GetDefinition(); lyt.SetDefinition(lyt_cim);

I have tried this with the same result - appears visually to do the same things as "Refresh" or just clicking the refresh button at the bottom of the layout.

Anyone have an idea for a workaround? I will add I believe this problem started in 3.0.

0 Kudos
14 Replies
Jimmy_Simpson
Regular Contributor

@JeffBarrette - Didn't really mean for that to turn into a complaining session. I really appreciate your help on this.

My organization has anywhere from 6-20 layout per project and several images that change depending on different parameters. I can be very time consuming to change these manually. Any workaround/bug fix you can provide would be greatly appreciated!!!

0 Kudos
JeffBarrette
Esri Regular Contributor

You have every right to be frustrated!  I wonder if I couldn't reproduce the issue was because I didn't use a project that may have gone through multiple changes over time / releases.  I'm querying our developers to determine if OLD images reappearing has to do with the switch to binary reference (for pictures).  Your latest, detailed synopsis is really helpful!

Jeff

0 Kudos
Jimmy_Simpson
Regular Contributor

@JeffBarrette If it would be helpful, more than happy to share my code with you or share my screen to show you what I am seeing. Just let me know!

Right now I am attempting to see what happens if I activate/create a layout pane and activate every layout before the setsourcepath runs on each layout.

0 Kudos
JeffBarrette
Esri Regular Contributor

I may have the project to reproduce your issue. Lets set up call.  Contact me at jbarrette@esri.com

0 Kudos
Jimmy_Simpson
Regular Contributor

@KeithAddison1 @imrankhadri 

@JeffBarrette gave me enough information to find a workaround for this. Below is the code I have now that updates the image consistently. The bug should be fixed in an upcoming release, but until then, this seems to work!

CIMPictureGraphic cimPic = picElm.GetGraphic() as CIMPictureGraphic;
cimPic.ReferenceURI = null;
cimPic.PictureURL = null;
cimPic.SourceURL = null;
picElm.SetGraphic(cimPic);
picElm.SetSourcePath($@"{Module1.LayoutLogo}");