This script reads a user specified text file and
creates a text layer for each line of text in a
new comp called "Text Comp", or it uses the active comp.
- adds expression to control a random placement in 3d space
- adds expression to control a depth fade as the layer recedes from the camera
- creates a new camera and a null with sliders to control the effect
It's pretty basic but I hope someone can find it useful.
This script is AWESOME and is almost just what I needed.
I have about 500 text layers that I need to fly through in a more or less straight Z fashion (with some X and Y distribution to the layers for variety). Thus I really need a separate slider to control the X Spread, Y Spread and Z Spread. Is that possible? I'm attempting to modify the script myself to do that but I know I am making a mess of things and haven't gotten to work yet so I figured I'd ask.
byronnash wrote:Glad to hear that the script was helpful. I wrote that one a l o n g time ago and I'm sure it's very messy. I haven't opened it in a while.
i just found your first script about this 3dtext-thing - and read the posts to it, but i could'nt find the modified script for the xyz-spread of the textlayers - i would really appreciate if someone could post it here or post a link where to find it!
it would be so much help for me, because i'm doing exactly something like this - a camera move through a field of keywords...
Don't know why he never posted his code, but it's an easy enough tweak.. I have not had a chance to test this so tell me if you run into any problems..
//
// Random3dText_w_depth_xyz.jsx
//
//Byron Nash 01/05
//The text reading/creating was borrowed from createTextLayersFromFile.jsx
// by Dan Ebberts
//
// This script reads a user specified text file and
// creates a text layer for each line of text in a
// new comp called "Text Comp", or it uses the active comp.
// - adds expression to control a random placement in 3d space
// - adds expression to control a depth fade as the layer recedes from the camera
// - creates a new camera and a null with sliders to control the effect
//
// added x,y,z sliders 10/2007 lloyd alvarez
//
{
// create undo group
app.beginUndoGroup("Create Text Layers From File");
// Prompt user to select text file
var myFile = fileGetDialog("Select a text file to open.");
if (myFile != null){
// open file
var fileOK = myFile.open("r","TEXT","????");
if (fileOK){
// create project if necessary
var proj = app.project;
if(!proj) proj = app.newProject();
//set currently selected comp to variable
var myComp = app.project.activeItem;
//check to see if selected item is a comp, if not, make a new comp
if(proj.activeItem instanceof CompItem) {
var myComp = proj.activeItem;
}else{
// create new comp named 'my text comp'
var compW = 720; // comp width
var compH = 486; // comp height
var compL = 15; // comp length (seconds)
var compRate = 29.97; // comp frame rate
var compBG = [0/255,0/255,0/255] // comp background color
var myItemCollection = app.project.items;
var myComp = myItemCollection.addComp('Text Comp',compW,compH,1,compL,compRate);
myComp.bgColor = compBG;
}
//setup controller null and add expression sliders
var controlLayer = myComp.layers.addNull();
controlLayer.startTime = 0;
controlLayer.enabled = false;
controlLayer.source.name = "Controller";
var theControl = controlLayer.Effects.addProperty("ADBE Slider Control");
theControl.name = "X_Spread";
theControl.property(1).setValue(0);
var theControl = controlLayer.Effects.addProperty("ADBE Slider Control");
theControl.name = "Y_Spread";
theControl.property(1).setValue(0);
var theControl = controlLayer.Effects.addProperty("ADBE Slider Control");
theControl.name = "Z_Spread";
theControl.property(1).setValue(0);
var opacityMin = controlLayer.Effects.addProperty("ADBE Slider Control");
opacityMin.name = "Start Fade";
opacityMin.property(1).setValue(0);
var opacityMax = controlLayer.Effects.addProperty("ADBE Slider Control");
opacityMax.name = "End Fade";
opacityMax.property(1).setValue(1000);
var cam = myComp.layers.addCamera("Camera 1",[360,243]);//make a new camera
// read text lines and create text layer for each
// until end-of-file is reached
var text;
while (!myFile.eof){
text = myFile.readln();
if (text != "") {
var curLayer = myComp.layers.addText(text);
curLayer.threeDLayer = true;
//define expressions on position and opacity
var posExp = 'seedRandom(index,true);\r'+
'x_slider = thisComp.layer("Controller").effect("X_Spread")("Slider");\r'+
'y_slider = thisComp.layer("Controller").effect("Y_Spread")("Slider");\r'+
'z_slider = thisComp.layer("Controller").effect("Z_Spread")("Slider");\r'+
'midWidth = thisComp.width/2; midHeight = thisComp.height/2;\r'+
'x = random(x_slider,x_slider*-1);\r'+
'y = random(y_slider,y_slider*-1);\r'+s
'z = random(z_slider,z_slider*-1);\r'+
'[x+midWidth,y+midHeight,z];\r';
var opacExp = 'depth = length(position,thisComp.layer("Camera 1").position);\r'+
'min = thisComp.layer("Controller").effect("Start Fade")("Slider");\r'+
'max = thisComp.layer("Controller").effect("End Fade")("Slider");\r'+
'linear(depth,min,max,100,0)';
//add expressions on position and opacity
curLayer.property("position").expression = posExp;
curLayer.property("opacity").expression = opacExp;
}
}
controlLayer.moveToBeginning();//moves the null to the top of the stack
cam.moveToBeginning();//moves the cam to the top of the stack
// close the file before exiting
myFile.close();
}else{
alert("File open failed!");
}
}else{
alert("No text file selected.");
}
app.endUndoGroup();
}
my spamfilter was blocking the mail from ae enhancers - so i just got it now - in the meantime i figured out a script by myself and it works - but i will try yours too - i let you know about how irt works, but thanks anyway!!!!
and here is my script - if you are using a english version of ae you should replace "Schieberegler" with "slider", because i'm using a german version of ae...
//
// Random3dText_w_depth.jsx - changed and extended by toby mory 10/07
//
//Byron Nash 01/05
//The text reading/creating was borrowed from createTextLayersFromFile.jsx
// by Dan Ebberts
//
// This script reads a user specified text file and
// creates a text layer for each line of text in a
// new comp called "Text Comp", or it uses the active comp.
// - adds expression to control a random placement in 3d space
// - adds expression to control a depth fade as the layer recedes from the camera
// - creates a new camera and a null with Schiebereglers to control the effect
{
// create undo group
app.beginUndoGroup("Create Text Layers From File");
// Prompt user to select text file
var myFile = fileGetDialog("Select a text file to open.", "TEXT txt");
if (myFile != null){
// open file
var fileOK = myFile.open("r","TEXT","????");
if (fileOK){
// create project if necessary
var proj = app.project;
if(!proj) proj = app.newProject();
//set currently selected comp to variable
var myComp = app.project.activeItem;
//check to see if selected item is a comp, if not, make a new comp
if(proj.activeItem instanceof CompItem) {
var myComp = proj.activeItem;
}else{
// create new comp named 'my text comp'
var compW = 768; // comp width
var compH = 576; // comp height
var compL = 60; // comp length (seconds)
var compRate = 25; // comp frame rate
var compBG = [255/255,255/255,255/255] // comp background color
var myItemCollection = app.project.items;
var myComp = myItemCollection.addComp('Text Comp',compW,compH,1,compL,compRate);
myComp.bgColor = compBG;
}
var cam = myComp.layers.addCamera("Camera 1",[360,243]);//make a new camera
// read text lines and create text layer for each
// until end-of-file is reached
var text;
while (!myFile.eof){
text = myFile.readln();
if (text != "") {
var curLayer = myComp.layers.addText(text);
curLayer.threeDLayer = true;
//define expressions on position and opacity
var posExp = 'seedRandom(index,true);\r'+
'SchiebereglerX = thisComp.layer("Controller").effect("SpreadX")("Schieberegler");\r'+
'midWidth = thisComp.width/2;\r'+
'x = random(SchiebereglerX,SchiebereglerX*-1);\r'+
'SchiebereglerY = thisComp.layer("Controller").effect("SpreadY")("Schieberegler");\r'+
'midHeight = thisComp.height/2;\r'+
'y = random(SchiebereglerY,SchiebereglerY*-1);\r'+
'SchiebereglerZ = thisComp.layer("Controller").effect("SpreadZ")("Schieberegler");\r'+
'z = random(SchiebereglerZ,SchiebereglerZ*-1);\r'+
'[x+midWidth,y+midHeight,z];\r';
var opacExp = 'depth = length(position,thisComp.layer("Camera 1").position);\r'+
'min = thisComp.layer("Controller").effect("Start Fade")("Schieberegler");\r'+
'max = thisComp.layer("Controller").effect("End Fade")("Schieberegler");\r'+
'linear(depth,min,max,0,100)';
//add expressions on position and opacity
curLayer.property("position").expression = posExp;
curLayer.property("opacity").expression = opacExp;
}
}
controlLayer.moveToBeginning();//moves the null to the top of the stack
cam.moveToBeginning();//moves the cam to the top of the stack
// close the file before exiting
myFile.close();
}else{
alert("File open failed!");
}
}else{
alert("No text file selected.");
}