Copy link to clipboard
Copied
Allah to all the angels progamators! How do I add a mask in all groups based on the reference to the selection of layers of shapes that are within their respective groups? Thank you.
...function sTT(v) {return stringIDToTypeID(v)}
(ref = new ActionReference()).putEnumerated
(sTT('document'), sTT('ordinal'), sTT('targetEnum'))
nOL = executeActionGet(ref).getInteger(sTT('numberOfLayers'))
bGL = !executeActionGet(ref).getInteger(sTT('hasBackgroundLayer'))
for(i = nOL - bGL; i >= 0; i--) {
function ttS(v) {return typeIDToStringID(v) == lS + 'Start'}
(ref = new ActionReference()).putIndex(sTT('layer'), idx1 = i + bGL)
if (ttS(executeActionGet(ref).getEnumerationValue(sTT(lS =
Copy link to clipboard
Copied
Shapes layers have a vector layer mask that is only depicted in the layers palette by the little shape icon in the layer's content thumbnail. You can easily edit this mask with Photoshop vector tools. Why do you need to create a group for each of your shape layer and add a grayscale layer mask like the shape layers transparency to the group that has a single shape layer? I don't get it??? You can just as easly added that raster layer masks as an additional layer mask on the shape layer. Why is it even needed? Why is a group needed?
If there are mote than one shape layer in the group you most like could load the groups transparency as a selection and add it to the group as a layer mask. The Group could also be used as a clipping mask I believe
Copy link to clipboard
Copied
It is necessary to automate a very repeatable possession. I'm working on several documents that have numerous photos in the form of composition, and some photos will have different patterns ....
The shape layers are just the reference, it makes me more comfortable to add groups with their respective masks.
Copy link to clipboard
Copied
Do you want to duplicate the mask from the current LayerSet to others?
Copy link to clipboard
Copied
The objective would be:
check if there is one or more LayerSet in the document.
If this is true, add a mask in each group layer having as the selection reference the same dimensions of the layer within the respective group.
Irrespective of whether the layer is oval, round, rectangular or square
Copy link to clipboard
Copied
Maybe this is it
if (activeDocument.activeLayer.typename == "LayerSet")
{
var ok = true;
try {
var d = new ActionDescriptor();
var r = new ActionReference();
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask"));
d.putReference(stringIDToTypeID("null"), r);
d.putBoolean(stringIDToTypeID("makeVisible"), false);
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
}
catch(e) { ok = false; alert("No Mask"); }
if (ok) for (var i = 0; i < activeDocument.layerSets.length; i++)
{
try {
if (activeDocument.layerSets == activeDocument.activeLayer) continue;
var d = new ActionDescriptor();
var r = new ActionReference();
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask"));
r.putIdentifier(stringIDToTypeID("layer"), activeDocument.layerSets.id);
d.putReference(stringIDToTypeID("null"), r);
try { executeAction(stringIDToTypeID("delete"), d, DialogModes.NO); } catch(e) {}
var d = new ActionDescriptor();
d.putClass(stringIDToTypeID("new"), stringIDToTypeID("channel"));
var r = new ActionReference();
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask"));
r.putIdentifier(stringIDToTypeID("layer"), activeDocument.layerSets.id);
d.putReference(stringIDToTypeID("at"), r);
var r1 = new ActionReference();
r1.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask"));
r.putIdentifier(stringIDToTypeID("layer"), activeDocument.activeLayer.id);
d.putReference(stringIDToTypeID("using"), r1);
d.putBoolean(stringIDToTypeID("duplicate"), true);
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
}
catch (e) { alert(e); break; }
}
}
else
{
alert("Not a LayerSet");
}
Copy link to clipboard
Copied
Very good r-bin! This way is great, from this stage I can continue my project!
Just one detail: If you have groups, and there is no mask applied please apply to all groups. Thank you very much for the support, you are very kind.
Copy link to clipboard
Copied
function sTT(v) {return stringIDToTypeID(v)}
(ref = new ActionReference()).putEnumerated
(sTT('document'), sTT('ordinal'), sTT('targetEnum'))
nOL = executeActionGet(ref).getInteger(sTT('numberOfLayers'))
bGL = !executeActionGet(ref).getInteger(sTT('hasBackgroundLayer'))
for(i = nOL - bGL; i >= 0; i--) {
function ttS(v) {return typeIDToStringID(v) == lS + 'Start'}
(ref = new ActionReference()).putIndex(sTT('layer'), idx1 = i + bGL)
if (ttS(executeActionGet(ref).getEnumerationValue(sTT(lS = 'layerSection')))) {
(ref = new ActionReference()).putIndex(sTT('layer'), idx2 = i - 1 + bGL)
if (executeActionGet(ref).getInteger(sTT(lS = 'layerKind')) == 4) {
(ref1 = new ActionReference()).putProperty(sTT('channel'), sTT('selection'));
(dsc1 = new ActionDescriptor()).putReference(sTT('null'), ref1);
(ref2 = new ActionReference()).putEnumerated(sTT('path'), sTT('path'), sTT('vectorMask'))
ref2.putIndex(sTT('layer'), idx2), dsc1.putReference(sTT('to'), ref2), executeAction(sTT('set'), dsc1);
(ref = new ActionReference()).putIndex(sTT('layer'), idx1);
(dsc = new ActionDescriptor()).putReference(sTT('null'), ref)
dsc.putBoolean(sTT('makeVisible'), false);
executeAction(sTT('select'), dsc);
(dsc = new ActionDescriptor())
.putClass(sTT('new'), sTT('channel'));
(ref = new ActionReference()).putEnumerated
(sTT('channel'), sTT('channel'), sTT('mask'))
dsc.putReference(sTT('at'), ref), dsc.putEnumerated
(sTT('using'), sTT('userMaskEnabled'), sTT('revealSelection'))
executeAction(sTT('make'), dsc)
}
}
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
That was strictly refered to your goal, so it is going to fail if some folder that already contained a shape layer got some mask or else shape layer wasn't first in a row (so top one) in certain folder. That can be easily changed so script can handle it too.
Copy link to clipboard
Copied
I will adhere to the final result! Beautiful work thank you
Find more inspiration, events, and resources on the new Adobe Community
Explore Now