Page 1 of 1

Adjust Levels Script

Posted: October 13th, 2005, 7:09 pm
by scribling
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.

Hello ...

Posted: October 27th, 2005, 3:10 pm
by scribling
I thought this would be simple. Oh well.

Anyone?

Posted: November 4th, 2005, 9:25 am
by Paul Tuersley
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);
}

I still can't get it to work

Posted: November 5th, 2005, 1:30 pm
by scribling
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

Posted: November 5th, 2005, 1:45 pm
by Paul Tuersley
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);	

Sure does.

Posted: November 7th, 2005, 2:34 pm
by scribling
I don't know why but it didn't work the first time I tried but works great now.

Thanks again.