Curves for Dodge&Burn

Explorer ,
Aug 17, 2022 Aug 17, 2022

Copy link to clipboard

Copied

Can anyone help me again 😊?

I was helped here Solved: Layer automatically assigned to group - Adobe Support Community - 11085982 and i'm sort of wanting the same thing with a dedicated group, if its not created, create one and these curves placed in that group no matter where you're in the layers palette.

 

I'm wanting two curves, that when I active the scripts they're placed in a group Called "Dodge & Burn", which will be a dedicated group.

One curve named Dodge, with no mask, inside its own group also called Dodge with a black mask with these points ([0,0], [26,64], [64,128], [128,192], [192,230], [255,255]).

Second curve named Burn, with no mask, inside its own group also called Burn with a black mask with these points ([0,0], [64,26], [128,64], [192,128], [230,192], [255,255]).

 

I can take the script above in the old thread and change the blank layers names and blend modes and such but no matter what I tried I can't get a curve placed in the group. I tried copying and pasting codes from other threads with no luck, so i'd be very grateful if you can help. Thanks

 

 

TOPICS
Actions and scripting

Views

163

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 17, 2022 Aug 17, 2022

I'll look at a script for you, however, this should be possible via an Action.

 

Edit:

 

The Action link – https://shared-assets.adobe.com/link/5922e583-986b-47db-5515-47ed7f0fe6f6

 

Dodge-&-Burn-Group.png

 

dodge-burn-group-layers.png

 

The action hasn't been exhaustively tested, so it may not work as expected with some layer stack combinations.

 

Let me know how it goes!

Likes

Translate

Translate
Community Expert ,
Aug 17, 2022 Aug 17, 2022

Copy link to clipboard

Copied

I'll look at a script for you, however, this should be possible via an Action.

 

Edit:

 

The Action link – https://shared-assets.adobe.com/link/5922e583-986b-47db-5515-47ed7f0fe6f6

 

Dodge-&-Burn-Group.png

 

dodge-burn-group-layers.png

 

The action hasn't been exhaustively tested, so it may not work as expected with some layer stack combinations.

 

Let me know how it goes!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 18, 2022 Aug 18, 2022

Copy link to clipboard

Copied

And here is a scripted version of the action:

 

 

// Select the top layer without changing visibility
if (activeDocument.artLayers[0].visible === false) {
    activeDocument.activeLayer = activeDocument.artLayers[0];
    activeDocument.activeLayer.visible = false;
} else {
    activeDocument.activeLayer = activeDocument.artLayers[0];
}

// Add dodge curves adjustment layer
addCurvesAdjustmentLayer("Dodge", "lighten");
deleteLayerMask();
curvePoints(0, 0, 26, 64, 64, 128, 128, 192, 192, 230, 255, 255);

// Add burn curves adjustment layer
addCurvesAdjustmentLayer("Burn", "darken");
deleteLayerMask();
curvePoints(0, 0, 64, 26, 128, 64, 192, 128, 230, 192, 255, 255);

// Add burn group
makeGroupFromLayers("Burn", 1, 2, "Burn");
addLayerMask("hideAll");

// Add dodge group
app.activeDocument.activeLayer = app.activeDocument.artLayers["Dodge"];
makeGroupFromLayers("Dodge", 1, 2, "Dodge");
addLayerMask("hideAll");

// Create doge & burn group
selectDodgeAndBurnLayers();
makeGroupFromLayers("Dodge & Burn", 1, 2, "Dodge & Burn");

/*
// Expand dodge & burn group
if (app.activeDocument.activeLayer.typename == 'LayerSet' && app.activeDocument.activeLayer.layers.length > 0) {
    app.activeDocument.activeLayer = app.activeDocument.activeLayer.layers[0];
}
*/


/***** Functions *****/

