I am trying to write a simple Mel script, that toggles smooth mesh preview for the selected object.
The default maya way of doing this is using keyboard key 1 and 3, I think. I would like to combine them to one key.
With this sort of thing I usually just turn on “echo all commands” in the script editor and use that as a clue.
But in this case, when I perform the action via the attribute editor, the scripts editor does not spit out anything useful that I can use or look into:
// Result: scriptEditorPanel1Window|scriptEditorPanel1|formLayout113|formLayout115|paneLayout2|cmdScrollFieldReporter1
SMPAttrsFromCustomControlsUI "pCubeShape1";
attrFieldSliderGrp -e -en false attrFieldSliderGrp23;
// Result: attrFieldSliderGrp23
setParent formLayout124;
// Result: AttributeEditor|MainAttributeEditorLayout|formLayout96|AErootLayout|AEStackLayout|AErootLayoutPane|AEbaseFormLayout|AEcontrolFormLayout|AttrEdmeshFormLayout|scrollLayout2|columnLayout4|frameLayout41|columnLayout9|frameLayout310|columnLayout263|formLayout124
checkBoxGrp -e -en1 false valueFld;
// Result: valueFld
setParent formLayout125;
// Result: AttributeEditor|MainAttributeEditorLayout|formLayout96|AErootLayout|AEStackLayout|AErootLayoutPane|AEbaseFormLayout|AEcontrolFormLayout|AttrEdmeshFormLayout|scrollLayout2|columnLayout4|frameLayout41|columnLayout9|frameLayout310|columnLayout263|formLayout125
checkBoxGrp -e -en1 false valueFld;
// Result: valueFld
attrFieldSliderGrp -e -en false attrFieldSliderGrp24;
// Result: attrFieldSliderGrp24
SMPCustomControlsUIFromAttrs "pCubeShape1";
attrFieldSliderGrp -e -en false attrFieldSliderGrp23;
// Result: attrFieldSliderGrp23
setParent formLayout124;
// Result: AttributeEditor|MainAttributeEditorLayout|formLayout96|AErootLayout|AEStackLayout|AErootLayoutPane|AEbaseFormLayout|AEcontrolFormLayout|AttrEdmeshFormLayout|scrollLayout2|columnLayout4|frameLayout41|columnLayout9|frameLayout310|columnLayout263|formLayout124
checkBoxGrp -e -en1 false valueFld;
// Result: valueFld
setParent formLayout125;
// Result: AttributeEditor|MainAttributeEditorLayout|formLayout96|AErootLayout|AEStackLayout|AErootLayoutPane|AEbaseFormLayout|AEcontrolFormLayout|AttrEdmeshFormLayout|scrollLayout2|columnLayout4|frameLayout41|columnLayout9|frameLayout310|columnLayout263|formLayout125
checkBoxGrp -e -en1 false valueFld;
// Result: valueFld
attrFieldSliderGrp -e -en false attrFieldSliderGrp24;
// Result: attrFieldSliderGrp24
DPCustomControlsUIFromAttrs "pCubeShape1";
I am new to Mel but I have fairly good understanding of it. I just need a good entry point for this task, is there a command that is dedicated to smooth mesh preview?
This may seem like a trivial task, but there a few cases where I would much prefer a toggle key rather than two keys, and I am just looking for a general approach to building a ‘toggle key’.
I am on Maya 2025
Any help would be greatly appreciated!