cmds.undoInfo(openChunk = 1)
# your code
cmds.undoInfo(closeChunk = 1)
这样,在两行 chunk 之间的可撤销 cmds 命令都会被封装成一个undo