Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions AE scripting: ‘onOpenProject’ event exists?

  • AE scripting: ‘onOpenProject’ event exists?

    Posted by David Gidali on August 24, 2020 at 4:07 am

    Hi there,

    For a script I’m writing, I would like to have some menus update automatically whenever the active project changes (by opening an existing/new project, or by saving the current project into a new file).

    So far I haven’t been able to track down this callback/event, but I would expect there to be something that does exactly that…

    Any clue?

    Scott Mcgee replied 5 years, 8 months ago 2 Members · 1 Reply
  • 1 Reply
  • Scott Mcgee

    August 24, 2020 at 3:55 pm

    Personally I’d just include an update button and function that to update/refresh the menu. There’s plenty of bits about on this sort of thing if you want it to update. (attached some code below)

    Depending on what you want this menu to do. I.e if you have a few scripts you want to combine, have you thought about tabbed panels to switch between them.

    If it’s data you want to pull from the project and have it update in the script panel. Then back to the first solution of adding and update/refresh button.

    If you are opening whilst AE is already open and opening another project. The script doesn’t know this as it doesn’t reverse communicate. You’d have to put in app.project.close() and app.open() into your script and trigger this, you’d need to include save if you wanted it to save. But then you’d still be using the above function of updating and/or refreshing the panel still.


    {
    function myScript(thisObj) {
    function myScript_buildUI(thisObj) {
    var myPanel = (thisObj instanceof Panel) ? thisObj : new Window ("palette", "Manheim", undefined, {resizable:true} );

    var mainGroup = myPanel.add("group");
    var btn = mainGroup.add("button",undefined,"Update");

    btn.onClick = function () {
    cleanUpGroup(grpContainer);
    var btn1_1 = grpContainer.add("button", undefined, "1_1");
    var btn1_2 = grpContainer.add("button", undefined, "1_2");
    var btn1_3 = grpContainer.add("button", undefined, "1_3");
    var btn1_4 = grpContainer.add("button", undefined, "1_4");
    updatePanel(myPanel);
    };

    var grpContainer = myPanel.add("group");

    // Setup panel sizing and make panel resizable
    myPanel.layout.layout(true);
    myPanel.layout.resize();
    myPanel.onResizing = myPanel.onResize = function () {this.layout.resize();}

    return myPanel;
    }

    function cleanUpGroup(container) {
    while (container.children[0]) {
    container.remove(container.children[0]);
    }
    }

    function updatePanel(win) {
    win.layout.layout(true);
    }

    // Build script panel
    var myScriptPal = myScript_buildUI(thisObj);

    if ((myScriptPal != null) && (myScriptPal instanceof Window)) {
    myScriptPal.center();
    myScriptPal.show();
    }
    }

    // Execute script
    myScript(this);
    }

    This updates the panel and might be of help to you possibly.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy