From: Norman Geist (
Date: Tue Dec 20 2016 - 07:55:37 CST

Each atomselect object has its own frame pointer. Therefore changing the the
frame of $sel doesn't change a thing. You can either move the global
animation frame forward, which will apply to all newly created atomselects
afterwards by doing:


animate goto $i


Or by pointing each atomselect to the particular frame:



set a [atomselect top "all" frame $i]


Also to leapfrog a possible question that may follow: You can add a "draw
delete all" to the end of the frame loop to remove all arrows before drawing
the new ones, otherwise your screen might get pretty messed up with arrows
after couple frames. A better option would nevertheless be to save the
return values of the draw commands for each n_atom and delete only the the
particular arrow right before drawing it to the updated position, which
would result in smoother "animation" of the arrow movement.


Good luck


Norman Geist


Von: Amit Gupta []
Gesendet: Dienstag, 20. Dezember 2016 10:44
An: Norman Geist <>
Betreff: Re: vmd-l: Draw arrows in trajectory file


Thank you for the reply. I modified the script as written at the bottom of
mail and it worked fine (did not crash). However now i notice that arrows
are drawn only once, in the first frame. After which I do not see any
movement in the arrows. Is there any way to draw arrows per frame?




Modified lines that worked:


set end_temp [atomselect top "index $n_atom"]

set end [lindex [ $end_temp get {x y z}] 0]


set start_temp [atomselect top "index $current_c_atom_index"]

set start [lindex [$start_temp get {x y z}] 0]


$end_temp delete

$start_temp delete





From: Norman Geist < <>>
Sent: Tuesday, December 20, 2016 2:07:25 PM
To: 'Amit Gupta'
Subject: AW: vmd-l: Draw arrows in trajectory file


You produced a common memory leak with many atomselects which you never

After you no more need an atomselect object, you should call "delete" on it
to free memory.




set a [atomselect top all]

set list [$a get index]

$a delete; #<-------


So whats happening is that vmd gets killed for eating up all the memory.


Best of luck


Norman Geist


Von: <>
[] Im Auftrag von Amit Gupta
Gesendet: Dienstag, 20. Dezember 2016 07:31
An: <>
Betreff: vmd-l: Draw arrows in trajectory file


I want to draw come arrows in a lammps trajectory file, indicating movement
of certain vectors.

I have written script below, it works fine for single frame, but for more
than one frame, VMD crashes without any message (even in console). Can
anyone suggest a reason?


draw color yellow

##-----------Draw arrow subroutine from VMD website----------


proc vmd_draw_arrow {mol start end} {

    # an arrow is made of a cylinder and a cone

    set middle [vecadd $start [vecscale 0.75 [vecsub $end $start]]]

    graphics $mol cylinder $start $middle radius 0.1

    graphics $mol cone $middle $end radius 0.3





set n [molinfo top get numframes]

set sel [atomselect top "all"]

set n_list [atomselect top "type 6"] #get indexes of all nitrogens in

set all_n_atoms [$n_list get index]


for {set i 0} {$i < $n} {incr i} {

     $sel frame $i

    foreach n_atom $all_n_atoms {

        set current_c_atom_index [expr $n_atom - 1] # get index of C
attached to N

        set end [lindex [[atomselect top "index $n_atom"] get {x y z}] 0]

        set start [lindex [[atomselect top "index $current_c_atom_index"]
get {x y z}] 0]

        draw arrow $start $end




Sorry if certain logic seems slightly convoluted, still getting used to TCL!