What are batchPlay options to create a layer without mask? Currently I’m creating a group and a solid color layer in that group.
[
{
"_obj": "make",
"_target": [
{"_ref": "layerSection"}
],
"using": {
"_obj": "layerSection",
"name": name
}
},
{
"_obj": "make",
"_target": [
{"_ref": "contentLayer"}
],
"using": {
"_obj": "contentLayer",
"type": {
"_obj": "solidColorLayer",
"color": {
"_obj": "RGBColor",
"red": 128,
"grain": 128,
"blue": 128
}
}
}
}
]
What should I add to skip the solid color layer mask (if possible)?
Bonus question: How do I specifically define in which group (by name) to create that layer?
AKAIK, you can’t avoid the mask creation.
However, you can remove it after it gets created:
const batchPlay = require("photoshop").action.batchPlay;
const name = "Group A";
await batchPlay(
[{
"_obj": "make",
"_target": [{
"_ref": "layerSection"
}],
"using": {
"_obj": "layerSection",
"name": name
}
},
{
"_obj": "make",
"_target": [{
"_ref": "contentLayer"
}],
"using": {
"_obj": "contentLayer",
"name": "Solid Color",
"type": {
"_obj": "solidColorLayer",
"color": {
"_obj": "RGBColor",
"red": 128,
"grain": 128,
"blue": 128
}
}
}
},
{
"_obj": "select",
"_target": [{
"_ref": "layer",
"_name": "Solid Color"
}]
},
{
"_obj": "delete",
"_target": [{
"_ref": "channel",
"_enum": "channel",
"_value": "mask"
}]
}
], {});
Further, to select the group “Group A”
{
"_obj": "select",
"_target": [{
"_ref": "layer",
"_name": "GROUP A"
}],
}
Possibly not the most elegant way but it works
Not really a scriptable solution, but you can turn off this default mask in the layer panel options:
That’s what I was thinking. Just wanted to make sure I’m not missing something
Yep, I know I can select that group, but was wondering if I can specify that group when creating a layer. Currently it works as expected and layer is created in a group, that was created right before, but I would like to not rely on selections, but rather define the specific group myself. I’ll need to create multiple different layers in that group.
I guess I’ll just have to delete the mask after layer is created Can’t really tell users to disable the option
Thank you both for the answers
In this case, be aware that your batchPlay call might break because of this option. If you try to delete a mask which doesn’t exist, this will give an error. You could check if the mask exists beforehand, of course.
Aha… Good to know, @simonhenke. Any idea how to check this beforehand? Can’t get it to show with Alchemist I mean the option in layers panel, so that I could exclude the mask deletion action. I’d like to keep all the group/layers creation under one history state, but if I try to check the mask after layer is created and then delete the mask or not, it’s another batchPlay call I guess, right?
Yep, I think it’s impossible to read out such “UI options”.
Correct. I also faced this problem multiple times already, but the Adobe devs are already working on providing a mechanism to group together multiple separate batchPlay stacks in one history state, similar to how we used to do it with CEP.
However, a workaround could be to create an adjustment layer, check if the mask exists and then delete the history step. This should result in just one history step once your function finishes.
1 Like
Would be great to get this ASAP
Did not think of that Thanks, will try to implement