Search code examples
pythoncolorspymol

automatically change object colors in pymol from python


I am trying to change the color of many objects in pymol from python. I made this for loop

obs = ['R8', 'R1X', 'R2X', 'R11']
for i in obs:
    print "color gray, %s" % i

from pymol I run

run myscript.py

but the pymol interface simply prints the the command that should change the color, and does not change the color of the structure.


Solution

  • In order to execute Pymol commands from python you need to use cmd. In your case this would be:

    cmd.color('gray', i)