Examples:
Two functions, one to save the current view position, the other to restore it. The position of the axis is not changed by these operations.
proc save_viewpoint {} { global viewpoints if [info exists viewpoints] {unset viewpoints} # get the current matricies foreach mol [molinfo list] { set viewpoints($mol) [molinfo $mol get { center_matrix rotate_matrix scale_matrix global_matrix}] } } proc restore_viewpoint {} { global viewpoints foreach mol [molinfo list] { puts "Trying $mol" if [info exists viewpoints($mol)] { molinfo $mol set {center_matrix rotate_matrix scale_matrix global_matrix} $viewpoints($mol) } } }
Cycle through the list of displayed molecules, turning each one on one at a time. At the end, return the display flags to their original state.
# save the current display state foreach mol [molinfo list] { set disp($mol) [molinfo $mol get drawn] } # turn everything off mol off all # turn each molecule on then off again foreach mol [molinfo list] { if $disp($mol) { mol on $mol sleep 1 mol off $mol } } # turn the original ones back on foreach mol [molinfo list] { if $disp($mol) {mol on $mol } }
The last loop, which turns the originally drawn molecules back on, doesn't turn them on at the same time. That's because some commands (those which use the command queue) redraw the graphics when they are used. This can be disabled with the display update (see section § for more information). Using this, the final loop becomes
#turn the original ones back on display update off foreach mol [molinfo list] { if $disp($mol) {mol on $mol } } display update onAlternatively, since the drawn option is settable, you could do:
foreach mol [molinfo list] { if $disp($mol) {molinfo $mol set drawn 1} }However, that won't set the flag to redraw the scene so you need to force a redraw with display redraw.