Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions writing a simple script to set null object anchor point in the center?

  • writing a simple script to set null object anchor point in the center?

    Posted by Allison Sabelli on July 18, 2010 at 10:12 pm

    Hi everyone, I need some little help here, I’m very new to AE and scripting is unknown territory, however I’m learning by looking at other scripts and reading a lot. However I’m a little stuck here with the anchor point.

    I’m trying to write a simple script that adds a null object to a scene and set its size and its anchor point right in the center, so far I got everything I need but the anchor point :\

    I might be doing this all wrong, I don’t know ahhaha but how do i set the anchor point to be in the center?.

    Any help is very much appreciated, thanks

    var nw = 50;
    var nh = 50;
    var myNull = myComp.layers.addNull();
    myNull.source.name = "My NUll";
    myNull.source.width = nw; // getting this right :)
    myNull.source.height = nh;
    myNull.source.anchorPoint = ???; //I know should be an array for [x,y,z] but I get errors if i try.
    myNull.threeDLayer = true;

    Allison Sabelli replied 15 years, 10 months ago 2 Members · 3 Replies
  • 3 Replies
  • Filip Vandueren

    July 19, 2010 at 11:05 am

    Try this:

    myNull.source.anchorPoint.setValue([x,y,z]);

  • Filip Vandueren

    July 19, 2010 at 11:07 am

    Oops, I meant

    myNull.anchorPoint.setValue([mw/2,mh/2,0]);

  • Allison Sabelli

    July 19, 2010 at 4:02 pm

    Thank you, I was close though 🙂 but I was still adding the = sing after .setValue and that wouldn’t work, long way to learn.

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