Selection Exists

From PyMOLWiki
Revision as of 08:35, 30 April 2009 by Inchoate (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
#
# The function below will return true if the selection is defined.
#
from pymol import cmd
from types import *

def sele_exists(sele):
    sess = cmd.get_session()
    for i in sess["names"]:
        if type(i) is ListType:
            if sele==i[0]:
                return 1
    return 0

# Note from Warren:
#
# simpler, faster:

def sele_exists(sele):
   return sele in cmd.get_names("selections")