Expressions/Scripts/Presets

Moderator: Paul Tuersley

 
peteoconnell
Topic Author
Posts: 19
Joined: Sun Nov 14, 2004 2:10 pm

Addding an effect to a layer

Wed Sep 03, 2008 9:34 am

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: 319
Joined: Sat Jun 26, 2004 10:01 am
Location: Folsom, CA
Contact:

Re: Addding an effect to a layer

Wed Sep 03, 2008 1:56 pm

Something like this:

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


Dan
 
ulikilian
Posts: 13
Joined: Tue Apr 28, 2009 8:11 am

Re: Addding an effect to a layer

Mon Jun 01, 2009 3:59 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: Fri Dec 07, 2007 10:11 am

Re: Addding an effect to a layer

Mon Jun 01, 2009 6:16 am

To set a value, use the setValue method.
For example for a value of 17 use:
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:
app.project.item(1).layer("whatever_0000.tga")("Effects")("Fast Blur")("Blurriness").setValueAtTime(2,17);

Koby.
 
ulikilian
Posts: 13
Joined: Tue Apr 28, 2009 8:11 am

Re: Addding an effect to a layer

Mon Jun 01, 2009 10:15 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: Fri Dec 07, 2007 10:11 am

Re: Addding an effect to a layer

Mon Jun 01, 2009 10:52 am

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

Koby.
 
ulikilian
Posts: 13
Joined: Tue Apr 28, 2009 8:11 am

Re: Addding an effect to a layer

Tue Jun 02, 2009 3:38 am

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

Re: Addding an effect to a layer

Fri Aug 06, 2010 6:45 am

Hello

When i Use
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: 319
Joined: Sat Jun 26, 2004 10:01 am
Location: Folsom, CA
Contact:

Re: Addding an effect to a layer

Fri Aug 06, 2010 2:56 pm

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: Tue Jul 27, 2010 2:12 am

Re: Addding an effect to a layer

Sat Aug 07, 2010 2:16 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.

//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: 319
Joined: Sat Jun 26, 2004 10:01 am
Location: Folsom, CA
Contact:

Re: Addding an effect to a layer

Sat Aug 07, 2010 10:44 am

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: Tue Jul 27, 2010 2:12 am

Re: Addding an effect to a layer

Mon Aug 09, 2010 3:01 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: 319
Joined: Sat Jun 26, 2004 10:01 am
Location: Folsom, CA
Contact:

Re: Addding an effect to a layer

Mon Aug 09, 2010 10:31 am

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: Tue Jul 27, 2010 2:12 am

Re: Addding an effect to a layer

Mon Aug 09, 2010 2:39 pm

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

//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: 319
Joined: Sat Jun 26, 2004 10:01 am
Location: Folsom, CA
Contact:

Re: Addding an effect to a layer

Mon Aug 09, 2010 3:17 pm

Try changing "myLayer" to "mySolid"


Dan

Who is online

Users browsing this forum: No registered users and 3 guests