From: Joaquim Rui de Castro Rodrigues (
Date: Tue Feb 18 2020 - 10:46:13 CST


Start by inserting some puts commands before entering the foreach loop, to be sure that you are reading data correctly:
puts $frx
puts $fry
puts $frz
Dont' forget to close the file after reading. Also, check that you selection is not empty:
puts [$index num]
and finally, in your last line, you probably want to increase the counter k, and not the selection $index.

Rui Rodrigues

De: <> em nome de Adupa Vasista <>
Enviado: 18 de fevereiro de 2020 15:32
Assunto: vmd-l: atomselect moveby: non-numeric in vector

Dear VMD users,

I have a system where I need to randomly distribute the molecules in the simulation box with some constraints. I got the coordinates from MATLAB and saved it as a dat file. Further I loaded the system and the molecules separately (indexed from 1 to 100). i need to randomly place these molecules according to the dat file coordinates.

I loaded the dat file using

set fpx [open "x.dat" r]
set frx [read $fpx]
set fpy [open "y.dat" r]
set fry [read $fpy]
set fpz [open "z.dat" r]
set frz [read $fpz]

then I used foreach loop

set k 1
foreach x $frx y $fry z $frz {
set index [atomselect $k all]
$index moveby {$x $y $z}
incr $index 1

But I am having an error in moveby command.

atomselect moveby: non-numeric in vector

 Is there any workaround for this?

Please let me know.

Thank you.