How to refresh document/plugin at the time of plugin invocation?

Here’s workaround:
I want the current artboards on the canvas. Once the plugin is invoked, the list is made for current artboards. Now if I add one more Artboard and invoke the plugin, the list is not updated. Obviously as the plugin lifecycle mentions that Plugin remains resident till document is closed or plugin is reloaded.
ref: https://adobexdplatform.com/plugin-docs/reference/core/lifecycle.html#plugin-loading

Is there a way to refresh the document at plugin Initialization or reload the plugin every time it is invoked?

You can most definitely see the current list of artboards on every plugin invocation, so I’d look deeper into your code.

Is this a modal or a panel plugin?

1 Like

It’s a Modal Plugin.

For a modal dialog, you’ll want to populate the list of artboards when your dialog is made visible, not at load time of the plugin.

For example:

let dialog;
function createDialog() {
    if (dialog) return dialog;
    dialog = document.createElement("dialog");
    dialog.innerHtml = `<div id="divSelectedElementCount"></div>`;
    /* ... */
    return dialog;
}

function showMyDialog() {
    const dialog = createDialog();
    const numSelectedElements = dialog.querySelector("#divSelectedElementCount");
    numSelectedElements.innerText = `${require("scenegraph").selection.items.length} items selected`;
    return dialog.showModal();
}

module.exports = {
    commands: {
        doTheThing: showMyDialog
    }
}
2 Likes

Thank you very much for your help!
Solved my problem

1 Like