Chris, I think I overlooked this question last year! It isn't very hard to script — or, maybe, the basic functionality is not. I ran into some problems when trying it on a line containing a figure, because in that case the 'baseline' — the bottom of the 'figure' line — is not what you expect. Anyway, the script automatically selects the newly created frame, so you can move it right away to a better position.
By way of bonus: the first line defines the name of the object style to be applied to this new frame. If you don't want to use this, delete the first line and the one that applies it (the 2nd line from the bottom). If your selected text ends in a hard return, it automatically deletes this, as usually you don't want that inside a text frame.
//DESCRIPTION:Create a frame from a text selection
// A Jongware script 19-Feb-2013
app.doScript(function() {
objectStyle = “Figure”;
if (app.selection.length == 1 && app.selection[0].hasOwnProperty(“baseline”) && app.selection[0].length > 0)
{
frame = app.selection[0].parentTextFrames[0].duplicate();
frame.texts[0].remove();
frame.move (undefined, [0, app.selection[0].characters[0].baseline- app.selection[0].parentTextFrames[0].characters[0].baseline]);
app.selection[0].move(LocationOptions.AT_BEGINNING, frame.texts[0]);
while (frame.texts[0].characters[-1].contents == 'r')
frame.texts[0].characters[-1].remove();
frame.fit (FitOptions.FRAME_TO_CONTENT);
frame.applyObjectStyle(app.activeDocument.objectStyles.item(objectStyle));
frame.select();
}
}, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, “Frame from Selection”);