Cycle between Object and Component Mode Through Script


#1

Hi All,

Is there a way to map two keys
One b[/b] for the switching between Object Mode and Component Mode and the other b[/b] for switching between Vertex, Edge and Face mode?

So far I got this code for the first one


selectMode -object;
selectMode -component;

The problem with this is that I cannot get the current mode if it is object or component.
Basically, the process would run as:
(1) Check whether object or component
(2) If object, change to component
(3) If component, change to object.

For the second one, thanks to this thread


if (`selectMode -q -o` == 1)
{
   dR_modeVert;
   inViewMessage -pos topCenter -msg "Vert" -fade;
}
else if (`selectType -q -pv` == 1)
{
   dR_modeEdge;
   inViewMessage -pos topCenter -msg "Edge" -fade;
}    
   
else if (`selectType -q -pe` == 1)
{
   dR_modePoly;
   inViewMessage -pos topCenter -msg "Face" -fade;
}   
   
else if (`selectType -q -pf` == 1)
{
   dR_modeObject;
   inViewMessage -pos topCenter -msg "Object" -fade;
}

It works. But the problem is that it maps all the command to one key rather than my preferred two keys.
I tried deleting the last last “else if” statement for the object but after that the script does not work any longer.

Is there a way around this?

Thank you for your time.