Addding an effect to a layer

Find out why the . goes before the /

Moderator: Paul Tuersley

peteoconnell
Posts: 19
Joined: November 14th, 2004, 2:10 pm

Hi I am making a script that creates an adjustment layer in my comp. How do I add an effect to this layer with scripting?
Here is my script so far:

//start
myComp = app.project.activeItem;
mySolid = myComp.layers.addSolid([0,0,0], "colorCorrect", myComp.width, myComp.height,1);
mySolid.startTime = 0
mySolid.adjustmentLayer = true;
//end

Thanks
Pete
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

Something like this:

myEffect = mySolid.property("Effects").addProperty("ADBE Lens Flare");


Dan
ulikilian
Posts: 13
Joined: April 28th, 2009, 8:11 am

Here is another related question (sorry - I'm still new to AFX):
How do I access the properties of the just added effect?
Lets say I've added a "Fast Blur" Effect to a layer. Reading the Bluriness value works like this:
app.project.item(1).layer("whatever_0000.tga")("Effects")("Fast Blur")("Blurriness")
But how do I actually SET a value? If I try to add just " = 17" AFX tells me
"Error: Can’t appear on the left hand side of an assignment, because it is read-only"

So what is the correct notation to assign a value to an effect's property?

Thanks a lot!
Uli
kobyg
Posts: 128
Joined: December 7th, 2007, 10:11 am

To set a value, use the setValue method.
For example for a value of 17 use:

Code: Select all

app.project.item(1).layer("whatever_0000.tga")("Effects")("Fast Blur")("Blurriness").setValue(17);
If you want to add a keyframe at a specific time, use the setValueAtTime method.
For example, to create a keyframe of 17 at the time of 2 seconds use:

Code: Select all

app.project.item(1).layer("whatever_0000.tga")("Effects")("Fast Blur")("Blurriness").setValueAtTime(2,17);
Koby.
ulikilian
Posts: 13
Joined: April 28th, 2009, 8:11 am

That simple - thanks a lot, Koby.
To prevent further basic questions, can you please tell me where I can find such information in some documentation.
The online scripting help is a big joke. There must be a simple index of all functions, methods, properties and some basic examples for things like I've asked.

Thanks again!
Uli
kobyg
Posts: 128
Joined: December 7th, 2007, 10:11 am

The best and a MUST documentation, is After Effects CS3 Scripting Guide:
http://www.adobe.com/products/aftereffe ... _guide.pdf

Koby.
ulikilian
Posts: 13
Joined: April 28th, 2009, 8:11 am

Super! Thanks a lot!
appie21
Posts: 11
Joined: July 27th, 2010, 2:12 am

Hello

When i Use

Code: Select all

app.project.item(1).layer("spot1.jpg")("Effects")("Fast Blur")("Blurriness").setValue(17);
then i get a Error AE was unable to call Item layer ... what do i wrong?

i have in my composition a image called spot1.jpg
over this image i will get the fast blur, blurriness also 17!

Howe can i get that!
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

My guess is that your comp may not be the first item (item(1)) in the project bin.

If you make sure the comp is selected you could use activeItem instead, like this:

var myComp = app.project.activeItem;
myComp.layer("spot1.jpg")("Effects")("Fast Blur")("Blurriness").setValue(17);


Dan
appie21
Posts: 11
Joined: July 27th, 2010, 2:12 am

it didn't work
must i give the full path of the image? for example d:\spot1.jpg?


i wil get a script when i run it it must do:
after open it there are 10 images in my work area
each image must get the effect fast blurr and i wil give each Fast blur effect uits own value (changed manual in the script)

I have made this code and it work for one picture becauase it add a new sollid.

Code: Select all

//start
var my_file = new File("d:/1.aep");
new_project = app.open(my_file);myComp = app.project.activeItem;
mySolid = myComp.layers.addSolid([0,0,0], "colorCorrect", myComp.width, myComp.height,1);
mySolid.adjustmentLayer = true;
myEffect = mySolid.property("Effects").addProperty("Fast Blur")("Blurriness").setValue(61);
var myQueue = app.project.renderQueue
myQueue.render();
var projectName = "Unsaved Project";
app.project.close(CloseOptions.DO_NOT_SAVE_CHANGES)
//end
But how can i make that each image get the effect blur on it?

Let me know

Albert
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

You have a lot of work left to do. You need to import your images (see ImportOptions() and importFile() in the scripting guide). You need to add each image to the comp and then add the effect. You need to add your comp to the render queue (app.project.renderQueue.items.add(comp). You may also need to set the render settings and output modules and the output file.

Dan
appie21
Posts: 11
Joined: July 27th, 2010, 2:12 am

Dan Ebberts wrote:You have a lot of work left to do. You need to import your images (see ImportOptions() and importFile() in the scripting guide). You need to add each image to the comp and then add the effect. You need to add your comp to the render queue (app.project.renderQueue.items.add(comp). You may also need to set the render settings and output modules and the output file.

Dan
hello

i have already placed my images in the timeline so all is imported jet!
i only want to get the effect's on the images so that if i start the script it automaticly do!


app.project.item(1).layer("whatever_0000.tga")("Effects")("Fast Blur")("Blurriness").setValue(17);

give an error to my file?
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

This should work:

var myEffect = myLayer.property("Effects").addProperty("Fast Blur");
myEffect.property("Blurriness").setValue(17);


If you're using a foreign language version of AE, you may need to use the match names like this:

var myEffect = myLayer.property("Effects").addProperty("ADBE Fast Blur");
myEffect.property("ADBE Fast Blur-0001").setValue(17);

Dan
appie21
Posts: 11
Joined: July 27th, 2010, 2:12 am

Dan Ebberts wrote:This should work:

var myEffect = myLayer.property("Effects").addProperty("Fast Blur");
myEffect.property("Blurriness").setValue(17);


If you're using a foreign language version of AE, you may need to use the match names like this:

var myEffect = myLayer.property("Effects").addProperty("ADBE Fast Blur");
myEffect.property("ADBE Fast Blur-0001").setValue(17);

Dan
Hi Thanks for help


i have try it

like this

Code: Select all

//start
var my_file = new File("d:/1.aep");
new_project = app.open(my_file);myComp = app.project.activeItem;
mySolid = myComp.layers.addSolid([0,0,0], "colorCorrect", myComp.width, myComp.height,1);
mySolid.adjustmentLayer = true;
var myEffect = myLayer.property("Effects").addProperty("Fast Blur");
myEffect.property("Blurriness").setValue(17);
var myQueue = app.project.renderQueue
myQueue.render();
var projectName = "Unsaved Project";
app.project.close(CloseOptions.DO_NOT_SAVE_CHANGES)
//end
but it give a error


at line 7 i get " Mylayer is undefined"
how to fix
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

Try changing "myLayer" to "mySolid"


Dan
Post Reply