Mel solution toggle between 'Default Quality Dsiplay' and 'High Quality Display'?

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!

doing stuff via the Attribute Editor often runs internal AE template functions - you can see in your example gif it enable/disables several editor controls. When you perform operations using the Attr Editor functions it can often mask or obfuscate what is actually happening. You can usually “find” the functions it’s running using whatIs and then open the associated MEL scripts and read them to figure out what is actually being executed, but in this case, you can simply turn “Echo All” off, and simply press keys 1 and 3 to get this output to the Script Editor:

displaySmoothness -divisionsU 0 -divisionsV 0 -pointsWire 4 -pointsShaded 1 -polygonObject 1;
displaySmoothness -divisionsU 3 -divisionsV 3 -pointsWire 16 -pointsShaded 4 -polygonObject 3;
1 Like

@Naughty
This explains a lot, far beyond this question. It will help me a lot going forward. Thank you