Page 1 of 2

Addding an effect to a layer

Posted: September 3rd, 2008, 9:34 am
by peteoconnell
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

Re: Addding an effect to a layer

Posted: September 3rd, 2008, 1:56 pm
by Dan Ebberts
Something like this:

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


Dan

Re: Addding an effect to a layer

Posted: June 1st, 2009, 3:59 am
by ulikilian
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

Re: Addding an effect to a layer

Posted: June 1st, 2009, 6:16 am
by kobyg
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.

Re: Addding an effect to a layer

Posted: June 1st, 2009, 10:15 am
by ulikilian
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

Re: Addding an effect to a layer

Posted: June 1st, 2009, 10:52 am
by kobyg
The best and a MUST documentation, is After Effects CS3 Scripting Guide:
http://www.adobe.com/products/aftereffe ... _guide.pdf

Koby.

Re: Addding an effect to a layer

Posted: June 2nd, 2009, 3:38 am
by ulikilian
Super! Thanks a lot!

Re: Addding an effect to a layer

Posted: August 6th, 2010, 6:45 am
by appie21
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!

Re: Addding an effect to a layer

Posted: August 6th, 2010, 2:56 pm
by Dan Ebberts
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

Re: Addding an effect to a layer

Posted: August 7th, 2010, 2:16 am
by appie21
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

Re: Addding an effect to a layer

Posted: August 7th, 2010, 10:44 am
by Dan Ebberts
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

Re: Addding an effect to a layer

Posted: August 9th, 2010, 3:01 am
by appie21
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?

Re: Addding an effect to a layer

Posted: August 9th, 2010, 10:31 am
by Dan Ebberts
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

Re: Addding an effect to a layer

Posted: August 9th, 2010, 2:39 pm
by appie21
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

Re: Addding an effect to a layer

Posted: August 9th, 2010, 3:17 pm
by Dan Ebberts
Try changing "myLayer" to "mySolid"


Dan