ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

question: how to parent different positions to a null

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Raphael Schaafquestion: how to parent different positions to a null
by on Jan 29, 2011 at 5:52:48 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;

if (video1 == back) {

var X = x * (-1);

if (video1 == right) {

var Z = x;

if (video1 == left) {

var Z = x * (-1)


alert ("choose compatible videoname")

if (video2 == front) {

var X = z;

if (video2 == back) {

var X = z * (-1);

if (video2 == right) {

var Z = z;

if (video2 == left) {

var Z = z * (-1)


alert ("choose compatible videoname")

number += 1;
var trackName = "Trackpoint " + number;

newTrackpoint = thisComp.layers.addNull(); = 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...

Return to posts index

Michael SzalapskiRe: question: how to parent different positions to a null
by on Jan 31, 2011 at 2:52:13 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.

Return to posts index

Raphael SchaafRe: question: how to parent different positions to a null
by on Jan 31, 2011 at 5:38:03 pm

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

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 All Rights Reserved