Skip to main content
Participating Frequently
November 11, 2024
Question

Show/hide keyframed properties from an extension

  • November 11, 2024
  • 1 reply
  • 368 views

I have an extension that executes function test() on a button click, to show/hide properties with keyframes:

 

function test() {

var res = false;

var msg = 'default';

var comp = _proj.activeItem;

if (!comp || !(comp instanceof CompItem)) {

msg = 'No active item or active item is not a comp';

return toJSON(res, msg);

}

var layer = comp.layer(1);

if (!layer) {

msg = 'No layer selected';

return toJSON(res, msg);

}

layer.selected = true;

var cmdStr = 'Reveal Properties with Keyframes';

var cmdId = executeCommand(cmdStr);

if (cmdId == 0) {

msg = 'Command \'' + cmdStr + '\' id not found';

return toJSON(res, msg);

}

msg = 'Executed \'' + cmdStr + '\' (' + cmdId + ')';

layer.selected = false;

return toJSON(res, msg);

}


function executeCommand(cmdStr) {

var cmdId = 0;

cmdId = app.findMenuCommandId(cmdStr);

if (cmdId == 0) return cmdId;

app.executeCommand(cmdId);

return cmdId;

}

 

When I call test() the first time, it works and opens keyframed props, but when I call it again, it opens all props of the layer. On the other hand, if after the first call I click away from the extension window and focus AE UI, it works and hides keyframed props.

Does anyone here have any experience re this behavior?

This topic has been closed for replies.

1 reply

Legend
November 11, 2024

try this:

function executeCommand(cmdStr) {
    var cmdId = 0;
    cmdId = app.findMenuCommandId(cmdStr);
    if (cmdId == 0) return cmdId;
    // RevealAllModifiedProperties
    app.executeCommand(2771);
    app.executeCommand(2771);
    app.executeCommand(cmdId);
    return cmdId;
}
Participating Frequently
November 11, 2024

This way it opens keyframed props if they are hidden but doesn't hide them if they are shown.

Participating Frequently
November 11, 2024

... which makes sense because running 2771 twice hides everything and then props are shown again, so this code doesn't work as a switch