Results 1 to 3 of 3

Thread: Pre and post render python scripting

  1. #1

    Default Pre and post render python scripting



    Hello guys, this is my first post around here, even though I've been following for a couple months now.

    I've been encountering a issue in python scripting in general and that is the reload of the script in pre render operations.

    I have a script that is called renderOperations.py inside the maya scripts folder and in the Post Translate Python Script I have:

    import renderOperations
    reload(renderOperations)
    renderOperations.main()

    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.

    Thanks in advance

  2. #2
    while loop
    Join Date
    Feb 2010
    Posts
    179

    Default

    While reload can be weird, we'd probably need to see what exactly is happening in renderOperations to be able to say if it is the cause or not.

  3. #3

    Default

    this is the renderOperations.py code

    Code:
    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...
    Last edited by PoLLuX; 02-21-2017 at 01:58 PM. Reason: new tests

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •