📄

Save/load VMD visualization state

Created
Tagsvmd

This blogs cover how to save VMD visualization state into a file and load it for further use. These function is useful for who is make animation from multiple files.

Type the following functions sv and lv into VMD command window.

Save function sv:

proc sv {} {
set myfile [open C:/tmp/view.txt w]
set view [molinfo top get {center_matrix
rotate_matrix scale_matrix global_matrix}]
puts $myfile $view
puts $myfile [display get size]
close $myfile
}

Load function lv:

proc lv {} {
set myfile [open C:/tmp/view.txt r]
gets $myfile view
gets $myfile winsize
close $myfile
eval "display resize $winsize"
for {set i 0} {$i<[molinfo num]} {incr i} {
set id [molinfo index $i]
molinfo $id set {center_matrix rotate_matrix
scale_matrix global_matrix} $view
}
}

Type sv, current visualization state will be saved in file C:/tmp/view.txt.

When you switch to another file. Type lv, the visualization file will be restored.

Acknowledgement

The blog (tutorial) is learned from Sobereva's courseware.