Mailing List AE-List@media-motion.tv ? Message #52580
From: David Torno <torno@sydefxink.com>
Subject: Re: [AE] scripting for pseudo-effects
Date: Sun, 19 Jan 2014 17:02:28 -0800
To: After Effects Mail List <AE-List@media-motion.tv>
My terminology may be off a bit too in explaining that. You'll come across this issue in a few spots in ExtendScript as a heads up.

David Torno
Technical Director
O: 213.739.2290
C: 818.391.6060
--------------------

"The most useless day is that in which we do not laugh"
-Charles Field

On Jan 19, 2014, at 4:30 PM, Drew Gilmore <dotsandlines@gmail.com> wrote:

Ahh, ok. I may have to let the logic of that sink in, but I think I get it. This is what happens when I only script every year or so. Thanks very much for the help!

Drew


On Sun, Jan 19, 2014 at 6:02 PM, David Torno <torno@sydefxink.com> wrote:
The reason is that the first object becomes invalid once you run addProperty again. You can add the properties back to back like in version 2, but you would need to assign them to variables afterwards like in version 3, to be able to access any attributes for them.

VERSION 1
var vppath = curLayer.Effects.addProperty("VP-Path");
vppath.property("Azimuth").expression = ("50");

var vp = curLayer.Effects.addProperty("Virtual Projector");
vp.property("Azimuth").expression = ("50");
This works because you are changing a value to a valid effect property immediately after creating each effect.

VERSION 2
var vppath = curLayer.Effects.addProperty("VP-Path");
var vp = curLayer.Effects.addProperty("Virtual Projector");

vp.property("Azimuth").expression = ("50");
vppath.property("Azimuth").expression = ("50");
vppath becomes invalid the second you add another property (vp), at which point you cannot change something that's invalid. You can check if a variable is valid by running:
vppath.isValid;
vp.isValid;


Doing this though, should work.
VERSION 3
//Create effects
curLayer.Effects.addProperty("VP-Path");
curLayer.Effects.addProperty("Virtual Projector");

//Assign effects variables
var vppath = curLayer.property("ADBE Effect Parade").property("VP-Path");
var vp = curLayer.property("ADBE Effect Parade").property("Virtual Projector");

//Change properties
vp.property("Azimuth").expression = ("50");
vppath.property("Azimuth").expression = ("50");


------
David Torno
Visual Effects Artist and Supervisor
------------------------------------------------
http://www.sydefxink.com  (main portfolio)
http://aeioweyou.blogspot.com (vfx tutorials and AE scripts blog)
http://mactex.blogspot.com  (free textures blog)

On Jan 19, 2014, at 2:01 PM, Drew Gilmore wrote:

Thanks yeah, now that I poke around it's clearly something else I'm doing wrong... I think I have it working. But now I'm curious. Why does this work:

var vppath = curLayer.Effects.addProperty("VP-Path");
vppath.property("Azimuth").expression = ("50");

var vp = curLayer.Effects.addProperty("Virtual Projector");
vp.property("Azimuth").expression = ("50");


But this doesn't:

var vppath = curLayer.Effects.addProperty("VP-Path");
var vp = curLayer.Effects.addProperty("Virtual Projector");

vp.property("Azimuth").expression = ("50");
vppath.property("Azimuth").expression = ("50");


(FWIW, VP-Path is the custom effect, Virtual Projector is a plugin effect.)

Thanks,
Drew


 
Subscribe (FEED) Subscribe (DIGEST) Subscribe (INDEX) Unsubscribe Mail to ListMaster