From: Axel Kohlmeyer (
Date: Fri Apr 13 2012 - 18:57:22 CDT

On Fri, Apr 13, 2012 at 2:07 PM, Andrew DeYoung <> wrote:
> Hi,
> I am running VMD 1.9.  I have a complicated system that I need to visualize
> in different ways (i.e., using different various files).  If I open one file
> and position the camera just how I want it, is it possbile to "lock off" the
> camera when I subsequently open other files?  Similarly, I would like to

not directly, but you can save the status and then reapply it.
this is what the "save_state" procedure does.

> "extract" or "save" the camera position, angle, etc., so that I can use it
> in later sessions of VMD.  This way, I will be able to reproduce the camera
> position in future sessions, enabling 1:1 comparison between images.  Is
> there any way that I can do this?

this is easiest done by using the state saving function
and then edit the resulting script accordingly. a lot of
the stuff that save_state writes are just the default settings.
so what you can do is:
- save a state that you like
- then start a second session of VMD loading the same
  file, but don't change anything and save a state right away.
- compare the two files and keep only the parts that were
  modified and whatever script constructs are needed around it.
with a little bit of experience, you don't need the comparison
any more and can even turn this into a custom function.

as for preserving rotation and camera position, have a look
at this procedure that i use in my setup as "reload" command.
this will extract the name of the last file loaded, delete all
coordinate data and load the file again. before loading it saves
the view settings and after it reapplies it.
just change it so it takes a file name as argument and passes
it to the "mol addfile" command and you are gold.

proc reload {args} {
    set tmol [molinfo top]
    array set viewpoints {}
    foreach mol [molinfo list] {
    # save orientation and zoom parameters
      set viewpoints($mol) [molinfo $mol get {
        center_matrix rotate_matrix scale_matrix global_matrix}]
    # delete all coordinates and (re)load the latest data set.
    animate delete all $tmol
    set files [lindex [molinfo $tmol get filename] 0]
    set lf [expr [llength $files] - 1]

    mol addfile [lindex $files $lf] mol $tmol \
        type [lindex [lindex [molinfo $tmol get filetype] 0] $lf]

    foreach mol [molinfo list] {
    # restore orientation and zoom
      molinfo $mol set {center_matrix rotate_matrix scale_matrix
        global_matrix} $viewpoints($mol)

> Thank you very much!
> Andrew DeYoung
> Carnegie Mellon University

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