Skip to main content
Inspiring
October 1, 2022
Question

Deleting selection on layer

  • October 1, 2022
  • 1 reply
  • 384 views

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?

This topic has been closed for replies.

1 reply

Stephen Marsh
Community Expert
Community Expert
October 1, 2022

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

hertzeAuthor
Inspiring
October 1, 2022

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.

Stephen Marsh
Community Expert
Community Expert
October 1, 2022

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 );