Skip to main content
February 3, 2021
Answered

[ExtendScript] Changed inset graphic InsetFile, but can't get displayed graphic to refresh

  • February 3, 2021
  • 1 reply
  • 505 views

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

 

This topic has been closed for replies.
Correct answer

Gah! Once again, I find the answer in the "Related Conversations" list as soon as I post the question. I really need to work on my Google-fu.

 

FM19 don't refresh the preview after copy a graphic by script 

Summary - It appears to be a bug with doc.Refresh(): Bug Report FRMAKER-7962 

Workaround from Russ Ward - Change the doc zoom level 

doc.Zoom = doc.Zoom + 1000;
doc.Zoom = doc.Zoom - 1000;

 

1 reply

Correct answer
February 3, 2021

Gah! Once again, I find the answer in the "Related Conversations" list as soon as I post the question. I really need to work on my Google-fu.

 

FM19 don't refresh the preview after copy a graphic by script 

Summary - It appears to be a bug with doc.Refresh(): Bug Report FRMAKER-7962 

Workaround from Russ Ward - Change the doc zoom level 

doc.Zoom = doc.Zoom + 1000;
doc.Zoom = doc.Zoom - 1000;

 

LinSims
Community Expert
Community Expert
February 3, 2021

Huh. I wonder if that works when you have a graphic imported by reference that you've updated on disk? Half the time it doesn't appear to be updated in the FM document, even though double-clicking on it will show the new version. I bet there's a cache somewhere that FM is referencing first.

February 4, 2021

I would think so, that was also something I saw when updating the InsetFile property - the displayed graphic wouldn't change, but double-clicking the graphic would open the new graphic.