The weird thing is that when I first render the scene, it doesn’t run the operations it should run, only at the second attempt. I discovered around the web that the reload function seems to be a bit buggy, because some people have the same issue.
Any idea what might cause this? The operations on the script are simple: mesh smooth before render, remove it after.
import maya.cmds as mc
import maya.mel as mel
import os, sys
def main():
mc.prepareRender(edit=True, preRender=preRenderOp)
mc.prepareRender(edit=True, postRender=postRenderOp)
def preRenderOp():
meshes = mc.ls(type='mesh')
for mesh in meshes:
a = mc.polySmooth(mesh, sdt=2, dv=2)
def postRenderOp():
meshes = mc.ls(type='mesh')
for mesh in meshes:
connections = mc.listConnections(mesh)
for connection in connections:
if 'polySmooth' in connection:
mc.polySmooth(connection, edit=True, sdt=0, dv=0)
mc.select(meshes)
mel.eval("DeleteHistory;")
mc.select(clear=True)
The weird thing is that the preRenderOp doesn’t run at the first try, but the postRenderOp does…