From: Axel Kohlmeyer (akohlmey_at_gmail.com)
Date: Mon Sep 28 2009 - 09:35:25 CDT

hi stephanie,

On Mon, Sep 28, 2009 at 9:39 AM, Stephanie Held
<e-mail_at_stephanie-held.de> wrote:
> Hello!
>
> I have a problem concerning vectors in vmd. What I'm trying to do is draw a
> cylinder using vmd console which works nicely when I do it like this:
>
> graphics top cylinder {-12.3400001526 73.4120025635 46.4959983826}
> {-6.99599981308 63.8670005798 67.9349975586} radius 0.5 resolution 60 filled
> yes
>
> Since I have to draw many cylinders I would like to give the positions as
> variables instead of numbers in the command:

this is not how programming or script languages like tcl work. you would
have to use something more obscure like APL to make these things work,
but that is a way you don't want to go.

the solution is very simple: use a loop!
see below for an example.

>
> set a1 [atomselect 0 "resid 33 and type CA"]
> set x1 [$a1 get {x y z}]
>
> I did the same for x2 and then tried to draw the cylinder by typing:
>
> graphics top cylinder {$x1} {$x2} radius 0.5 resolution 60 filled yes

foreach x1 [$a1 get {x y z}] x2 [$a2 get {x y z}] {
    graphics top cylinder $x1 $x2 radius 0.5 resolution 60 filled yes
}

other than that, i stronly suggest to have a look at the excellent tcl
tutorial that ships with tcl 8.5 and can be found at www.tcl.tk which
has many great examples of how to deal with lists (which is what
a "vector" really is in tcl syntax).

cheers,
    axel.

> But that doesn't work. vmd tells me "need three numbers for a vector" which
> doesn't make sense to me because x1 and x2 are actually vectors of three
> numbers which I checked:
>
> puts $x1
> {-12.3400001526 73.4120025635 46.4959983826}
>
> Does anyone know what to do about this? I'd be very happy about any advice!
>
> Best regards
>
> Stephanie
>

-- 
Dr. Axel Kohlmeyer    akohlmey_at_gmail.com
Institute for Computational Molecular Science
College of Science and Technology
Temple University, Philadelphia PA, USA.