• Facebook - Grey Circle
  • LinkedIn - Grey Circle
  • Vimeo - Grey Circle
  • SideFX Gallery

If you use the following code/tool to create, manage, and render.

‚Äč

PLEASE GIVE CREDIT TO

Luke Vuilliomenet

from hutil.Qt import QtWidgets
from hutil.Qt import QtCore

import hou


nodeList = []
rangeNodeList = []
nodeNumber = 0
versionNumber = 1
renderPath = []
#myCam = hou.node("/obj").createNode("cam", "nodeCamera")

def onCreateInterface():
    welcome = QtWidgets.QLabel('Welcome to the Render Node Manager')
    credit = QtWidgets.QLabel('Credit: Luke Vuilliomenet')
    instructions = QtWidgets.QLabel()
    
    root_widget = QtWidgets.QWidget()
    layout = QtWidgets.QVBoxLayout()
    layout.addStretch()
    layout.addWidget(welcome)
    layout.addWidget(credit)
    
    BTTN_createRender = QtWidgets.QPushButton("Create Render Node")
    BTTN_createRender.clicked.connect(createRender)
    
    BTTN_deleteRender = QtWidgets.QPushButton("Delete Render Node")
    BTTN_deleteRender.clicked.connect(deleteSelect)
    
    BTTN_renderSelect = QtWidgets.QPushButton("Render Select Nodes")
    BTTN_renderSelect.clicked.connect(renderSelect)
    
    BTTN_render = QtWidgets.QPushButton("Render ALL Managed Nodes")
    BTTN_render.clicked.connect(renderAll)
    
    BTTN_versionNumber = QtWidgets.QPushButton("Change Version Number")
    BTTN_versionNumber.clicked.connect(changeVersion)
    
    BTTN_reset = QtWidgets.QPushButton("Reset")
    BTTN_reset.clicked.connect(reset)
    
    BTTN_instructions = QtWidgets.QPushButton("Instructions")
    BTTN_instructions.clicked.connect(usage)
    
    layout.addWidget(BTTN_instructions)
    layout.addWidget(BTTN_createRender)
    layout.addWidget(BTTN_deleteRender)
    layout.addWidget(BTTN_renderSelect)
    layout.addWidget(BTTN_render)
    layout.addWidget(BTTN_versionNumber)
    layout.addWidget(BTTN_reset)
    
    root_widget.setLayout(layout)
   
    return root_widget
    
def reset():

    #import global variables
    
    global nodeNumber
    global nodeList

    global rangeNodeList
    global versionNumber
    global renderPath
    global myCam
    
    #print nodeList
    
    if hou.ui.displayMessage("Reseting manager will delete all managed nodes. Are you sure you want to reset?", buttons=("Yes","No"))==0:
        for i in range(len(nodeList)):
            delete = hou.node(('/out/%s') % nodeList[i])
            hou.Node.destroy(delete)
            
        #reset global variables
        
        nodeNumber = 0
        nodeList = []

        rangeNodeList = []
        versionNumber = 1
        renderPath = []
        #hou.Node.destroy(myCam)
        
        hou.ui.displayMessage("Render Node Manager and all nodes have been reset")
       
