From: Pierpaolo Pravatto (pierpaolo.pravatto_at_greenenergystorage.eu)
Date: Mon Jan 02 2023 - 02:27:13 CST

Hello,

I am trying to write a script to display atomic charges by putting a label over the corresponding atom. I managed to do so using the code:

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

The labels, however, appear to be located on the plane passing through the atom position and perpendicular to the user's point of view. As such, if not manually shifted on the 2D plane using the textoffset command, the labels are often covered, at least partially, by the other 3D objects (in my case atoms and bonds in CPK mode).

Unfortunately, in my case, manually offsetting the labels using the textoffset command is not an option given that the script should work regardless of the molecule and its orientation in space (the script is part of a visualization tool agnostic to the molecule given). I would like to know if it was possible to put the labels as overlays on top of the 3D objects rather than treating them as objects in space (as done, for example, in the Chemcraft viewer). This would eliminate the issue altogether.

Thank you very much in advance,
Kind regards

Pierpaolo