From: Robert Brunner (rbrunner_at_uiuc.edu)
Date: Fri Jun 08 2007 - 14:55:20 CDT

[$h12 get {x y z}] returns a list of lists (since the selection may
have included more than one atom), so you need to do

set vector [lindex [$h12 get {x y z}] 0]

When you do foreach, it does the unwrapping and executes one
iteration of the loop, so it is also correct.

Robert

On Jun 8, 2007, at 11:04 AM, Pavan Ghatty wrote:

> Hello all,
>
> I loaded a pdb file on vmd and typed the following commands on the
> Tcl/Tk console:
>
> set h12 [atomselect top "serial 6"]
>
> set vector [$h12 get {x y z}]
>
> veclength $vector
>
> That is what I want to do but Tcl keeps complaining that $vector is
> non-numeric. How else should I load the coordinates of h12 in to a
> vector without using foreach.
> This worked
> foreach coord [$h12 get {x y z}] {
> puts [veclength $coord]
> }
>
> Thanks.
> Pavan