function addCurvesAdjustmentLayer(layerName, blendMode) {
	function s2t(s) {
        return app.stringIDToTypeID(s);
    }
	var descriptor = new ActionDescriptor();
	var descriptor2 = new ActionDescriptor();
	var descriptor3 = new ActionDescriptor();
	var reference = new ActionReference();
	reference.putClass( s2t( "adjustmentLayer" ));
	descriptor.putReference( s2t( "null" ), reference );
	descriptor2.putString( s2t( "name" ), layerName );
	descriptor2.putEnumerated( s2t( "mode" ), s2t( "blendMode" ), s2t( blendMode ));
	descriptor3.putEnumerated( s2t( "presetKind" ), s2t( "presetKindType" ), s2t( "presetKindDefault" ));
	descriptor2.putObject( s2t( "type" ), s2t( "curves" ), descriptor3 );
	descriptor.putObject( s2t( "using" ), s2t( "adjustmentLayer" ), descriptor2 );
	executeAction( s2t( "make" ), descriptor, DialogModes.NO );
}

function deleteLayerMask() {
	function s2t(s) {
        return app.stringIDToTypeID(s);
    }
	var descriptor = new ActionDescriptor();
	var reference = new ActionReference();
	reference.putEnumerated( s2t( "channel" ), s2t( "ordinal" ), s2t( "targetEnum" ));
	descriptor.putReference( s2t( "null" ), reference );
	executeAction( s2t( "delete" ), descriptor, DialogModes.NO );
}

function curvePoints(horizontal, vertical, horizontal2, vertical2, horizontal3, vertical3, horizontal4, vertical4, horizontal5, vertical5, horizontal6, vertical6) {
	function s2t(s) {
        return app.stringIDToTypeID(s);
    }

	var descriptor = new ActionDescriptor();
	var descriptor2 = new ActionDescriptor();
	var descriptor3 = new ActionDescriptor();
	var descriptor4 = new ActionDescriptor();
	var descriptor5 = new ActionDescriptor();
	var descriptor6 = new ActionDescriptor();
	var descriptor7 = new ActionDescriptor();
	var descriptor8 = new ActionDescriptor();
	var descriptor9 = new ActionDescriptor();
	var list = new ActionList();
	var list2 = new ActionList();
	var reference = new ActionReference();
	var reference2 = new ActionReference();

	reference.putEnumerated( s2t( "adjustmentLayer" ), s2t( "ordinal" ), s2t( "targetEnum" ));
	descriptor.putReference( s2t( "null" ), reference );
	descriptor2.putEnumerated( s2t( "presetKind" ), s2t( "presetKindType" ), s2t( "presetKindCustom" ));
	reference2.putEnumerated( s2t( "channel" ), s2t( "channel" ), s2t( "composite" ));
	descriptor3.putReference( s2t( "channel" ), reference2 );
	descriptor4.putDouble( s2t( "horizontal" ), horizontal );
	descriptor4.putDouble( s2t( "vertical" ), vertical );
	list2.putObject( s2t( "paint" ), descriptor4 );
	descriptor5.putDouble( s2t( "horizontal" ), horizontal2 );
	descriptor5.putDouble( s2t( "vertical" ), vertical2 );
	list2.putObject( s2t( "paint" ), descriptor5 );
	descriptor6.putDouble( s2t( "horizontal" ), horizontal3 );
	descriptor6.putDouble( s2t( "vertical" ), vertical3 );
	list2.putObject( s2t( "paint" ), descriptor6 );
	descriptor7.putDouble( s2t( "horizontal" ), horizontal4 );
	descriptor7.putDouble( s2t( "vertical" ), vertical4 );
	list2.putObject( s2t( "paint" ), descriptor7 );
	descriptor8.putDouble( s2t( "horizontal" ), horizontal5 );
	descriptor8.putDouble( s2t( "vertical" ), vertical5 );
	list2.putObject( s2t( "paint" ), descriptor8 );
	descriptor9.putDouble( s2t( "horizontal" ), horizontal6 );
	descriptor9.putDouble( s2t( "vertical" ), vertical6 );
	list2.putObject( s2t( "paint" ), descriptor9 );
	descriptor3.putList( s2t( "curve" ), list2 );
	list.putObject( s2t( "curvesAdjustment" ), descriptor3 );
	descriptor2.putList( s2t( "adjustment" ), list );
	descriptor.putObject( s2t( "to" ), s2t( "curves" ), descriptor2 );
	executeAction( s2t( "set" ), descriptor, DialogModes.NO );
}