def createRender():
    global nodeNumber
    global nodeList
    global rangeNodeList
    global versionNumber
    global renderPath
    global myCam
    
    nodeNumber +=1;
    path = hou.ui.selectFile()
    
    
    sceneRoot = hou.node('/out/')
    rop = sceneRoot.createNode("ifd","Managed_Node_%d" % nodeNumber)
    rop.parm("vm_picture").set("%s_$HIPNAME.v%04d.exr" % (path,versionNumber))
    renderPath.append(path)
    nodeList.append("Managed_Node_%d" % nodeNumber)
    
    
    
    #select and assign camera
    
    if hou.ui.displayMessage("Assign Camera?", buttons=("Yes","No"))==0:
        camera = hou.ui.selectNode()
        rop.parm("camera").set("%s" % camera)
    #else:
     #   rop.parm("camera").set(myCam)
    
    if hou.ui.displayMessage("Do you want to render a frame range?", buttons=("Yes","No"))==0:
        rangeNodeList.append("Managed_Node_%d" % nodeNumber)
        rop.parm("vm_picture").set("%s_$HIPNAME.$F4.exr" % (path))
        rop.parm("trange").set(1)
        rop.parm("f1").deleteAllKeyframes()
        rop.parm("f2").deleteAllKeyframes()
        f1 = hou.ui.readInput("Please type in start frame")
        f1 = float(f1[1])
        rop.parm("f1").set(f1)
        
        f2 = hou.ui.readInput("Please type in end frame")
        f2 = float(f2[1])
        rop.parm("f2").set(f2)
        
        f3 = hou.ui.readInput("Please type in render increment")
        f3 = float(f3[1])
        rop.parm("f3").set(f3)
        
        
    if hou.ui.displayMessage("This tool comes with node presets. Would you like to use these settings?", buttons=("Yes","No"))==0:
        setting = hou.ui.displayMessage("Presets", buttons=("Low Res","Mid Res","High Res", "Particles"))
        if setting ==0:
            rop.parm("declare_all_shops").set(2)
            rop.parm("vm_image_comment").set("Render node created and managed by 'Render Node Manager'. Credit Luke Vuilliomenet")
            rop.parm("vm_samplesx").set(2)
            rop.parm("vm_samplesy").set(2)
            rop.parm("vm_reflectlimit").set(4)
            rop.parm("vm_refractlimit").set(4)
            rop.parm("vm_maxraysamples").set(9)
            rop.parm("vm_globalquality").set(1)
            rop.parm("vm_quickplane_P").set(1)
            rop.parm("vm_quickplane_Pz").set(1)
            rop.parm("vm_quickplane_N").set(1)
            rop.parm("vm_numaux").set(1)
            rop.parm("vm_variable_plane1").set("all")
            rop.parm("vm_pfilter_plane1").set("gaussian -w 2")
            rop.parm("allowmotionblur").set(0)
            rop.parm("vm_renderengine").set("pbrraytrace")
            rop.parm("override_camerares").set(1)
            
       
        elif setting == 1:
            rop.parm("declare_all_shops").set(2)
            rop.parm("vm_image_comment").set("Render node created and managed by 'Render Node Manager'. Credit Luke Vuilliomenet")
            rop.parm("vm_samplesx").set(4)
            rop.parm("vm_samplesy").set(4)
            rop.parm("vm_reflectlimit").set(4)
            rop.parm("vm_refractlimit").set(6)
            rop.parm("vm_maxraysamples").set(12)
            rop.parm("vm_globalquality").set(1.5)
            rop.parm("vm_quickplane_P").set(1)
            rop.parm("vm_quickplane_Pz").set(1)
            rop.parm("vm_quickplane_N").set(1)
            rop.parm("vm_numaux").set(1)
            rop.parm("vm_variable_plane1").set("all")
            rop.parm("vm_pfilter_plane1").set("gaussian -w 2")
            rop.parm("allowmotionblur").set(1)
            rop.parm("vm_renderengine").set("pbrraytrace")
            rop.parm("override_camerares").set(1)
            rop.parm("res_fraction").set("specific")
            rop.parm("res_overridex").set(1280)
            rop.parm("res_overridey").set(720)
            
        elif setting == 2:
            rop.parm("declare_all_shops").set(2)
            rop.parm("vm_image_comment").set("Render node created and managed by 'Render Node Manager'. Credit Luke Vuilliomenet")
            rop.parm("vm_samplesx").set(7)
            rop.parm("vm_samplesy").set(7)
            rop.parm("vm_reflectlimit").set(4)
            rop.parm("vm_refractlimit").set(6)
            rop.parm("vm_maxraysamples").set(16)
            rop.parm("vm_globalquality").set(2)
            rop.parm("vm_variance").set(0.098)
            
            rop.parm("vm_quickplane_P").set(1)
            rop.parm("vm_quickplane_Pz").set(1)
            rop.parm("vm_quickplane_N").set(1)
            rop.parm("vm_numaux").set(1)
            rop.parm("vm_variable_plane1").set("all")
            rop.parm("vm_pfilter_plane1").set("gaussian -w 2")
            rop.parm("allowmotionblur").set(1)
            rop.parm("vm_renderengine").set("pbrraytrace")
            rop.parm("override_camerares").set(1)
            rop.parm("res_fraction").set("specific")
            rop.parm("res_overridex").set(1920)
            rop.parm("res_overridey").set(1080)
            
        elif setting == 3:
            rop.parm("declare_all_shops").set(2)
            rop.parm("vm_image_comment").set("Render node created and managed by 'Render Node Manager'. Credit Luke Vuilliomenet")
            rop.parm("vm_samplesx").set(10)
            rop.parm("vm_samplesy").set(10)
            rop.parm("vm_reflectlimit").set(4)
            rop.parm("vm_refractlimit").set(6)
            rop.parm("vm_maxraysamples").set(16)
            rop.parm("vm_globalquality").set(2)
            rop.parm("vm_variance").set(0.01)
            
            rop.parm("vm_quickplane_P").set(1)
            rop.parm("vm_quickplane_Pz").set(1)
            rop.parm("vm_quickplane_N").set(1)
            rop.parm("vm_numaux").set(1)
            rop.parm("vm_variable_plane1").set("all")
            rop.parm("vm_pfilter_plane1").set("gaussian -w 2")
            rop.parm("allowmotionblur").set(1)
            rop.parm("vm_renderengine").set("micropoly")
            rop.parm("override_camerares").set(1)
            rop.parm("res_fraction").set("specific")
            rop.parm("res_overridex").set(1280)
            rop.parm("res_overridey").set(720)

    else:
        rop.parm("vm_image_comment").set("Render node created and managed by 'Render Node Manager'. Credit Luke Vuilliomenet")
    #select render method
        if hou.ui.displayMessage("Would you like to enter a specific images resolution?", buttons=("Yes","No"))==0:
            resX = hou.ui.readInput("Enter Resolution X", buttons=("Ok","Cancel"))
            resY = hou.ui.readInput("Enter Resolution Y", buttons=("Ok","cancel"))
            
            
            rop.parm("override_camerares").set(1)
            rop.parm("res_fraction").set("specific")
            rop.parm("res_overridex").set(resX[1])
            rop.parm("res_overridey").set(resY[1])
            
        if hou.ui.displayMessage("Assign Render Method?", buttons=("Yes","No"))==0:
            method = hou.ui.displayMessage("Render Method", buttons=("Micro Poly","Ray Trace","Micro Physical", "Physically Based", "Photon Map"))
            if method == 0:
                rop.parm("vm_renderengine").set("micropoly")
            elif method == 1:
                rop.parm("vm_renderengine").set("raytrace")
            elif method == 2:
                rop.parm("vm_renderengine").set("pbrmicropoly")
            elif method == 3:
                rop.parm("vm_renderengine").set("pbrraytrace")
            elif method == 4:
                rop.parm("vm_renderengine").set("photon")
            else:
                rop.parm("vm_renderengine").set("pbrraytrace")
      
        if hou.ui.displayMessage("Extra Image Planes?", buttons=("Yes","No"))==0:
            if hou.ui.displayMessage("The following Planes will be added: P, Pz, N", buttons=("Accept","Deny"))==0:
                rop.parm("vm_quickplane_P").set(1)
                rop.parm("vm_quickplane_Pz").set(1)
                rop.parm("vm_quickplane_N").set(1)
                
        if hou.ui.displayMessage("Combined Lighting?", buttons=("Yes","No"))==0:
            rop.parm("vm_numaux").set(1)
            rop.parm("vm_variable_plane1").set("all")
            rop.parm("vm_pfilter_plane1").set("gaussian -w 2")
        
        #ask if motion blur is desired
        if hou.ui.displayMessage("Allow Motion Blur?", buttons=("Yes","No"))==0:
            rop.parm("allowmotionblur").set(1)
   
    #if hou.ui.displayMessage("Would you like to designate which objects/lights to be used?", buttons=("Yes","No"))==0:
     #   objects = []
      #  object = []
       # lights = []
        #light = []
       # rop.parm("vobject").set("")
      #  hou.ui.displayConfirmation("Please selected desired forced objects")
      #  selector = hou.ui.selectMultipleNodes()
      #  objects.append(selector)
        #print len(objects)
      #  for i in range (len(objects)):
      #      selected = ("%s" % objects [i-1])
      #      select = selected[5:]
      #      print select
            #object.append(select)
        #print object
        #rop.parm("forceobject").set(objects)
        
        #hou.ui.displayConfirmation("Please selected desired forced lights")
        #lselector = hou.ui.selectMultipleNodes()
       # lights.append(lselector)
        
     
   # if hou.ui.displayMessage("Allow Motion Blur?", buttons=("Yes","No"))==0:
    #nodeList.append("Managed_Node_%d" % nodeNumber)
    #print nodeList
   
