From: Axel Kohlmeyer (
Date: Tue May 01 2012 - 19:13:11 CDT

On Tue, May 1, 2012 at 6:18 PM, Heather Mayes <> wrote:

> I tried a couple things. The one I thought would be successful was
> copying the sample in a cpmd-vmd tutorial (below) and putting it in my

o dear. the sins of my youth are coming back to haunt me. ;)

> vim.rc (I'm using Windows). I saved and reopened VMD and then a
> molecule the result was a null result: the same display behavior
> (default lines) as if I had not added anything to my vim.rc. I have
> successfully made other changes to my vim.rc  which do show a
> different display, such as adding the line "mol default style {VDW 0.3
> 15}".

> # delete the default visualization and create another one
> proc my_def_viz {args} {
>   lassign $args fname molid
>   mol delrep 0 $molid
>   mol color Type
>   mol representation CPK 1.000000 0.300000 19.000000 16.000000
>   mol addrep $molid
> }
> # add 'default visualization' hack for the first three molecules.
> trace variable vmd_read_trajectory(0) w my_def_viz
> trace variable vmd_read_trajectory(1) w my_def_viz
> trace variable vmd_read_trajectory(2) w my_def_viz
> Does this look like it should work? As I said, it did not for me.

this was developed and tested with a *much* older version of VMD.
apparently there were some changes to the syntax and how
variable traces are handled. please try using the following code
instead that i just tested with a current version of VMD. it is a
bit more complicated, but also more robust and will work on
the molecule loaded at startup.

good luck,

proc reset_viz {molid} {
  # operate only on existing molecules
  if {[lsearch [molinfo list] $molid] >= 0} {
    # delete all representations
    set numrep [molinfo $molid get numreps]
    for {set i 0} {$i < $numrep} {incr i} {
      mol delrep $i $molid
    # add new representations
    mol color Name
    mol representation VDW 0.3 15.0
    mol selection all
    mol material Opaque
    mol addrep $molid
    mol representation DynamicBonds 1.6 0.3 6.0
    mol selection {name C}
    mol addrep $molid
    mol representation DynamicBonds 1.2 0.3 6.0
    mol selection {name C H}
    mol addrep $molid

proc my_def_viz {args} {
  foreach {fname molid rw} $args {}
  eval "after idle {reset_viz $molid}"

trace variable vmd_initialize_structure w my_def_viz

# take care of the molecule loaded on startup.
after idle {reset_viz 0}

> Thank you,
> -Heather

Dr. Axel Kohlmeyer
College of Science and Technology
Temple University, Philadelphia PA, USA.