[ExtendScript] Changed inset graphic InsetFile, but can't get displayed graphic to refresh
I've written a script that goes through a document and changes the InsetFile path of a graphic, but I can't get the document to update the displayed graphic without either:
- closing/re-opening the document, or
- going to the graphic's "Object Properties" and selecting "Apply" (the "Referenced File" text box already has the correct path).
I tried using doc.Refresh(), with and without toggling app.Displaying, but the displayed graphic still didn't change. Is there a different method I should call? Here is a small snippit of code that reproduces the issue:
var doc = app.ActiveDoc;
app.Displaying = false;
var currentGraphic = doc.FirstGraphicInDoc;
while (currentGraphic.ObjectValid()) {
if (currentGraphic.reflect.name == "Inset" && currentGraphic.InsetFile != "") {
// currentGraphic.InsetFile = "C:\\Temp\\pending.png";
currentGraphic.InsetFile = "C:\\Temp\\approved.png";
break;
}
currentGraphic = currentGraphic.NextGraphicInDoc;
}
app.Displaying = true;
doc.Redisplay(); // Does not refresh the displayed graphic
// - "Object Properties" -> "Referenced File" displays the updated path. Clicking "Apply", without changing anything else, will update the displayed graphic
// - Saving, closing, and re-open document will display the correct graphic
