In my last post I wrote about two methods for getting the manipulator handle to change automatically when you select an object. Then, thanks to Brad Clark's post on cgtalk I discovered yet another way (actually the same technique as zooTriggered, but doesnt require the zooToolbox to be installed).
I thought it would be useful to put Brad's whichTool() proc into an easy to use mel script. I've called it djSwitchManipOnSelection.mel to stick with my usual naming, but really the guts of this are Brad's code and a bit from Hamish - thanks guys.
You need to source djSwitchManipOnSelection.mel, probably by adding a line to your userSetup.mel. Then you have a few commands you can use. Here is a basic work flow.
Select some objects. Then in the cmd window type djCreateDefaultToolAttr 0 to flag those objects for worldspace move (substitute 1 for object move, 2 for rotate, 3 for scale). An attribute called defaultTool is added to the objects and specifies the manipulator type, which you can change later if you wish.
djSwitchManipOnSelection 1 activates the manipulator switching scriptJob. Now a change of selection will check for the defaultTool attribute and change manipulator accordingly.
djSwitchManipOnSelection 0 deactivates manipulator switching.
djRemoveDefaultToolAttr removes the defaultTool attribute from selected objects.
These commands will be easier to use if you assign them to shelf buttons or marking menus.