Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects question: how to parent different positions to a null

  • question: how to parent different positions to a null

    Posted by Raphael Schaaf on January 29, 2011 at 5:52 pm

    can someone please help me?
    4 days ago i started scripting in after effects, mainly because i wanted to automaticaly create a new null. the x-position of my null is parented to the x of one selected layer, the z-position is parented to the x of another selected layer.
    y-position is the average of the y-positions of the two selected layers

    it depends on the names of my first and second layer which selected layer is responsible for the x/z position of the null. this works fine, but the new null always stays in the middle of the comp…

    this is my script:

    thisComp = app.project.activeItem

    var x = thisComp.selectedLayers[0].position[0];
    var z = thisComp.selectedLayers[1].position[0];
    var Y = (thisComp.selectedLayers[0].position[1] + thisComp.selectedLayers[1].position[1]) / 2;

    front = new String (“front”);
    back = new String (“back”);
    right = new String (“right”);
    left = new String (“left”);

    video1 = String (thisComp.layers[1].name)
    video2 = String (thisComp.layers[2].name)

    if (video1 == front) {

    var X = x;

    }else{
    if (video1 == back) {

    var X = x * (-1);

    }else{
    if (video1 == right) {

    var Z = x;

    }else{
    if (video1 == left) {

    var Z = x * (-1)

    }else{

    alert (“choose compatible videoname”)
    }
    }
    }
    }

    if (video2 == front) {

    var X = z;

    }else{
    if (video2 == back) {

    var X = z * (-1);

    }else{
    if (video2 == right) {

    var Z = z;

    }else{
    if (video2 == left) {

    var Z = z * (-1)

    }else{

    alert (“choose compatible videoname”)
    }
    }
    }
    }

    number += 1;
    var trackName = “Trackpoint ” + number;

    newTrackpoint = thisComp.layers.addNull();
    newTrackpoint.name = trackName;
    newTrackpoint.threeDLayer = true;

    newTrackpoint.position= [X,Y,Z];

    i hope someone can help me…

    by the way, does anybody know how to change the index of a layer? i want my new null to be on bottom, not on top…

    Raphael Schaaf replied 15 years, 3 months ago 2 Members · 2 Replies
  • 2 Replies
  • Michael Szalapski

    January 31, 2011 at 2:52 pm

    If you don’t get a response here in a couple of days, you might try posting this in the Expressions forum. A lot of the script gurus spend time in there.

    – The Great Szalam
    (The ‘Great’ stands for ‘Not So Great, in fact, Extremely Humble’)

    No trees were harmed in the creation of this message, but several thousand electrons were mildly inconvenienced.

  • Raphael Schaaf

    January 31, 2011 at 5:38 pm

    oops, i just realized that i posted it in the wrong forum, thanks man 🙂

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