Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions AE Script to emulate Drag Audio on New Composition icon To create composition

  • AE Script to emulate Drag Audio on New Composition icon To create composition

    Posted by John Gate on September 9, 2020 at 5:50 pm

    Hi there,

    If we drag an audio clip from project panel and drop on composition icon, then it creates a composition with audio in it.

    How can i get the same behavour using a script?

    Please advise

    Walter Soyka replied 5 years, 8 months ago 2 Members · 1 Reply
  • 1 Reply
  • Walter Soyka

    September 10, 2020 at 4:25 am

    Yes, and it’s pretty straightforward if you’re familiar with scripting. Here’s some commented code:

    // create an undo group so we can Control+Z this all away app.beginUndoGroup("Create new comp with first selected footage");

    // assume the first selected item in the project panel is our audio footage. // in real life, you'd already have an object for this. // note that I'm not doing any error checking here, so things will go wrong if you don't have a valid selection var audioTrack = app.project.selection[0];

    // create a new comp named after our audio track, 1920px wide, 1080px high, square pixels, at the length of the audio track, and at 29.97fps var newComp = app.project.items.addComp("Comp " + audioTrack.name, 1920, 1080, 1, audioTrack.duration, 30000/1001);

    // add the audio footage as a layer in the new comp var newAudioLayer = newComp.layers.add(audioTrack);

    // close the undo group, that's all, folks! app.endUndoGroup();

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