Get Names: Difference between revisions

From PyMOLWiki
Jump to navigation Jump to search
(added "how to tell whether or not object is enabled" as posted by Jason on pymol-users)
m (→‎EXAMPLES: Changed the example so that it will print the actual object name)
Line 20: Line 20:
<source lang="python">
<source lang="python">
if objName in cmd.get_names(enabled_only=1):
if objName in cmd.get_names(enabled_only=1):
     print "objName is enabled"
     print objName, "is enabled"
</source>  
</source>
 


===SEE ALSO===
===SEE ALSO===

Revision as of 11:04, 18 March 2015

get_names returns a list of object and/or selection names.

PYMOL API

cmd.get_names( [string: "objects"|"selections"|"all"|"public_objects"|"public_selections"] )

NOTES

The default behavior is to return only object names.

EXAMPLES

Multiple alignments

# structure align all proteins in PyMOL to the protein named "PROT".  Effectively a 
# poor multiple method for multiple structure alignment.
for x in cmd.get_names("all"): cealign( "PROT", x)

Determine whether or not an object (objName) is enabled:

if objName in cmd.get_names(enabled_only=1):
    print objName, "is enabled"

SEE ALSO

get_type, get_names_of_type, count_atoms, count_states