It prints the selection all right. Why then save wouldn't save it:
def bk_saves_unique_pdb(Selection = None):
"""Takes current selection (or "all" -- if nothing selected) and
saves it as a uniquetly named pdb file
(Frame_Selection_RandomString.pdb) in the current working
if not Selection:
Selection = cmd.get_names('selections', 1)
Selection = Selection # it was a list
Selection = 'all'
tempFile = tempfile.NamedTemporaryFile(dir=os.curdir,
sel=Selection) , suffix=".pdb")
print tempFile.name, Selection # prints righteous file name and
selection name (though not in quotes)
cmd.save(tempFile.name, Selection) # but still saves nothing
On Tue, Jan 22, 2013 at 10:49 PM, Thomas Holder <
> Hi Boris,
> this will give you the list of active selections, which has by default
> only one entry (or zero, if no selection is enabled).
> active_selections = cmd.get_names('selections', 1)
> Hope that helps.
> On Jan 22, 2013, at 2:08 PM, Boris Kheyfets <kheyfboris@...> wrote:
> > I want to save current selection as a uniquetly-named pdb file. So I
> need tempfile of python.
> > So I write def, and I want it have current selection as default one (not
> the '(all)'). How do I do that?
> > I think it will be somewhere under
> > cmd.get_session()
> > I read the sources, but couldn't find a single instance where current
> selection would be a default one.
> Thomas Holder
> PyMOL Developer
> Schrödinger Contractor