From: Axel Kohlmeyer (
Date: Fri May 17 2013 - 05:22:43 CDT

On Fri, May 17, 2013 at 11:17 AM, Paweł Kędzierski
<> wrote:
> Dear VMD users,
> It is possible to format atom labels using VMD GUI (Graphics->Labels, tab
> Properties), but I can't find in the user guide such functionality for the
> Tcl label command.
> I want to automate relatively simple tasks like labeling every atom with its
> index:
> set all [atomselect $molid "all"]
> foreach atom [$all list] {
> label add Atoms $molid/$atom
> }
> $all delete
> Can I set the label format to e.g "%i" in Tcl code or via GUI only?

you can always monitor Tcl commands that do the same thing as the GUI
by turning on logging.

please try something like this (untested):

set all [atomselect $molid "all"]
set i [llength [label list Atoms]]
foreach atom [$all list] {
   label add Atoms "$molid/$atom"
   label textformat Atoms $i {%i}
   incr i
$all delete

> Thanks,
> Pawel

Dr. Axel Kohlmeyer
International Centre for Theoretical Physics, Trieste. Italy.