AE ENHANCERS

Expressions/Scripts/Presets
It is currently Fri May 24, 2013 10:44 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Add expression to Levels with script
PostPosted: Mon Apr 04, 2011 12:16 pm 
Offline

Joined: Sun May 01, 2005 1:52 pm
Posts: 129
I have a script that works great but I can't get the expression into the setvalue of the "GAMMA INVERSE" layer to work.
Hopefully someone here can help.

Code:
{
   // This script will create two Adjustment layers in the activeComp.
   // The adjustment layer will have Levels effect and ...
   //
   //
   // note: This script is using matchName so that this script can work with localized build.
   //

   var activeItem = app.project.activeItem;
   if (activeItem == null || !(activeItem instanceof CompItem)){
       alert("Please establish a comp as the active item and run the script again");
   } else {

      // By bracketing the operations with begin/end undo group, we can
      // undo the whole script with one undo operation.
      app.beginUndoGroup("Gamma up and down");

      var activeComp = activeItem;

      var solidName = "GAMMA DOWN";
      var solidW = activeComp.width;
      var solidH = activeComp.height;
      var solidPixelAspectRatio = activeComp.pixelAspect;
      var solidDuration = activeComp.duration;

      var adjLayer = activeComp.layers.addSolid([1, 1, 1], solidName, solidW, solidH, solidPixelAspectRatio, solidDuration);

      // Apply Levels   
         var levels = adjLayer.Effects.addProperty("Levels (Individual Controls)");

      // Set Values
          levels.property(6).setValue(.5);
       
      adjLayer.adjustmentLayer = true;
      //adjLayer.guideLayer = true;
      adjLayer.moveToBeginning();

// Gamma Inverse
var solidName = "GAMMA INVERSE";
      var solidW = activeComp.width;
      var solidH = activeComp.height;
      var solidPixelAspectRatio = activeComp.pixelAspect;
      var solidDuration = activeComp.duration;

      var adjLayer = activeComp.layers.addSolid([1, 1, 1], solidName, solidW, solidH, solidPixelAspectRatio, solidDuration);

      // Apply Levels
         var levels = adjLayer.Effects.addProperty("Levels (Individual Controls)");

      // Set Values
         levels.property(6).setValue(thisComp.layer("GAMMA DOWN")("Effects")("Levels (Individual Controls)")("Gamma"));
       
      adjLayer.adjustmentLayer = true;
          adjLayer.moveToBeginning();
      app.endUndoGroup();
   }
}


Top
 Profile  
 
 Post subject: Re: Add expression to Levels with script
PostPosted: Mon Apr 04, 2011 12:59 pm 
Offline
Enhancement master
User avatar

Joined: Thu Jun 17, 2004 9:27 am
Posts: 456
Location: New York City, NY
What are you trying to set the value to? You need to put the value in the SetValue parenthesis. Currently you have this:

Code:
//Set Values
         levels.property(6).setValue(thisComp.layer("GAMMA DOWN")("Effects")("Levels (Individual Controls)")("Gamma"));



But it should be something like this:
Code:
//Set Values
         levels.property(6).setValue(100);


-Lloyd

_________________
http://aescripts.com


Top
 Profile  
 
 Post subject: Re: Add expression to Levels with script
PostPosted: Tue Apr 05, 2011 3:17 pm 
Offline

Joined: Sun May 01, 2005 1:52 pm
Posts: 129
I'm trying to add an expression to invert the gamma of another adjustment layer.

The expression -- when working and set manually -- is this:

1/thisComp.layer("GAMMA DOWN")("Effects")("Levels (Individual Controls)")("Gamma")

It takes the value of the "GAMMA DOWN" layer's gamma and gives the inverse to regain a gamma of 1.0.


Attachments:
Screen shot 2011-04-05 at 12.52.03 PM.png
Screen shot 2011-04-05 at 12.52.03 PM.png [ 42.53 KiB | Viewed 770 times ]
Top
 Profile  
 
 Post subject: Re: Add expression to Levels with script
PostPosted: Tue Apr 05, 2011 4:40 pm 
Offline
Enhancement master
User avatar

Joined: Thu Jun 17, 2004 9:27 am
Posts: 456
Location: New York City, NY
Then just add it as an expression:

Code:
//Set Values
         levels.property(6).expression='1/thisComp.layer("GAMMA DOWN")("Effects")("Levels (Individual Controls)")("Gamma")';


Otherwise you need to calculate the actual value and set that.

-Lloyd

_________________
http://aescripts.com


Top
 Profile  
 
 Post subject: Re: Add expression to Levels with script
PostPosted: Tue Apr 05, 2011 5:20 pm 
Offline

Joined: Sun May 01, 2005 1:52 pm
Posts: 129
Yes!
That works!
It's the ".expression=" that I was missing.

Thanks Lloyd. You rock!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group