Get object list

From PyMOLWiki
Revision as of 12:10, 6 March 2017 by Speleo3 (talk | contribs) (print syntax for python 2+3)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

cmd.get_object_list is an API only command which returns the list of all molecular objects in selection. It will not return selection names or objects which are not of type molecule.


list cmd.get_object_list(string selection='(all)')

Important: Always put the selection in parenthesis to force PyMOL to interpret it as an atom selection. Otherwise this might fail on name wildcards, groups, etc.

For proper atom selections this should be identical to:

list cmd.get_names('objects', 0, string selection='(all)')


PyMOL> fetch 2x19 2xwu 1d7q, async=0
PyMOL> print(cmd.get_object_list('solvent'))
['2x19', '2xwu']
PyMOL> print(cmd.get_object_list('hydro'))
PyMOL> print(cmd.get_object_list('2x*'))    # FAIL!!! (fixed in PyMOL 1.7.6)
PyMOL> print(cmd.get_object_list('(2x*)'))  # correct, with parenthesis
['2x19', '2xwu']

See Also