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

Deleting selection on layer

Participant ,
Oct 01, 2022 Oct 01, 2022

Copy link to clipboard

Copied

Hi, all! Using DOM scripting, I'm trying to delete the contents of a selection on the active layer, in the same way I can delete a selection pressing the backspace or delete button on my keyboard, basically punching a hole in the layer, revealing the layer underneath. I've tried using

app.activeDocument.selection.clear();

or

app.activeDocument.selection.cut();

 but nothing gets deleted from the selection. What on earth am I missunderstanding here?

TOPICS
Actions and scripting

Views

56

Likes

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 ,
Oct 01, 2022 Oct 01, 2022

Copy link to clipboard

Copied

I'm not in front of a computer, but I think you need to add activeLayer. in there.

Likes

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
Participant ,
Oct 01, 2022 Oct 01, 2022

Copy link to clipboard

Copied

You mean like this?

app.activeDocument.activeLayer.selection.clear();

This doesnt seem to work, I'm afraid. I just get an error statis that "app.activeDocument.activeLayer.selection.clear();" isn't an object.

Likes

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 ,
Oct 01, 2022 Oct 01, 2022

Copy link to clipboard

Copied

I'm home now, this works with a selection on a layer ( not Background )

 

activeDocument.selection.clear();

 

Which you have already tried without success... You don't have a layer lock on do you?

 

What do you get with the AM equivalent:

 

var iddelete = stringIDToTypeID( "delete" );
executeAction( iddelete, undefined, DialogModes.NO );

Likes

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
Participant ,
Oct 01, 2022 Oct 01, 2022

Copy link to clipboard

Copied

LATEST

That is very weird! No, no layer lock as far as I can tell. For now, I resorted to setting the blend mode of the layer to SCREEN and then fill the selection I wanted to clear with black. It sort of gets me there.

Likes

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