function makeGroupFromLayers(name2, layerSectionStart, layerSectionEnd, name3) {
	function s2t(s) {
        return app.stringIDToTypeID(s);
    }
	var descriptor = new ActionDescriptor();
	var descriptor2 = new ActionDescriptor();
	var reference = new ActionReference();
	var reference2 = new ActionReference();
	reference.putClass( s2t( "layerSection" ));
	descriptor.putReference( s2t( "null" ), reference );
	reference2.putEnumerated( s2t( "layer" ), s2t( "ordinal" ), s2t( "targetEnum" ));
	descriptor.putReference( s2t( "from" ), reference2 );
	descriptor2.putString( s2t( "name" ), name2 );
	descriptor.putObject( s2t( "using" ), s2t( "layerSection" ), descriptor2 );
	descriptor.putInteger( s2t( "layerSectionStart" ), layerSectionStart );
	descriptor.putInteger( s2t( "layerSectionEnd" ), layerSectionEnd );
	descriptor.putString( s2t( "name" ), name3 );
	executeAction( s2t( "make" ), descriptor, DialogModes.NO );
}

function addLayerMask(maskType) {
	function s2t(s) {
        return app.stringIDToTypeID(s);
    }

	var descriptor = new ActionDescriptor();
	var reference = new ActionReference();

	descriptor.putClass( s2t( "new" ), s2t( "channel" ));
	reference.putEnumerated( s2t( "channel" ), s2t( "channel" ), s2t( "mask" ));
	descriptor.putReference( s2t( "at" ), reference );
	descriptor.putEnumerated( s2t( "using" ), s2t( "userMaskEnabled" ), s2t( maskType ));
	executeAction( s2t( "make" ), descriptor, DialogModes.NO );
}

