From: Paweł Kędzierski (
Date: Fri May 17 2013 - 09:03:40 CDT

W dniu 17.05.2013 12:22, Axel Kohlmeyer pisze:
> 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.
Good idea indeed, thanks :)
> 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 for the code. I have checked that a single atom can only have one
label so the indexes will start at 0 and they can't grow beyond the
number of atoms.
The code (possibly useful for someone else) would be then:

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

The initial deletion of all Atoms labels is there because relabeling of
an atom actually hides its label.
Thank you,

>> Thanks,
>> Pawel
> --
> Dr. Axel Kohlmeyer
> International Centre for Theoretical Physics, Trieste. Italy.