def deleteSelect():
    global nodeNumber
    global nodeList

    global rangeNodeList
    global versionNumber
    global renderPath
    
    
    selector = hou.ui.selectMultipleNodes()
            
    if hou.ui.displayConfirmation("!!!WARNING!!! This will delete the selected nodes and will not be recoverable. Do you still wish to continue?", suppress=hou.confirmType.OverwriteFile):
        for i in range((len(selector))):
            delete = hou.node(('%s') % selector[i-1])
            deleted = ("%s" % selector[i-1])
            deletedNode = deleted[5:]
            nodeList.remove(deletedNode)

            rangeNodeList.remove(deletedNode)
            hou.Node.destroy(delete)
            
        hou.ui.displayConfirmation("%s have been deleted" % selector)
            
    
def renderSelect():
    global nodeNumber
    global nodeList
    global versionNumber
    global renderPath
    
    selector = hou.ui.selectMultipleNodes()
    versionNumber += 1
    
    if hou.ui.displayMessage("!!!WARNING!!! Rendering select nodes will still update version number for all. Do you still wish to continue?", buttons=("Yes","Cancel"))==0:
        for i in range((len(selector))):
            node = hou.node(('%s') % selector[i])
            node.parm("vm_image_comment").set("Render node created and managed by 'Render Node Manager'. Credit Luke Vuilliomenet")
            hou.parm(("%s/execute") % selector[i]).pressButton()

        for i in range(len(rangeNodeList)):
            if rangeNodeList[i] in nodeList:
                nodeList.remove(rangeNodeList[i])
        for i in range(len(nodeList)):
            path = renderPath[i]
            node = hou.node(('/out/%s') % nodeList[i])
            node.parm("vm_picture").set("%s_$HIPNAME.v%04d.exr" % (path,versionNumber))
        for i in range(len(rangeNodeList)):
            nodeList.append(rangeNodeList[i])
            
        #hou.ui.displayMessage("%s has been rendered successfully" % selector)