function selectDodgeAndBurnLayers() {
    var idselect = stringIDToTypeID("select");
    var desc941 = new ActionDescriptor();
    var idnull = stringIDToTypeID("null");
    var ref271 = new ActionReference();
    var idlayer = stringIDToTypeID("layer");
    var idordinal = stringIDToTypeID("ordinal");
    var idfront = stringIDToTypeID("front");
    ref271.putEnumerated(idlayer, idordinal, idfront);
    desc941.putReference(idnull, ref271);
    var idmakeVisible = stringIDToTypeID("makeVisible");
    desc941.putBoolean(idmakeVisible, false);
    var idlayerID = stringIDToTypeID("layerID");
    var list98 = new ActionList();
    desc941.putList(idlayerID, list98);
    executeAction(idselect, desc941, DialogModes.NO);

    var idselect = stringIDToTypeID("select");
    var desc942 = new ActionDescriptor();
    var idnull = stringIDToTypeID("null");
    var ref272 = new ActionReference();
    var idlayer = stringIDToTypeID("layer");
    var idordinal = stringIDToTypeID("ordinal");
    var idbackwardEnum = stringIDToTypeID("backwardEnum");
    ref272.putEnumerated(idlayer, idordinal, idbackwardEnum);
    desc942.putReference(idnull, ref272);
    var idselectionModifier = stringIDToTypeID("selectionModifier");
    var idselectionModifierType = stringIDToTypeID("selectionModifierType");
    var idaddToSelection = stringIDToTypeID("addToSelection");
    desc942.putEnumerated(idselectionModifier, idselectionModifierType, idaddToSelection);
    var idmakeVisible = stringIDToTypeID("makeVisible");
    desc942.putBoolean(idmakeVisible, false);
    var idlayerID = stringIDToTypeID("layerID");
    var list99 = new ActionList();
    desc942.putList(idlayerID, list99);
    executeAction(idselect, desc942, DialogModes.NO);

    var idselect = stringIDToTypeID("select");
    var desc943 = new ActionDescriptor();
    var idnull = stringIDToTypeID("null");
    var ref273 = new ActionReference();
    var idlayer = stringIDToTypeID("layer");
    var idordinal = stringIDToTypeID("ordinal");
    var idbackwardEnum = stringIDToTypeID("backwardEnum");
    ref273.putEnumerated(idlayer, idordinal, idbackwardEnum);
    desc943.putReference(idnull, ref273);
    var idselectionModifier = stringIDToTypeID("selectionModifier");
    var idselectionModifierType = stringIDToTypeID("selectionModifierType");
    var idaddToSelection = stringIDToTypeID("addToSelection");
    desc943.putEnumerated(idselectionModifier, idselectionModifierType, idaddToSelection);
    var idmakeVisible = stringIDToTypeID("makeVisible");
    desc943.putBoolean(idmakeVisible, false);
    var idlayerID = stringIDToTypeID("layerID");
    var list100 = new ActionList();
    desc943.putList(idlayerID, list100);
    executeAction(idselect, desc943, DialogModes.NO);

    var idselect = stringIDToTypeID("select");
    var desc944 = new ActionDescriptor();
    var idnull = stringIDToTypeID("null");
    var ref274 = new ActionReference();
    var idlayer = stringIDToTypeID("layer");
    var idordinal = stringIDToTypeID("ordinal");
    var idbackwardEnum = stringIDToTypeID("backwardEnum");
    ref274.putEnumerated(idlayer, idordinal, idbackwardEnum);
    desc944.putReference(idnull, ref274);
    var idselectionModifier = stringIDToTypeID("selectionModifier");
    var idselectionModifierType = stringIDToTypeID("selectionModifierType");
    var idaddToSelection = stringIDToTypeID("addToSelection");
    desc944.putEnumerated(idselectionModifier, idselectionModifierType, idaddToSelection);
    var idmakeVisible = stringIDToTypeID("makeVisible");
    desc944.putBoolean(idmakeVisible, false);
    var idlayerID = stringIDToTypeID("layerID");
    var list101 = new ActionList();
    desc944.putList(idlayerID, list101);
    executeAction(idselect, desc944, DialogModes.NO);
}

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 18, 2022 Aug 18, 2022

Copy link to clipboard

Copied

Action runs great but the groups are open, and when ran again you get the same group Dodge & Burn inside the group. For the script version when ran a second time I get this error.

Error 1302: No such element Line: 19 -> app.activeDocument.activeLayer = app.activeDocument.artLayers["Dodge"];

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 18, 2022 Aug 18, 2022

Copy link to clipboard

Copied

I have commented out the code that expands the group.

 

@Madman1234 – I didn't expect the script to be run more than once. Why not simply dupe the result of the first run?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 18, 2022 Aug 18, 2022

Copy link to clipboard

Copied

I like to add more curves for intense results sometimes. I think i figured out the code by copying and pasting yours along with the other, but I can't figure out how to close the group on the Dodge layer, have any ideas? Here is the code.

if (app.documents.length > 0) {
var myDocument = app.activeDocument;
var theArray = getLayersIndexAndID (true);

var theCheck = false;
for (var x = 0; x < theArray.length; x++) {
if (theArray[x][0] == "Dodge & Burn") {
theCheck = true;
var theGroup = x
}
};

if (theCheck == false) {createLayer ("Dodge & Burn", "passthrough", true)
}
else {selectLayerByIndex(theArray[theGroup][1], false)};
addCurvesAdjustmentLayer("Dodge", "lighten");
deleteLayerMask();
curvePoints(0, 0, 26, 64, 64, 128, 128, 192, 192, 230, 255, 255);
makeGroupFromLayers("Dodge", 1, 2, "Dodge");
addLayerMask("hideAll");
};

