From: Joaquim Rui de Castro Rodrigues (joaquim.rodrigues_at_ipleiria.pt)
Date: Tue Feb 18 2020 - 10:46:13 CST

Hi,

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.

HTH,
Rui Rodrigues

________________________________________
De: owner-vmd-l_at_ks.uiuc.edu <owner-vmd-l_at_ks.uiuc.edu> em nome de Adupa Vasista <adupavasista_at_gmail.com>
Enviado: 18 de fevereiro de 2020 15:32
Para: vmd-l_at_ks.uiuc.edu
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.