def renderAll():
    global nodeList
    global versionNumber
    global renderPath
    versionNumber += 1
    
    if hou.ui.displayMessage("!!!WARNING!!! This will render all manged nodes with current settings. Do you still wish to continue?", buttons=("Yes","Cancel"))==0:
        for i in range (len(nodeList)):
            path = renderPath[i]
            node = hou.node(('/out/%s') % nodeList[i])
            node.parm("vm_image_comment").set("Render node created and managed by 'Render Node Manager'. Credit Luke Vuilliomenet")
            hou.parm(("/out/%s/execute") % nodeList[i]).pressButton()
        for i in range(len(rangeNodeList)):
            if rangeNodeList[i] in nodeList:
                nodeList.remove(rangeNodeList[i])
        for i in range(len(nodeList)):
            path = renderPath[i]
            node = hou.node(('/out/%s') % nodeList[i])
            node.parm("vm_picture").set("%s_$HIPNAME.v%04d.exr" % (path,versionNumber))
        for i in range(len(rangeNodeList)):
            nodeList.append(rangeNodeList[i])

def changeVersion():
    global nodeList
    global versionNumber
    global renderPath

    if hou.ui.displayMessage("Do you wish to change the file version number? This will update across all managed nodes.", buttons=("Yes","No"))==0:
        update = hou.ui.readInput("Please type in the desired version number with no padding")
        versionNumber = int(update[1])
        #print ("v%04d" % versionNumber)
        for i in range(len(nodeList)):
            path = renderPath[i]
            node = hou.node(('/out/%s') % nodeList[i])
            node.parm("vm_picture").set("%s_$HIPNAME.v%04d.exr" % (path,versionNumber))

def usage():
    hou.ui.displayMessage("Welcome to the a Houdini Mantra render node manager. Created by Luke Vuilliomenet",buttons=("Continue",))
    selection = hou.ui.displayMessage("Please select below for more information, or click cancel",buttons=("Basic","Create","Delete","Render Select","Render All", "Change Version","Reset","Cancel"))
    if selection == 0:
        hou.ui.displayMessage("Interfaces like this one will appear promting for user input",buttons=("Ok",))
    elif selection == 1:
        hou.ui.displayMessage("Clicking this button will begin a chain of prompt windows to create and set up a Mantra render node. If a preset is not selected the user with be asked specific question believed to be crucial aspects of the node.",buttons=("Ok",))
    elif selection == 2:
        hou.ui.displayMessage("Clicking this button will display a node tree allowing the selection of all render nodes. Please selecting one or more of the nodes with the title 'Managed_Node_' and click ok. These nodes will then be removed.",buttons=("Ok",))
    elif selection == 3:
        hou.ui.displayMessage("Clicking this button will display a node tree allowing the selection of all render nodes. Please selecting one or more of the nodes with the title 'Managed_Node_' and click ok. These nodes will then be rendered to their destination. HOWEVER all node's version number will be updated.",buttons=("Ok",))
    elif selection == 4:
        hou.ui.displayMessage("This button will render all nodes created and managed by this tool as long as they still exist.",buttons=("Ok",))
    elif selection == 5:
        hou.ui.displayMessage("Allows the user to manually input the desire verison number to be used next time render is clicked. Note this number will be incremented afterwards.", buttons=("Ok",))
    elif selection == 6:
        hou.ui.displayMessage("Will reset all aspects of the tool to default settings. Including the removal of all currently in use nodes. Please be advised that once deleted the nodes can not be CTRL+Z and still function.",buttons=("Ok",))

All Rights Reserved as intellectual property

by Luke Vuilliomenet