Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Is there a scripting equivalent to reveal a layers position property? Like the shortcut “P”? – AE Scripting

  • Is there a scripting equivalent to reveal a layers position property? Like the shortcut “P”? – AE Scripting

    Posted by Jason Schwarz on January 21, 2015 at 2:49 am

    I’ve hit a wall on this one.

    I’m making some custom scripts. This one is a simple camera rig. It works fine but I wanted to add some functionality to it to save myself a few clicks.
    Once the layers have been created, I’d like them to reveal certain properties in the UI.

    Question 1:
    Is there a scripting equivalent to the keyboard shortcut “P”?… Or similar shortcuts to reveal a layers Transform Properties?

    Question 2:
    Can you programmatically create a One-Node Camera instead of the default Two-Node Camera?
    I went through the AE scripting guide and found no way of setting the type of Camera.

    Any help is much appreciated.
    Thanks in advance.
    -Jason

    var myComp = app.project.activeItem;
    if (myComp != null && (myComp instanceof CompItem)){

    var w = myComp.width /2;
    var h = myComp.height /2;
    var newCamera = myComp.layers.addCamera("Camera", [w,h]); //make a new camera
    newCamera.position.setValue([w,h,-1900]);
    var myLayer = myComp.selectedLayers;
    if (myLayer) {
    var PosNull = myComp.layers.addNull();
    PosNull.source.name = "Cam_Pos";
    PosNull.threeDLayer = true;
    PosNull.position.setValue([w,h]);
    PosNull.enabled = true;

    var RotNull = myComp.layers.addNull();
    RotNull.source.name = "Cam_Rot";
    RotNull.threeDLayer = true;
    RotNull.position.setValue([w,h]);
    RotNull.enabled = true;

    newCamera.parent = PosNull; //parenting
    PosNull.parent = RotNull;

    var Lock3D = '[0,0,0]'; //lock unwanted properties
    var Lock1D = '[0]';
    var LockScale = '[100,100,100]';

    RotNull.anchorPoint.expression = Lock3D;
    RotNull.position.expression = Lock3D;
    RotNull.scale.expression = LockScale;

    PosNull.anchorPoint.expression = Lock3D;
    PosNull.scale.expression = LockScale;
    PosNull.orientation.expression = Lock3D;
    PosNull.xRotation.expression = Lock1D;
    PosNull.yRotation.expression = Lock1D;
    PosNull.zRotation.expression = Lock1D;

    /* PosNull.position.selected = true; //Selecting works, but Layer does not twirl down
    RotNull.orientation.selected = true;
    RotNull.xRotation.selected = true;
    RotNull.yRotation.selected = true;
    RotNull.zRotation.selected = true; */

    } else {
    alert("Please select at least one layer");
    }
    } else {
    alert("Please select an active comp to use this script");
    }

    Jason Schwarz replied 11 years, 6 months ago 1 Member · 1 Reply
  • 1 Reply
  • Jason Schwarz

    January 21, 2015 at 6:22 pm

    Found the One-Node Camera solution.

    Still needing some help on Question 1.

    var new_camera = comp.layers.addCamera("Camera"), [comp.width/2,comp.height/2]);

    new_camera.autoOrient = AutoOrientType.NO_AUTO_ORIENT;

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