ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Changing Anchorpoint within a Script - Create Null and parent to selected layer.

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Sebastian Rasche
Changing Anchorpoint within a Script - Create Null and parent to selected layer.
on Jul 10, 2017 at 1:09:17 pm

Hey there,

so I found this script by Lloyd Alvarez on AeScripts called "Add Parented Null to Selected Layers"
What the script basically does is creating a null and parent it to a selected layer.

The only thing I would like to change is that the nulls Anchorpoint is centered, so basically having the Anchorpoints coordinates at [50,50].
As I have no experience with scripting could anybody tell me how I would achieve that?

Thanks in advance!

var proj = app.project;
var undoStr = "Add Parented Null to Selected Layers";

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

var myLayers = myComp.selectedLayers;
if (myLayers.length != 0) {
var saveIn = myComp.duration;
var saveOut = 0;
var saveIndex = myComp.numLayers;
var newInpoint=myComp.duration, newOutpoint=0, myIndex=myComp.numLayers;
var newNull = myComp.layers.addNull(myComp.duration);
//check to see if any of the selected layers is a 3d layer
for (i=0; i &lt;= myLayers.length-1; i++){
if (myLayers[i].threeDLayer) {
newNull.threeDLayer = true;

for (i=0; i &lt;= myLayers.length-1; i++){

currentLayer = myLayers[i];
saveIn = (currentLayer.stretch &lt; 0) ? currentLayer.outPoint : currentLayer.inPoint;
saveOut = (currentLayer.stretch &lt; 0) ? currentLayer.inPoint : currentLayer.outPoint;
saveIndex = currentLayer.index;

if (saveIn &lt; newInpoint) {newInpoint = saveIn}
if (saveOut > newOutpoint) {newOutpoint = saveOut}
if (saveIndex &lt; myIndex) {myIndex = saveIndex}

currentLayer.parent = newNull;

newNull.inPoint = newInpoint;
newNull.outPoint = newOutpoint;

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

Return to posts index

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