Adjust Levels Script

What type of scripts do you need?

Moderator: byronnash

Post Reply
scribling
Posts: 143
Joined: May 1st, 2005, 1:52 pm

I've altered the Cineon Converter Adj layer script to create a Gamma check layer, but I can't get it to set the Gamma to 5.

Everything else works great except this part.
Here's what I've tried and doesn't work:

levels.property("Levels-0004").setValue(5);
levels.property("Levels-0004").setValue(5.0);
levels.property("Levels-0004").setValue(5.0);
Gamma to 5.00;

All I need is this one line.

Thanks.
scribling
Posts: 143
Joined: May 1st, 2005, 1:52 pm

I thought this would be simple. Oh well.

Anyone?
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

Sorry it's taken so long to respond. Here's a script that should tell you what you need to know, select a layer before running the script.

Code: Select all

{
	// you must have a layer selected before running this script
	var activeItem = app.project.activeItem;
	var activeComp = activeItem;
	var theLayer = activeComp.selectedLayers[0];

	// apply Levels effect (two naming methods are shown)
   	//theEffect = theLayer.Effects.addProperty("ADBE Easy Levels");
   	theEffect = theLayer.Effects.addProperty("Levels");

	// loop through effect properties, showing name and matchName
	for (var j = 1; j <= theEffect.numProperties; j++) {
		alert("Property " + j + "\rname = " + theEffect.property(j).name + "\rmatchName = " + theEffect.property(j).matchName);
	}

	// here are three possible ways of accessing an effect property
	//theEffect.property(5).setValue(5);
	//theEffect.property("Gamma").setValue(5);
	theEffect.property("ADBE Easy Levels-0005").setValue(5);
}
scribling
Posts: 143
Joined: May 1st, 2005, 1:52 pm

Here's the code I'm using. I added you code but still can't get it to work.

Code: Select all

{
	// This script will create an Adjustment layer in the activeComp.
	// The adjstment 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("Levels Adjust");

		var activeComp = activeItem;

		var solidName = "GAMMA CHECK";
		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");

		// Set Values

			//levels.property("Levels-0004").setValue(4);
			//levels.property("Levels-0004").setValue(4.0);
			//Gamma to 5.00;
			

		adjLayer.adjustmentLayer = true;
		adjLayer.guideLayer = true;
		adjLayer.moveToBeginning();

		app.endUndoGroup();
	}
}
Thanks for the help
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

If I replace these lines in your script:

Code: Select all

		//levels.property("Levels-0004").setValue(4); 
		//levels.property("Levels-0004").setValue(4.0); 
		//Gamma to 5.00;
with any one of these lines, it works fine for me.

Code: Select all

		levels.property("ADBE Easy Levels-0005").setValue(5);
		levels.property(5).setValue(5);
		levels.property("Gamma").setValue(5);	
scribling
Posts: 143
Joined: May 1st, 2005, 1:52 pm

I don't know why but it didn't work the first time I tried but works great now.

Thanks again.
Post Reply