function addCurvesAdjustmentLayer(layerName, blendMode) {
	function s2t(s) {
        return app.stringIDToTypeID(s);
    }
	var descriptor = new ActionDescriptor();
	var descriptor2 = new ActionDescriptor();
	var descriptor3 = new ActionDescriptor();
	var reference = new ActionReference();
	reference.putClass( s2t( "adjustmentLayer" ));
	descriptor.putReference( s2t( "null" ), reference );
	descriptor2.putString( s2t( "name" ), layerName );
	descriptor2.putEnumerated( s2t( "mode" ), s2t( "blendMode" ), s2t( blendMode ));
	descriptor3.putEnumerated( s2t( "presetKind" ), s2t( "presetKindType" ), s2t( "presetKindDefault" ));
	descriptor2.putObject( s2t( "type" ), s2t( "curves" ), descriptor3 );
	descriptor.putObject( s2t( "using" ), s2t( "adjustmentLayer" ), descriptor2 );
	executeAction( s2t( "make" ), descriptor, DialogModes.NO );
}

function deleteLayerMask() {
	function s2t(s) {
        return app.stringIDToTypeID(s);
    }
	var descriptor = new ActionDescriptor();
	var reference = new ActionReference();
	reference.putEnumerated( s2t( "channel" ), s2t( "ordinal" ), s2t( "targetEnum" ));
	descriptor.putReference( s2t( "null" ), reference );
	executeAction( s2t( "delete" ), descriptor, DialogModes.NO );
}

function curvePoints(horizontal, vertical, horizontal2, vertical2, horizontal3, vertical3, horizontal4, vertical4, horizontal5, vertical5, horizontal6, vertical6) {
	function s2t(s) {
        return app.stringIDToTypeID(s);
    }

	var descriptor = new ActionDescriptor();
	var descriptor2 = new ActionDescriptor();
	var descriptor3 = new ActionDescriptor();
	var descriptor4 = new ActionDescriptor();
	var descriptor5 = new ActionDescriptor();
	var descriptor6 = new ActionDescriptor();
	var descriptor7 = new ActionDescriptor();
	var descriptor8 = new ActionDescriptor();
	var descriptor9 = new ActionDescriptor();
	var list = new ActionList();
	var list2 = new ActionList();
	var reference = new ActionReference();
	var reference2 = new ActionReference();

	reference.putEnumerated( s2t( "adjustmentLayer" ), s2t( "ordinal" ), s2t( "targetEnum" ));
	descriptor.putReference( s2t( "null" ), reference );
	descriptor2.putEnumerated( s2t( "presetKind" ), s2t( "presetKindType" ), s2t( "presetKindCustom" ));
	reference2.putEnumerated( s2t( "channel" ), s2t( "channel" ), s2t( "composite" ));
	descriptor3.putReference( s2t( "channel" ), reference2 );
	descriptor4.putDouble( s2t( "horizontal" ), horizontal );
	descriptor4.putDouble( s2t( "vertical" ), vertical );
	list2.putObject( s2t( "paint" ), descriptor4 );
	descriptor5.putDouble( s2t( "horizontal" ), horizontal2 );
	descriptor5.putDouble( s2t( "vertical" ), vertical2 );
	list2.putObject( s2t( "paint" ), descriptor5 );
	descriptor6.putDouble( s2t( "horizontal" ), horizontal3 );
	descriptor6.putDouble( s2t( "vertical" ), vertical3 );
	list2.putObject( s2t( "paint" ), descriptor6 );
	descriptor7.putDouble( s2t( "horizontal" ), horizontal4 );
	descriptor7.putDouble( s2t( "vertical" ), vertical4 );
	list2.putObject( s2t( "paint" ), descriptor7 );
	descriptor8.putDouble( s2t( "horizontal" ), horizontal5 );
	descriptor8.putDouble( s2t( "vertical" ), vertical5 );
	list2.putObject( s2t( "paint" ), descriptor8 );
	descriptor9.putDouble( s2t( "horizontal" ), horizontal6 );
	descriptor9.putDouble( s2t( "vertical" ), vertical6 );
	list2.putObject( s2t( "paint" ), descriptor9 );
	descriptor3.putList( s2t( "curve" ), list2 );
	list.putObject( s2t( "curvesAdjustment" ), descriptor3 );
	descriptor2.putList( s2t( "adjustment" ), list );
	descriptor.putObject( s2t( "to" ), s2t( "curves" ), descriptor2 );
	executeAction( s2t( "set" ), descriptor, DialogModes.NO );
}

