Hi, I'd like to create a hotkey to toggle between object, vert, edge and face mode. I've found a similar hotkey that toggles between move, scale and rotate and I believe it should work in the same way. I understand I need to use if and else statements but so far I have been unable to create what I want it to do.
Here's the code for the toggle script I found.
string $currentTool = `currentCtx`;
if ($currentTool == "moveSuperContext")
setToolTo $gScale;
else if ($currentTool == "scaleSuperContext")
setToolTo $gRotate;
else
setToolTo $gMove;Can someone help me create this toggle please? It would be such a time saver
Thanks
Replies
if (`selectType -q -pf` == 1){
setSelectMode components Components; selectType -smp 1 -sme 0 -smf 0 -smu 0 -pv 1 -pe 0 -pf 0 -puv 0; HideManipulators;
inViewMessage -smg "Vertex selection is now <hl>on</hl>.\nPress <hl>F8</hl> for object selection" -fade -pos topCenter;
}
else if (`selectType -q -pv` == 1){
setSelectMode components Components; selectType -smp 0 -sme 1 -smf 0 -smu 0 -pv 0 -pe 1 -pf 0 -puv 0; HideManipulators;
inViewMessage -smg "Edge selection is now <hl>on</hl>.\nPress <hl>F8</hl> for object selection" -fade -pos topCenter;
}
else if (`selectType -q -pe` == 1){
setSelectMode components Components; selectType -smp 0 -sme 0 -smf 1 -smu 0 -pv 0 -pe 0 -pf 1 -puv 0; HideManipulators;
inViewMessage -smg "Face selection is now <hl>on</hl>.\nPress <hl>F8</hl> for object selection" -fade -pos topCenter;
}
// Error: line 19: Cannot find procedure "HideManipulators".
Generally what is the best way to troubleshoot errors in Mel?
In this case, HideManipulators is a proc that lives in Maya2016.5/scripts/others/drInit.mel, and probably isn't necessary so you can try removing it from the lines using it.
For example when I was trying to code this myself, I was trying to use the command, 'SelectVertexMask'.
Also could you give me a hint as to how I'd figure out adding more to this script? I've really been enjoying playing with mel code so far and would like to start figuring more out as I go
I'd love to be able to get it to cycle through Object and UV mode eventually.
Thanks
I'm still not that great at scripting. I couldn't find a clean and simple way to detect object mode that still works for when multiple objects or nothing is selected, or maybe i'm overthinking it. I also question the sanity of adding that to the toggle, but that's just me. The default F8 hotkey has a simple toggle for object/component mode.
</code><pre class="CodeBlock"><code><br>//Query Object Mode, returns 1 or 0<br>selectMode -q -o;<br><br>//Query Component Mode, will return 1 even if no components are selected (cyan wireframe)<br>selectMode -q -co;
If you use selectMode to enter component mode, it will switch to the last active component selection mode that was used. If you have multiple objects selected, selectMode -q -o will return true as long as there is at least one object in your selection still in object mode.
Personally I use a hotkey to toggle between Object and Multi modes. Since Multi lets me pick all components, it's a bit more convenient than cycling through multiple modes. You can also use getPanel -underPointer to make your component cycling context-sensitive to whatever window you're in. For example, my hotkey that switches between Object and Multi modes is for my modeling viewports. If I'm in the UV editor, it swaps between UVs and edges.
i guess it will nees some sort of mel scripting involving if statments or something like that
anyway i found this
if i run it it will allow me to select border edges
and it i only run
resetPolySelectConstraint;
then i get back my regular selection
(i guess it turns off the selectionConstraint or something)
anyway i hope some way smarter and brilliant person
will help me make this in to a awsome mel toggle script that i then can assign to a hotkey
sorry four my extremly bad english