• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Removal of Groups with black masks

Participant ,
Jul 04, 2021 Jul 04, 2021

Copy link to clipboard

Copied

You guys are awesome! I will update to this script, just to make sure.

I feel like I ask too much right now, but is it possible to include removal of Groups with black mask?

I hope it isn't a pain in the a**.

 

Capture.JPG

TOPICS
Actions and scripting

Views

365

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 2 Correct answers

People's Champ , Jul 04, 2021 Jul 04, 2021

 

 

 

 

// important, the active layer does not to be a group itself (active group mask allowed). This is due to a bug that cannot be fixed so far. Someone at Adobe decided that calculations and applyimage command should not be available in such a situation. Morons ... 


var inv = false; // depends on channels settings. true = masked areas, false = selected areas. check what you have when manually adding new alpha channel.


var r = new ActionReference();
r.putProperty(stringIDToTypeID("propert
...

Votes

Translate

Translate
LEGEND , Jul 04, 2021 Jul 04, 2021

 

sTT = stringIDToTypeID; (function(v) {
	var lrs = [].slice.call(v); while(lrs.length) {
		(ref = new ActionReference()).putIdentifier
		(sTT('layer'), id = (theCurrentLayerSet = lrs.shift()).id);
		((dsc = executeActionGet(ref)).getBoolean(sTT('hasUserMask')) &&
		(ref.putIdentifier(sTT('layer'), id), dsc.putReference(sTT('null'), ref),
		executeAction(sTT('select'), dsc)) && ((ref1 = new ActionReference())
		.putProperty(channel = sTT('channel'), selection = sTT('selection')),
		dsc.putRefere
...

Votes

Translate

Translate
Adobe
People's Champ ,
Jul 04, 2021 Jul 04, 2021

Copy link to clipboard

Copied

 

 

 

 

// important, the active layer does not to be a group itself (active group mask allowed). This is due to a bug that cannot be fixed so far. Someone at Adobe decided that calculations and applyimage command should not be available in such a situation. Morons ... 


var inv = false; // depends on channels settings. true = masked areas, false = selected areas. check what you have when manually adding new alpha channel.


var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("count"));
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
var count = executeActionGet(r).getInteger(stringIDToTypeID("count"));


var n = 0; 
try { app.activeDocument.backgroundLayer; } catch(e) { n = 1; ++count; }


var r_idx = new ActionReference();
var do_it = false;

for (var i = count-1; i >= n; i--)
    {
    var r = new ActionReference();
    r.putIndex(stringIDToTypeID("layer"), i);
    if (executeActionGet(r).getInteger(stringIDToTypeID("layerKind")) != 7) continue; 

    var d = new ActionDescriptor();
    var r = new ActionReference();
    r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
    d.putReference(stringIDToTypeID("null"), r);
    var d1 = new ActionDescriptor();
    var r1 = new ActionReference();
    r1.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask"));
    r1.putIndex(stringIDToTypeID("layer"), i);
    d1.putBoolean(stringIDToTypeID("invert"), inv);
    d1.putReference(stringIDToTypeID("to"), r1);
    d1.putEnumerated(stringIDToTypeID("calculation"), stringIDToTypeID("calculationType"), stringIDToTypeID("normal"));
    var r2 = new ActionReference();
    r2.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask"));
    r2.putIndex(stringIDToTypeID("layer"), i);
    d1.putReference(stringIDToTypeID("source2"), r2);
    d1.putBoolean(stringIDToTypeID("invertSource2"), inv);
    d.putObject(stringIDToTypeID("to"), stringIDToTypeID("calculation"), d1);
    executeAction(stringIDToTypeID("set"), d, DialogModes.NO);


    var r = new ActionReference();
    r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("selection"));
    r.putEnumerated(stringIDToTypeID("document"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));

    if (!executeActionGet(r).hasKey(stringIDToTypeID("selection")))  { r_idx.putIndex(stringIDToTypeID("layer"), i); do_it = true; }
    }

app.activeDocument.selection.deselect();

if (do_it)
    {
    var d = new ActionDescriptor();
    d.putReference(stringIDToTypeID("null"), r_idx);
    executeAction(stringIDToTypeID("delete"), d, DialogModes.NO);
    }

alert("done");

 

 

upd.

changed comments

Votes

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
LEGEND ,
Jul 04, 2021 Jul 04, 2021

Copy link to clipboard

Copied

 

sTT = stringIDToTypeID; (function(v) {
	var lrs = [].slice.call(v); while(lrs.length) {
		(ref = new ActionReference()).putIdentifier
		(sTT('layer'), id = (theCurrentLayerSet = lrs.shift()).id);
		((dsc = executeActionGet(ref)).getBoolean(sTT('hasUserMask')) &&
		(ref.putIdentifier(sTT('layer'), id), dsc.putReference(sTT('null'), ref),
		executeAction(sTT('select'), dsc)) && ((ref1 = new ActionReference())
		.putProperty(channel = sTT('channel'), selection = sTT('selection')),
		dsc.putReference(sTT('null'), ref1), (ref2 = new ActionReference())
		.putEnumerated(channel, channel, sTT('mask')),
		dsc.putReference(sTT('to'), ref2),
		executeAction(sTT('set'), dsc))

		&& ((ref = new ActionReference()).putProperty(sTT('property'), selection),
		ref.putEnumerated(sTT('document'), sTT('ordinal'), sTT('targetEnum')),
		!executeActionGet(ref).hasKey(selection)) && ((ref = new ActionReference())
		.putIdentifier(sTT('layer'), id), dsc.putReference(sTT('null'), ref),
		executeAction(sTT('delete'), dsc)) && true)
		|| callee(theCurrentLayerSet.layerSets)
	}
	aD.selection.deselect()
})((aD = activeDocument).layerSets)

 

What about the other script I wrote. It does what you described in starting post. Did you try it:
Help with script that select Layers based on string then move selected layers to specific folder.

Votes

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
People's Champ ,
Jul 04, 2021 Jul 04, 2021

Copy link to clipboard

Copied

Kukurykus

Removes all masks in groups. It is right?

Votes

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
LEGEND ,
Jul 04, 2021 Jul 04, 2021

Copy link to clipboard

Copied

I noticed it myself and corrected the script meantime 😉

Votes

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
People's Champ ,
Jul 04, 2021 Jul 04, 2021

Copy link to clipboard

Copied

Now removes black masks. Is that what the author asked for?

Votes

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
LEGEND ,
Jul 04, 2021 Jul 04, 2021

Copy link to clipboard

Copied

Right - I understood he wants black masks from groups.

Actually I forgot during writing what was the gaol 😕 loll

I edited a little the script and now it does what it should 🙂

Votes

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
Participant ,
Jul 05, 2021 Jul 05, 2021

Copy link to clipboard

Copied

LATEST

Thank you for you commitment!

Votes

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