From: John Stone (johns_at_ks.uiuc.edu)
Date: Thu Sep 08 2016 - 11:57:19 CDT

Hi,
  I'm fairly certain that the problem with your script is that you're
trying to set colors for atom names etc that don't exist at the time
you're trying to set them. VMD adaptively creates new color entries
for atom names and atom types (and a few others) when structures are
loaded, so you will need the the color commands to be run when you
load your structure rather than at startup. What I describe is the
approach that the VMD saved state files use, for example. You could
create a script that applies your favorite colors to structures when
they are loaded if you use so-called "callback" procedures and check
to make sure that the atom names/types you're modifying exist at the
time you try to set them.

Cheers,
  John Stone
  vmd_at_ks.uiuc.edu

On Thu, Sep 08, 2016 at 10:17:53AM -0500, Tyler Westland wrote:
> Dear VMD users,
>
> VMD Version: 1.9.2
>
> Problem: Error in custom vmdrc script
>
> Problem script:
> # Our colors set by name.
> # The "after idle" command is because the .vmdrc is processed too early
> # for colors to be set; this makes it so that it occurs after other
> # stuff is properly set up.
> # The dummy molecule is created because we can't set colors if no
> # molecules exist.
> # See
> https://sites.google.com/site/akohlmey/random-hacks/vmd-initialization-scripts
> after idle {
> # create dummy molecule with one atom
> set mol [mol new atoms 20]
> set sel [atomselect $mol all]
> # add items to color categories
> # Water and Hexane project
> # Water
> $sel set name H
> $sel set type H
> color Name H blue
> color Type H blue
> $sel set name O
> $sel set type O
> color Name O blue
> color Type O blue
> $sel set type M
> $sel set name M
> color Name M blue
> color Type M blue
> # Hexane
> $sel set name CH2
> $sel set type CH2
> color Name CH2 yellow
> color Type CH2 yellow
> $sel set name CH3
> $sel set type CH3
> color Name CH3 yellow
> color Type CH3 yellow
>
> # SDK project
> # Water
> $sel set name W
> $sel set type W
> color Name W blue
> color Type W blue
> # Surfactant S10E3
> $sel set name OA
> $sel set type OA
> color Name OA red
> color Type OA red
> $sel set type EO
> $sel set name EO
> color Name EO yellow
> color Type EO yellow
> $sel set name CM
> $sel set type CM
> color Name CM green
> color Type CM green
> $sel set name CT
> $sel set type CT
> color Name CT gray
> color Type CT gray
> $sel set name EST1
> $sel set type EST1
> color Name EST1 orange
> color Type EST1 orange
> $sel set name CT2
> $sel set type CT2
> color Name CT2 orange
> color Type CT2 orange
>
> # clean up
> $sel delete
> mol delete $mol
> }
>
> Error:
> When VMD starts up it throws an application error with this message:
>
> Unable to change color name
> Unable to change color name
> while executing
> "color Name "CH2" yellow"
> ("after" script)
>
> Thank you very much,
> Tyler Westland

-- 
NIH Center for Macromolecular Modeling and Bioinformatics
Beckman Institute for Advanced Science and Technology
University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
http://www.ks.uiuc.edu/~johns/           Phone: 217-244-3349
http://www.ks.uiuc.edu/Research/vmd/