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

Change 'layer via cut' behavior to keep original layer selected

Community Beginner ,
Mar 13, 2020 Mar 13, 2020

Copy link to clipboard

Copied

After using 'layer via cut', PS automatically selects the new layer. I would like PS to keep the original layer selected, as I often need to cut tens (for my present project often over a hundred) of layers from it. Is it possible to change this behavior?
(It's very annoying, having to select the original layer after each cut, especially after about 20 layers, when it drops below the screen in the layers window.)

Views

1.3K

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

Community Expert , Mar 14, 2020 Mar 14, 2020
Community Expert , Mar 14, 2020 Mar 14, 2020

Back to the original topic, the two-step action that can be recorded to automate the Layer > New > Layer via Cut and then selecting the relative backwards/previous layer:

 

Screen Shot 2020-03-14 at 20.53.07.png

 

OPT/ALT [

 

Is the relative keyboard shortcut to select the previous/background layer (left square bracket), as one does not wish to record an absolute or explicit layer name into the action.

 

This action can have a function keyboard shortcut applied in the action panel. Or you can reference the action in a script, which

...

Votes

Translate

Translate
Valorous Hero ,
Mar 13, 2020 Mar 13, 2020

Copy link to clipboard

Copied

script or action?

 

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
Community Expert ,
Mar 13, 2020 Mar 13, 2020

Copy link to clipboard

Copied

I agree with r-bin that custom automation is the key as it is not possible to change the behaviour.

 

Can you show or describe your layer content? There is a script to split isolated objects on a transparent background for example.

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
Community Beginner ,
Mar 14, 2020 Mar 14, 2020

Copy link to clipboard

Copied

Thank you, r-bin and Stephen! 
My situation: I photograph, say, 20 screws on a white background. In PS I strip the white backgrond, so then I'm left with 20 'islands of screws' and each island must become a separate layer.
Stephen, it sounds like the script you mention does exactly what I need. Frankly, I didn't dare think such a thing was possible! Can you point me to that script? It sounds like it will save me lots of work in the future. 

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
Community Expert ,
Mar 14, 2020 Mar 14, 2020

Copy link to clipboard

Copied

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
Community Beginner ,
Mar 14, 2020 Mar 14, 2020

Copy link to clipboard

Copied

Thank you so much, Stephen. I'm forever in your debt! The script works like a charm. This will make my life sooo much easier. 🙂

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
Community Expert ,
Mar 14, 2020 Mar 14, 2020

Copy link to clipboard

Copied

Back to the original topic, the two-step action that can be recorded to automate the Layer > New > Layer via Cut and then selecting the relative backwards/previous layer:

 

Screen Shot 2020-03-14 at 20.53.07.png

 

OPT/ALT [

 

Is the relative keyboard shortcut to select the previous/background layer (left square bracket), as one does not wish to record an absolute or explicit layer name into the action.

 

This action can have a function keyboard shortcut applied in the action panel. Or you can reference the action in a script, which gives one more flexibility in selecting a keyboard shortcut.

 

https://prepression.blogspot.com/2016/11/photoshop-scripting-actions.html

 

While purely scripted solution could be written as follows:

 

 

 

cutToLayer();

function cutToLayer() {
	var s2t = function (s) {
		return app.stringIDToTypeID(s);
	};


	executeAction(s2t("cutToLayer"), undefined, DialogModes.NO);
}

select(false);

function select(makeVisible) {
	var c2t = function (s) {
		return app.charIDToTypeID(s);
	};

	var s2t = function (s) {
		return app.stringIDToTypeID(s);
	};

	var descriptor = new ActionDescriptor();
	var list = new ActionList();
	var reference = new ActionReference();

	reference.putEnumerated(s2t("layer"), s2t("ordinal"), s2t("backwardEnum"));
	descriptor.putReference(c2t("null"), reference);
	descriptor.putBoolean(s2t("makeVisible"), makeVisible);
	list.putInteger(8);
	descriptor.putList(s2t("layerID"), list);
	executeAction(s2t("select"), descriptor, DialogModes.NO);
}

 

 

 

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
Community Beginner ,
Mar 14, 2020 Mar 14, 2020

Copy link to clipboard

Copied

Stephen, thank you for this added solution and your explanation. But the script you referred to earlier already does exactly what I want. Which was far more than I asked for, but somehow you seem to have read my mind and provided a much better solution than I asked for. Once again, thanks you ever so much!

 

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
Community Expert ,
Mar 14, 2020 Mar 14, 2020

Copy link to clipboard

Copied

My pleasure, although I thought that the split script may be what you were looking for, I added the action and script for completeness, just in case somebody else wanted to do what you originally requested. It is not so much reading your mind, but reading in-between the words.

 

Now it may even be possible to apply the script that I posted previously to loop/iterate over all visible layers... But that is beyond my current beginner scripting level.

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
Community Beginner ,
Mar 14, 2020 Mar 14, 2020

Copy link to clipboard

Copied

Your beginner level is way beyond my non-existent level. 🙂 I have marked both your answers as correct, in vase others ar elooking for a solution to my original question.

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
Community Expert ,
Mar 14, 2020 Mar 14, 2020

Copy link to clipboard

Copied

I know that you are happy with the current solution, however, there is still room for further automation if desired. Thinking through your workflow, another option could be to use the export > layers to files option if you have a multi layer file. Then you could then bulk process each separate file with the split script. Somewhere in the process if you have separate screws on a large transparent layer you can use the trim command to auto crop away the transparent pixels. Anyway, glad you are happy!

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
Engaged ,
Apr 29, 2023 Apr 29, 2023

Copy link to clipboard

Copied

LATEST

Great Script!
I was not able to download it as it appears corrupted, but copied and pasted your code into a jsx and it works!
If I would want to add an option  it would be to hide extracted layer, so  the original layer with what has been cut,  is visible at once , when chopping multiple elements from a layer without  having to go to layers panel and hide it.

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