• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Community Beginner ,
Feb 03, 2021 Feb 03, 2021

Copy link to clipboard

Copied

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

 

TOPICS
Scripting

Views

244

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , Feb 03, 2021 Feb 03, 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;

 

Votes

Translate

Translate
Community Beginner ,
Feb 03, 2021 Feb 03, 2021

Copy link to clipboard

Copied

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;

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 03, 2021 Feb 03, 2021

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines