From: Nima Soltani (
Date: Sun Jun 07 2020 - 22:49:58 CDT

Hello dear all, I consider myself a newbie in TCL scripting and appreciate
any help!
I want to remove the unwanted waters inside a carbon nanotube .
I have selected everything inside NT using the following command
*>> set badwater [atomselect top "(z>$Zmin and z<$Zmax) and

1st I tried to delete the selected waters using the following command:

*>> foreach segid [$badwater get segid] resid [$badwater get resid] {
  delatom $segid $resid

But unfortunately the result was : psfgen) no segment

Then I tried to get the index of atoms of every water molecule that has a
selected atom (In order to prevent having dangling H or O) using the
following command:

>> *set allbadH2O [atomselect top "resid [$badHW_H get resid]"]*
but the atomselect also selected water molecules far away from nanotube
which was very odd

Any help/tip will be highly appreciated
Best Regards,