function makeGroupFromLayers(name2, layerSectionStart, layerSectionEnd, name3) {
	function s2t(s) {
        return app.stringIDToTypeID(s);
    }
	var descriptor = new ActionDescriptor();
	var descriptor2 = new ActionDescriptor();
	var reference = new ActionReference();
	var reference2 = new ActionReference();
	reference.putClass( s2t( "layerSection" ));
	descriptor.putReference( s2t( "null" ), reference );
	reference2.putEnumerated( s2t( "layer" ), s2t( "ordinal" ), s2t( "targetEnum" ));
	descriptor.putReference( s2t( "from" ), reference2 );
	descriptor2.putString( s2t( "name" ), name2 );
	descriptor.putObject( s2t( "using" ), s2t( "layerSection" ), descriptor2 );
	descriptor.putInteger( s2t( "layerSectionStart" ), layerSectionStart );
	descriptor.putInteger( s2t( "layerSectionEnd" ), layerSectionEnd );
	descriptor.putString( s2t( "name" ), name3 );
	executeAction( s2t( "make" ), descriptor, DialogModes.NO );
}

function addLayerMask(maskType) {
	function s2t(s) {
        return app.stringIDToTypeID(s);
    }

	var descriptor = new ActionDescriptor();
	var reference = new ActionReference();

	descriptor.putClass( s2t( "new" ), s2t( "channel" ));
	reference.putEnumerated( s2t( "channel" ), s2t( "channel" ), s2t( "mask" ));
	descriptor.putReference( s2t( "at" ), reference );
	descriptor.putEnumerated( s2t( "using" ), s2t( "userMaskEnabled" ), s2t( maskType ));
	executeAction( s2t( "make" ), descriptor, DialogModes.NO );
}


function getLayersIndexAndID (groups) {
	var ref = new ActionReference();
	ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt")); 
	var applicationDesc = executeActionGet(ref);
	var theNumber = applicationDesc.getInteger(stringIDToTypeID("numberOfLayers"));
	var aNumber = 0;
	var theArray = new Array;
	var theGroups = new Array;
	for (var m = theNumber; m >= 0; m--) {
	try {
	var ref = new ActionReference();
	ref.putIndex( charIDToTypeID( "Lyr " ), m);
	var layerDesc = executeActionGet(ref);
	var layerSet = typeIDToStringID(layerDesc.getEnumerationValue(stringIDToTypeID("layerSection")));
	var isBackground = layerDesc.getBoolean(stringIDToTypeID("background"));
	var theName = layerDesc.getString(stringIDToTypeID('name'));
	var theID = layerDesc.getInteger(stringIDToTypeID('layerID'));
	if (layerSet == "layerSectionStart" && isBackground != true) {
	if (aNumber == 0) {var setArray = [[theName, m]]
    }
	else {
	var thisArray = [[theName, m, theID]];
	for (var o = setArray.length - 1; o >= 0; o--) {thisArray.push(setArray[o])
    }
	theArray.push(thisArray)
	setArray.push([theName, m, theID])
    }
	theGroups.push([theName, m, theID]);
	aNumber++
    }
	if (layerSet == "layerSectionEnd" && isBackground != true) {
	aNumber--;
	if (aNumber == 0) {var setArray = []
    }
	else {setArray.pop()}
    }
	if (layerSet != "layerSectionEnd" && layerSet != "layerSectionStart") {
	if (aNumber == 0) {theArray.push([[theName, m, theID, "document"]])
    }
	else {
	var thisArray = [[theName, m, theID]];
	for (var o = setArray.length - 1; o >= 0; o--) {thisArray.push(setArray[o])};
	theArray.push(thisArray)
    }
    }
}
catch (e) {};
}

if (groups == true) {return theGroups};
return theArray
}

