- PDB Name:
- sg-isolate.scm (after the page appears, click on the "Download" command)
- If there is a selection, running this script will result in the contents of the current drawable being deleted everywhere except within the selection. This is basically a convenient substitute for the sequence Select->Invert, Edit->Clear, Select->Invert except that layers without an alpha channel will have one added (resulting in transparency rather than background fill).
In addition, if the currently active drawable is a layermask or a channel, the mask or channel is filled with a grayscale copy of the current selection.
I find using this function after duplicating a layer is often preferable to floating a selection or doing a copy/paste. Floating a selection removes the content from the original layer and can sometimes re-position the copied region. Both floating and copying result in the new layer being placed at the top of the layerstack (whereas duplicating a layer places it directly above the original). Using "Edit->Paste As->New Layer" positions the new layer above the original in the layerstack, but also relocates the new layer to the upper-left corner of the image (which is likewise not often desirable).