As part of our research on developing new types of user interfaces for molecular modelling, we have added a simple way for other programs to send information to a VMD process via the Tcl-DP RPC mechanism. (See sections § and §). As an example of use, here's how to control one VMD session from another program.
For now, I'll assume that both programs are on the same computer.
Start VMD and execute external on
. This tells VMD to start
listening for commands from one of the machine ports. (For those
interested in the details, this function disables acceptance of
commands from other machines (
dp_Host -; dp_Host +[exec hostname]
)
then starts the server as dp_MakeRPCServer 8639.)
SECURITY WARNING: Once the external option is enabled, VMD will allow any program to connect to it and execute a Tcl script as you. By default, VMD limits its connections to other processes on the same machine, so you are reasonably safe if you trust the other users. However, it is easy to modify the settings to allow anyone in the world to connect and do whatever they wanted. It is possible to make the connection more secure, but since VMD is designed for an academic environment where different users trust each other, we have not implemented it. (See the Tcl-DP distribution for documentation of how to do so.)
Start up another program that uses Tcl-DP, like dpwish or another instance of VMD. (Remember, you can start VMD without a display with vmd -dispdev none.) Execute the command
set vmd_server [dp_MakeRPCClient [exec hostname] 8639]This should return a name like ``file7'' if successful. To send a command (in this case,
rotate x by 90
) to VMD, enter
dp_RPC $vmd_server rotate x by 90To simplify matters you might want to implement a new procedure to handle these messages
proc tell_vmd {args} { global vmd_server dp_RPC $vmd_server eval $args } tell_vmd rotate x by 90Where the last line is an example of how this procedure is used.
If you want to control VMD on from machine, on the controlling process, replace the [exec hostname] with the name of the machine with VMD.