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

Removal of Groups with black masks

Participant ,
Jul 04, 2021 Jul 04, 2021

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
959
Translate
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
...
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
...
Translate
Adobe
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("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

Translate
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

 

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.

Translate
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

Kukurykus

Removes all masks in groups. It is right?

Translate
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

I noticed it myself and corrected the script meantime 😉

Translate
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
Now removes black masks. Is that what the author asked for?
Translate
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

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 🙂

Translate
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
LATEST

Thank you for you commitment!

Translate
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