<dt><b>PDB Name:</b> <dd>script-fu-sg-isolate</dd></dt>
<dt><b>Download:</b> <dd>[http://chiselapp.com/user/saulgoode/repository/script-fu/artifact/44019253cbb72ae74415b72a81700f9bfdd0da7f|sg-isolate.scm] (after the page appears, click on the "Download" command)</dd></dt>
<dt><b>Description:</b> <dd>If there is a selection, running this script will result in the contents of the current drawable being deleted everywhere <i>except</i> 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).</dd></dt>