simple layer repeater script problem

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
audiovisualist
Posts: 2
Joined: September 13th, 2012, 3:25 am

hi, i start learning scripting and copied the script for layer repeating from brian charles. after the first launch nothing happens. i figured out that i have to put ADBE to each property. But now it doesnt connect the sliders to the expressions and the position i commented out because this brings me an failure. can anybody give me an advice where the failure is? i have ae cs5 on mac. thanks

// offset layers beta
// ©February - March 2011 Brian Charles version b.05
// Apply to layer below to Copy and Offset Position and Rotation.
//Adds a null with sliders to adjust offset and rotation in X, Y and Z.
// Scale linked to top layer.
//Opacity Slider added Mar 2/2011
// Check for Selected Layer March 5/2011
// added function March 5/2011
// you must have a layer selected to make this work.
// Brian Charles
app.beginUndoGroup("layer repeater");


var myComp = app.project.activeItem;
var undoStr = "Layer Offset";
if (myComp == null || !(myComp instanceof CompItem)) {
alert("A Comp must be active to run this script");
} else {
//app.beginUndoGroup(undoStr);
var myLayer = myComp.selectedLayers;

if (myLayer == null) {
alert ("Select a Layer");
}else{

var thisLayer = myComp.selectedLayers[0];

if(thisLayer){
offset3D();
}else{
alert("Select a layer first.")
//app.endUndoGroup();
}
}
}
function offset3D() {
var theNum = prompt("How many copies:", "1");
thisLayer.threeDLayer = true;
thisLayer.duplicate();
// make a null object
var controlNull = myComp.layers.addNull();
controlNull.source.name = "3D Offset Control";
//add a sliders for X Y and Z Position
var offset = controlNull("Effects").addProperty("ADBE Slider Control");
offset.name = 'Layer Offset (X)';
var offset = controlNull("Effects").addProperty("ADBE Slider Control");
offset.name = 'Layer Offset (Y)';
var offset = controlNull("Effects").addProperty("ADBE Slider Control");
offset.name = 'Layer Offset (Z)';
// add angle controls for X Y and Z Rotation
var offset = controlNull("Effects").addProperty("ADBE Angle Control");
offset.name = 'X Rotation';
var offset = controlNull("Effects").addProperty("ADBE Angle Control");
offset.name = 'Y Rotation';
var offset = controlNull("Effects").addProperty("ADBE Angle Control");
offset.name = 'Z Rotation';
var offset = controlNull("Effects").addProperty("ADBE Slider Control");
offset.name = "Opacity Offset";
// duplicate the layers and
// add the script to the selected layer
for (i = 0; i < (theNum-1); i++) { /*
var posExpression = 'x =thisComp.layer(index-1).transform.position[0]+thisComp.layer("3D Offset Control").effect("Layer Offset (X)")("Slider"); y=thisComp.layer(index-1).transform.position[1]+ thisComp.layer("3D Offset Control").effect("Layer Offset (Y)")("Slider");z =thisComp.layer(index-1).transform.position[2]+ thisComp.layer("3D Offset Control").effect("Layer Offset (Z)")("Slider");[x,y,z]';
thisLayer.position.expression = posExpression;*/
var xRotExpression = 'thisComp.layer(index-1).transform.xRotation+thisComp.layer("3D Offset Control").effect("X Rotation")("Angle")';
thisLayer.xRotation.expression = xRotExpression;
var yRotExpression = 'thisComp.layer(index-1).transform.yRotation+thisComp.layer("3D Offset Control").effect("Y Rotation")("Angle")';
thisLayer.yRotation.expression = yRotExpression;
var zRotExpression = 'thisComp.layer(index-1).transform.zRotation+thisComp.layer("3D Offset Control").effect("Z Rotation")("Angle")';
thisLayer.zRotation.expression = zRotExpression;
var scaleExpression= 'thisComp.layer(index-1).transform.scale';
thisLayer.scale.expression = scaleExpression;
var opacityExpression = 'D = thisComp.layer("3D Offset Control").effect("Opacity Offset")("Slider");thisComp.layer(index-1).transform.opacity - ((D/10)*-1)';
thisLayer.opacity.expression = opacityExpression;
thisLayer.duplicate();
}
}
app.endUndoGroup();
Klustre
Posts: 21
Joined: July 27th, 2011, 2:53 am

It works for me. Did you restart AE to clear all the vars?
audiovisualist
Posts: 2
Joined: September 13th, 2012, 3:25 am

yeah Klustre.
i figured out that restarting ae helped. it is now working. thx
Post Reply