The usual method for updating panels, such as:
cmds.setFocus("panel_name")
cmds.refresh(currentView = True, force = True)
will only update the panel canvas, but will not update changing UV components!
But you will need to use these commands to update the panel canvas when you open the UV Editor
while the script is running.
The polyTexturePlacementPanel
has its own refresh
method, called through the textureWindow
command flag of the same name.
Here’s a small demo:
import time
import maya.cmds as cmds
import maya.mel as mel
# create Poly Plane:
poly_plane = cmds.polyPlane(w = 5, h = 5, sx = 5, sy = 5, ax = (0, 1, 0), cuv =2, ch = 0)[0]
# open UV Editor:
mel.eval("texturePanelShow;")
# get UV Editor polyTexturePlacementPanel name:
uv_editor_panel_name = cmds.getPanel(scriptType = "polyTexturePlacementPanel")[0]
# Use usual method for updating panels canvas:
cmds.setFocus(uv_editor_panel_name)
cmds.refresh(currentView = True, force = True)
# We will move all 36 UVs one by one (along the “V” axis), to a value = 0.025.
# After each move we will update the panel.
# For clarity of the demonstration, we will set a delay of 0.1 second after each iteration.
for i in range(36):
cmds.polyMoveUV("{}.map[{}]".format(poly_plane, i), translateV = 0.025)
cmds.textureWindow(uv_editor_panel_name, edit = True, refresh = True)
time.sleep(0.1)
Command Help:
command (Python) textureWindow
command (Python) getPanel