Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Custom script -> Adding null then setting parent

  • Custom script -> Adding null then setting parent

    Posted by Ralph Moreau on September 6, 2021 at 9:18 pm

    Hi everyone,

    I’m really a hobbyist programmer so bare with me if you can. I’m making a script that basically

    adds a null then selects the active layer as the parent. I’m nearly there but it’s just setting the parent . Here is the code:

    var comp = app.project.activeItem, props, n, p, idx;

    if (comp instanceof CompItem){

    props = comp.selectedProperties;

    var layNum = comp.selectedLayers[0].index; // number of designated chosesn layer

    var selLay = comp.layer(layNum); // actual layer object with the proper index.

    var inLay = comp.layer(layNum).inPoint;

    var outLay = comp.layer(layNum).outPoint;

    var inOutlay = Math.abs(inLay - outLay);

    var newNull = comp.layers.addNull([inOutlay]).moveBefore(selLay);

    comp.layer(layNum).setParentWithJump(layNum -1);

    };

    Ralph Moreau replied 4 years, 8 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    September 6, 2021 at 10:30 pm

    I’m guessing this is close to what you’re looking for:

    var comp = app.project.activeItem;

    if (comp instanceof CompItem){

    var selLay = comp.selectedLayers[0];

    var inOutlay = selLay.outPoint - selLay.inPoint;

    var newNull = comp.layers.addNull(inOutlay);

    newNull.moveBefore(selLay);

    newNull.startTime = selLay.inPoint;

    newNull.setParentWithJump(selLay);

    };

  • Ralph Moreau

    September 7, 2021 at 8:22 pm

    Thank you Dan!!

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