-
question: how to parent different positions to a null
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 layersit 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…