function createLayer (theName, blendMode, group) {
	if (group == false) {var idlayer = stringIDToTypeID( "layer" )}
	else {
	var idlayer = stringIDToTypeID( "layerSection" )};
	var desc2 = new ActionDescriptor();
	var ref1 = new ActionReference();
	ref1.putClass( idlayer );
	desc2.putReference( stringIDToTypeID( "null" ), ref1 );
	var desc3 = new ActionDescriptor();
	desc3.putString( stringIDToTypeID( "name" ), theName );
	desc3.putEnumerated( stringIDToTypeID( "mode" ), stringIDToTypeID( "blendMode" ), stringIDToTypeID( blendMode ) );
	desc2.putObject( stringIDToTypeID( "using" ), idlayer, desc3 );
	executeAction( stringIDToTypeID( "make" ), desc2, DialogModes.NO );
}

function selectLayerByIndex(index,add) { 
	add = undefined ? add = false:add 
	var ref = new ActionReference();
	ref.putIndex(charIDToTypeID("Lyr "), index);
	var desc = new ActionDescriptor();
	desc.putReference(charIDToTypeID("null"), ref );
	if(add) desc.putEnumerated( stringIDToTypeID( "selectionModifier" ), stringIDToTypeID( "selectionModifierType" ), stringIDToTypeID( "addToSelection" ) ); 
	desc.putBoolean( charIDToTypeID( "MkVs" ), false ); 
	try {
	executeAction(charIDToTypeID("slct"), desc, DialogModes.NO );
    }

catch(e) {
alert(e.message); 
    }
};

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 18, 2022 Aug 18, 2022

Copy link to clipboard

Copied

You can easily collapse all groups... Or, if you create the group from the layers, the group is collapsed (in other words, create the groups last, not first).

 

Otherwise, it requires a hack to only collapse the selected group.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 18, 2022 Aug 18, 2022

Copy link to clipboard

Copied

I finally managed to code them, I had to add another adjustment layer to be able to close the group when created, sadly the group doesn't close with just one layer. Thanks for the help, your code and the way it was separated and named really helped. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 18, 2022 Aug 18, 2022

Copy link to clipboard

Copied

You're welcome. I still think of myself as a beginner in scripting, it's just a hobby... so I haven't forgotten how helpful it is to comment and structure my code for other newbs!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 18, 2022 Aug 18, 2022

Copy link to clipboard

Copied

I'm learning I can use Script Listener for parts of the code, I just need to learn functions 😊

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 18, 2022 Aug 18, 2022

Copy link to clipboard

Copied

LATEST

@Madman1234 wrote:

I'm learning I can use Script Listener for parts of the code, I just need to learn functions 😊


 

Yeah, that was a milestone for me...

 

// call the function by name
myFunctionName();

function myFunctionName() {
// recorded SL code pasted here
}

 

The next step is then swapping out hard-coded values for variables and putting these as parameters into the function.

 

https://gist.github.com/MarshySwamp/8d94e12597fe101451a5412bf8f3510f

 

The Clean SL script can also auto-create a function and shorten and make the code somewhat more legible:

 

https://github.com/rendertom/Clean-SL

 

https://community.adobe.com/t5/photoshop-ecosystem-discussions/clean-sl/td-p/9358420

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines