With this function you can get the list of all the panels and see their ID:
async function getPanelsList() {
return await batchPlay([
{
"_obj": "get",
"_target": [
{ "_property": 'panelList' },
{ "_ref": "application",
"_enum": "ordinal",
"_value": "targetEnum" },
],
"_options": { "dialogOptions": "dontDisplay" }
}
], {
synchronousExecution: true,
modalBehavior: "execute"
})[0].panelList;
}
const panelsList = await getPanelsList();
console.log(panelsList);
And with this other function you can check if a panel is visible using its ID:
async function isPanelVisible(panelID) {
const res = await batchPlay([
{
"_obj": "get",
"_target": [
{ "_property": 'panelList' },
{ "_ref": "application",
"_enum": "ordinal",
"_value": "targetEnum" },
],
"_options": { "dialogOptions": "dontDisplay" }
}
], {
synchronousExecution: true,
modalBehavior: "execute"
})[0].panelList?.find(p => p.ID === panelID).visible;
return res;
}
Then what you can do is use the Alchemist to listen when you hide or show the panel from the Window menu and it will log something like this, you should get the ID which will toggle the panel:
Then, use the ID with this function to toggle the panel, by toggle means that if it is open the function will close it, if it is closed the function will open it:
async function runCommandID(id) {
await core.performMenuCommand({ commandID: id,
kcanDispatchWhileModal: true, _isCommand: false });
}
// This toggles the Layers panel
await runCommandID(1098);
So use the isPanelVisible("panelid.static.layers")
function to see if the panel is visible and toggle it or viceversa, depends on what you want to show or hide, the runCommandID()
remember it âtogglesâ the panel, not opens it estrictly, it opens if it i s closed or closes if it is opened.
Hope this is helpful!