Maya 2025 Smooth Preview Hotkey Loop(1,2,3)

I share this script as a thanks to the collective knowledge, always grateful for finding websites like this one.
This script makes a smooth preview loop.

import maya.cmds as mc

def SwapSmoothPreview():

# Get the selected object
selected = mc.ls(selection=True)
if not selected:
    mc.warning("There is no object selected")
    return
obj = selected[0]

# Get the current smoothness level
smoothness_current = mc.displaySmoothness(obj, q=True, polygonObject=True)[0]

# Change to the next smoothness level based on the current level
if smoothness_current == 3:
    mc.displaySmoothness(obj, polygonObject=2)
elif smoothness_current == 2:
    mc.displaySmoothness(obj, polygonObject=1)
else:
    mc.displaySmoothness(obj, polygonObject=3)

# Update the smoothness level after the change
smoothness_new = mc.displaySmoothness(obj, q=True, polygonObject=True)[0]
print("Smoothness changed from", smoothness_current, "to", smoothness_new)

SwapSmoothPreview()

Save this as SwapSmoothPreview.py
In the hotkey editor, create a new RuntimeCommand as Python
Paste this to call:

import importlib
import SwapSmoothPreview
importlib.reload(SwapSmoothPreview)
SwapSmoothPreview.SwapSmoothPreview()

I choose F2 as hotkey. Now we can have more Scripts in 1,2,3 hotkeys!! :v:
save Runtime, save and close hotkey editor cheers

1 Like