Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Laying out layers with set gaps and random scale

  • Laying out layers with set gaps and random scale

    Posted by Jamesc on June 12, 2007 at 2:33 pm

    Hi all,

    I’ve got this to work fine; sits on the position of each layer.

    total = 0;
    for (i = 1; i<=(index); i++) { total += thisComp.layer(i).width * (thisComp.layer(i).scale[0]/100) } total += 20; //gap in pixels [total, 300] The problem is it only works when the anchor point is 0 on the x axis. I want the objects to scale from the centre of the object - not the edge. I've figured that the maths is something like this: total += ((thisComp.layer(i).width * (thisComp.layer(i).scale[0]/100))/2) + ((thisComp.layer(i-1).width * (thisComp.layer(i-1).scale[0]/100))/2) But it doesn't seem to work... :o( Any help? James

    Jamesc replied 18 years, 11 months ago 1 Member · 2 Replies
  • 2 Replies
  • Jamesc

    June 12, 2007 at 2:38 pm

    It always happens – I post and then get it to work 2 minutes later… :o)

    total = 0;
    for (i = 1; i<=(index); i++) { if (i==1) { total = (thisComp.layer(i).width * (thisComp.layer(i).scale[0]/100))/2; } if (i > 1) {
    total += ((thisComp.layer(i).width * (thisComp.layer(i).scale[0]/100))/2) + ((thisComp.layer(i-1).width * (thisComp.layer(i-1).scale[0]/100))/2);
    total += 20;
    }
    }
    [total, 350]

  • Jamesc

    June 12, 2007 at 2:55 pm

    Go faster stripes version;

    total = 0;
    for (i = thisComp.layer(“iconstart”).index+1; i<=(index); i++) { if (i >thisComp.layer(“iconstart”).index+1) {
    total += ((thisComp.layer(i).width * (thisComp.layer(i).scale[0]/100))/2) + ((thisComp.layer(i-1).width * (thisComp.layer(i-1).scale[0]/100))/2);
    total += 10;
    }
    }
    [thisComp.layer(“iconstart”).transform.position[0]+total, thisComp.layer(“iconstart”).transform.position[1]]

    Requires a null object named “iconstart” and then all your layers underneath it.

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