[Maya] Problem with Re-doing an Undo Chunk

I am having trouble with a simple script that planar maps each polygon of a mesh. Undo works as it should, but…

…it is when I try to redo the operation that I run into trouble, the redo stops after applying the changes to the first face.


import maya.cmds as cmds

def projEachFace(selection, scale=2.0):
    faces = cmds.polyListComponentConversion(selection, toFace=True)
    faces = cmds.filterExpand(faces, sm=34, ex=True, fp=True)
    for f in faces:
        cmds.select(f, r=True)
        proj = cmds.polyProjection(ch=True, t='Planar', md='b') # "best fit" only works if the face is directly selected. :(
        cmds.setAttr('{0}.projectionWidth'.format(proj[0]), scale)
        cmds.setAttr('{0}.projectionHeight'.format(proj[0]), scale)

cmds.undoInfo(openChunk=True)
try:
    projEachFace(cmds.ls(sl=True))
finally:
    cmds.undoInfo(closeChunk=True)

If I run the above code on a cube, I can undo the operation, but if I try to redo it, only the first face of the cube gets projected (the scale to the projection is not applied either). Basically redo stops after adding the first new node to the construction history.

this seems to be related to the polyProjection command. swapping it out for the more specific polyPlanarProjection fixed the problem with redo.