Skip to main content
Known Participant
April 1, 2023
Question

Changing masks in multiple groups to single colour.

  • April 1, 2023
  • 3 replies
  • 1183 views

Hi,

 

I use mock-ups for artwork and to save time I have nestled 10 mock-ups into a single file as groups and use linked smart object so I can just change the artwork once and export 10 mocked up files quickly. What I'd like to do if possible is change the colour of masks I've made in each group (of cushions, blankets, vases etc) to match said artwork. I know how to do an individual mask in a single group. I select cushions, create colour layer mask, change it to colour and that's fine for what I need. What I'd like to do is the above process but when I change colour I'd like it to apply said colour to all 10 masks in 10 groups without going into the other 9 groups manually. 

 

Is this possible? 

Many thanks 

This topic has been closed for replies.

3 replies

Stephen Marsh
Community Expert
Community Expert
April 1, 2023

@inter247 – So, in each top-level group (named Group 1, Group 2, to Group 10), inside the group named "Cushion Blanket Colour", change the colour of the colour fill layer (Color Fill 7, Color Fill 8 etc) from brown to something else. Is that correct?

inter247Author
Known Participant
April 1, 2023

That's right - I don't want to do them all individually though. I understand I have some initial adjustments to make to get it to work how I want. I have just changed to smart object as suggested and it's working to a degree but I have different shades of chosen colour across the groups

Stephen Marsh
Community Expert
Community Expert
April 1, 2023

Based on your original test file, I have a working script... However, it stops when it hits a top-level group that doesn't contain the required sub-group and colour fill (i.e. Group 3). If you remove Group 3 or move it to the bottom of the top-level layer stack, then all other top-level layer groups will be processed correctly. I don't have time at the moment to make it skip over groups that don't meet the required conditions, but perhaps somebody else could modify the code or post an alternative script.

 

// Set the layer groups variable
var theLayerSets = activeDocument.layerSets;
// Forward loop over the layer groups
for (var i = 0; i < theLayerSets.length; i++) {
    // Check if the layer is a group and a top level group
    if (theLayerSets[i].typename === "LayerSet" && theLayerSets[i].parent == activeDocument) {
        // Select the top layer in the "Cushion Blanket Colour" group
        activeDocument.activeLayer = theLayerSets[i].layers["Cushion Blanket Colour"].layers[0];
        // Change the colour fill
        setColorFill(0, 0, 255);
    }
}

function setColorFill(red, grain, blue) {
	function s2t(s) {
        return app.stringIDToTypeID(s);
    }
	var descriptor = new ActionDescriptor();
	var descriptor2 = new ActionDescriptor();
	var descriptor3 = new ActionDescriptor();
	var reference = new ActionReference();
	reference.putEnumerated( s2t( "contentLayer" ), s2t( "ordinal" ), s2t( "targetEnum" ));
	descriptor.putReference( s2t( "null" ), reference );
	descriptor3.putDouble( s2t( "red" ), red );
	descriptor3.putDouble( s2t( "grain" ), grain );
	descriptor3.putDouble( s2t( "blue" ), blue );
	descriptor2.putObject( s2t( "color" ), s2t( "RGBColor" ), descriptor3 );
	descriptor.putObject( s2t( "to" ), s2t( "solidColorLayer" ), descriptor2 );
	executeAction( s2t( "set" ), descriptor, DialogModes.NO );
}

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

 

PECourtejoie
Community Expert
Community Expert
April 1, 2023

What if the masked color fill was in a smart object?

inter247Author
Known Participant
April 1, 2023

That works thanks - I created a smart object in group 1 then pasted to each group with releveant mask over it and now I just have to change colour in group 1. I'm getting a different shade of chosen colour across all the images but I guess that is down to the original selection colour (cushion, blanket etc). Ideally I select 83927d for example and it looks perfect across all the masks. Is that down to original colour of the selection? I've probably not explained it very well but the attachement shows what I mean.

 

Thank for your reply

Stephen Marsh
Community Expert
Community Expert
April 1, 2023

@inter247 – Can you post the layered PSD file? You can reduce the resolution if you like, this is more about the layer structure than anything. A cropped screenshot of the layers panel would also be helpful.

inter247Author
Known Participant
April 1, 2023

Thanks for the help - I have reduced resolution and attached.