Example #1
0
def sendJob():
    project_name = hou.hscriptExpression('$HIP').split('/')[len(hou.hscriptExpression('$HIP').split('/'))-1]
    copy_file = "cp " + hou.hscriptExpression('$HIP') + "/*" + " ~/Documents/houdini_render_farm/" + project_name + "; "
    main_string1 = '''ssh [email protected] -t "cd /opt/hfs14.0.444/; source houdini_setup; cp -n /mnt/dtop/''' + project_name + ''' /mnt/hq/; cd /mnt/hq/Projects/'''
    main_string2 = project_name + '''; echo 'render hq_render1' | hbatch ''' + hou.hscriptExpression('$HIPNAME') + ''';"'''
    execute = copy_file+main_string1+main_string2
    print execute
Example #2
0
    def replace_global_variable(self, string_value, global_variable_name):
        """
        Expand global_variable_name, check if this string is in string value and replace if so.
        """

        #check if variable exists
        try:

            hou.hscriptExpression('{0}'.format(global_variable_name))

        except:

            #log
            self.logger.debug('Global variable {0} does not exist. Not altering string value'.format(global_variable_name))
            return string_value


        #global_variable_value
        global_variable_value = hou.expandString('{0}'.format(global_variable_name))

        #replace
        string_value = string_value.replace(global_variable_value, global_variable_name)

        #return
        return string_value
Example #3
0
def pbPWD():
    path = hou.hscriptExpression('$HIP')
    
    if sys.platform == 'darwin':
        subprocess.check_call(['open', path])
    elif sys.platform == 'win32':
        subprocess.check_call(['explorer', path])
    else:
        subprocess.call(('xdg-open', path))
Example #4
0
def pbShotSize():
	folder = hou.hscriptExpression('$HIP')
	folder_size = 0
	for (path, dirs, files) in os.walk(folder):
	  for file in files:
	    filename = os.path.join(path, file)
	    folder_size += os.path.getsize(filename)
	#print "Folder = %0.1f MB" % (folder_size/(1024*1024.0))
	hou.ui.displayMessage("Project Size :\n %0.2f TB\n %0.2f GB\n %0.2f MB" % ((folder_size/(1024*1024.0*1024.0*1024.0)), (folder_size/(1024*1024.0*1024.0)), (folder_size/(1024*1024.0))), buttons=('OK',), title='pbShotSize')
Example #5
0
def bakeTranslation(pathToSource, pathToDest, startSampleFrame, endSampleFrame, stepFrame):
        #sample chop:
        frameValList = []
        for frame in range(startSampleFrame, endSampleFrame, stepFrame):
                hexprTX = 'chf(\"'+pathToSource+'\"/tx,'+str(frame)+')'
                hexprTY = 'chf(\"'+pathToSource+'\"/ty,'+str(frame)+')'
                hexprTZ = 'chf(\"'+pathToSource+'\"/tz,'+str(frame)+')'				
                retvalTX = hou.hscriptExpression(hexprTX)
                retvalTY = hou.hscriptExpression(hexprTY)
                retvalTZ = hou.hscriptExpression(hexprTZ)				
                valTX = float(retvalTX)
                valTY = float(retvalTY)
                valTZ = float(retvalTZ)				
                frameValList.append((frame, (valTX, valTY, valTZ)))
        #make keys:
	pathToDestTX = pathToDest+"/tx"
	pathToDestTY = pathToDest+"/ty"
	pathToDestTZ = pathToDest+"/tz"
	
        parmTX = hou.parm(pathToDestTX)
        parmTX.deleteAllKeyframes()

        parmTY = hou.parm(pathToDestTY)
        parmTY.deleteAllKeyframes()

        parmTZ = hou.parm(pathToDestTZ)
        parmTZ.deleteAllKeyframes()

        keyList = []
        for frameVal in frameValList:
                key = hou.Keyframe()
                key.setFrame(frameVal[0])
                key.setValue(frameVal[1][0])
                parmTX.setKeyframe(key)
		
                key = hou.Keyframe()
                key.setFrame(frameVal[0])
                key.setValue(frameVal[1][1])
                parmTY.setKeyframe(key)

                key = hou.Keyframe()
                key.setFrame(frameVal[0])
                key.setValue(frameVal[1][2])
                parmTZ.setKeyframe(key)
Example #6
0
def pbFindMe():    
    logpath = hou.hscriptExpression('$HIP')+'/pathlog.log'
    found = 0
    
    F = 'Find Me'
    R = 'Replace By'
    
    user_input = hou.ui.readMultiInput('Enter words to replace', (F, R), buttons=('Find', 'Replace', 'Cancle'), close_choice=2, title='pbFindMe')
    find = user_input[1][0]
    replace = user_input[1][1]
    
    if user_input[0] == 0:
        foundlist = '%s in %s\n\n\n' %(find, hou.hipFile.path()) + 'NODE' + ' '*46 + 'PARM' + '\n'
        for node in hou.node('/').allSubChildren():
            for parm in node.parms():
                template = parm.parmTemplate()
                if (template.type() == hou.parmTemplateType.String and
                        template.stringType() == hou.stringParmType.FileReference and
                        len(parm.keyframes()) == 0 and
                        parm.unexpandedString().find(find) >= 0):
                    path = parm.eval()
                    if path:
                        found += 1
                        foundlist += node.path() + ' '*(50 - len(node.path())) + parm.name()+'\n'
    
        if found:
            hou.ui.displayMessage(find + ' Found '+str(found)+' times !!!'+'\n\nLog file saved on: '+ logpath)
            logfile = open(logpath, 'w')
            logfile.write(foundlist)
            logfile.close()
            subprocess.Popen(['gedit',logpath])
            
        else:
            hou.ui.displayMessage('Can not find %s !!!' % find)
            
    if user_input[0] == 1:
        def fixFilePrefixes(node, from_prefix, to_prefix):
            for parm in node.parms():
                template = parm.parmTemplate()
                if (template.type() == hou.parmTemplateType.String and
                        template.stringType() == hou.stringParmType.FileReference and
                        len(parm.keyframes()) == 0 and
                        parm.unexpandedString().find(from_prefix) >= 0):
                    print 'Replacing %s to %s from:' %(find, replace), parm.path()
                    parm.set(parm.eval().replace(from_prefix, to_prefix))
                    
        nodes = hou.selectedNodes()
        if nodes:
            for node in nodes:
                fixFilePrefixes(node, find, replace)
                for child in node.allSubChildren():
                    fixFilePrefixes(child, find, replace)
        else:
            for node in hou.node('/').allSubChildren():
                fixFilePrefixes(node, find, replace)
Example #7
0
def bakeChop(pathToChop, pathToParm, startSampleFrame, endSampleFrame, stepFrame):
        #sample chop:
        frameValList = []
        for frame in range(startSampleFrame, endSampleFrame, stepFrame):
                hexpr = 'chopf(\"'+pathToChop+'\",'+str(frame)+')'
                retval = hou.hscriptExpression(hexpr)
                val = float(retval)
                frameValList.append((frame, val))
        #make keys:
        parm = hou.parm(pathToParm)
        parm.deleteAllKeyframes()

        keyList = []
        for frameVal in frameValList:
                key = hou.Keyframe()
                key.setFrame(frameVal[0])
                key.setValue(frameVal[1])
                parm.setKeyframe(key)
Example #8
0
#-*- coding:utf-8 -*-

import hou
import os
import json
import time
reload(time)
from collections import OrderedDict

# Slate에 작성될 GLOBAL 변수
hip_dir = hou.hscriptExpression("$HIP")
hip_name = hou.hscriptExpression("$HIPNAME")
# username = hou.hscriptExpression("$FXUSER")
username = '******'

# Simulation Log에 대한 json 데이터를 저장할 경로
log_dir = hip_dir + "/simulation_log"

hip_dict = {
    'hip_dir': hip_dir,
    'hip_name': hip_name,
    'username': username,
    'log_dir': log_dir
}

houdini_os = hou.hscriptExpression("$HOUDINI_OS")


def convert_path(path):
    if 'window' in houdini_os.lower():
        repath = path.replace('/', '\\\\')
Example #9
0
def bakeChopTransforms(pathToChop="/obj/cam_master/hdfchopNet/exportCamChop/cam_main_orig_mm", pathToNode="/obj/fx_cam_meters", startFrame=1003, endFrame=1564, stepFrame=1):
        #sample chop:
        frameValList = []
	pathToChopTX = pathToChop + "/tx"
	pathToChopTY = pathToChop + "/ty"
	pathToChopTZ = pathToChop + "/tz"
	pathToChopRX = pathToChop + "/rx"
	pathToChopRY = pathToChop + "/ry"
	pathToChopRZ = pathToChop + "/rz"		
        for frame in range(startSampleFrame, endSampleFrame, stepFrame):		
                hexpr = 'chopf(\"'+pathToChopTX+'\",'+str(frame)+')'
                retval = hou.hscriptExpression(hexpr)
                valTX = float(retval)		
                hexpr = 'chopf(\"'+pathToChopTY+'\",'+str(frame)+')'
                retval = hou.hscriptExpression(hexpr)
                valTY = float(retval)
                hexpr = 'chopf(\"'+pathToChopTZ+'\",'+str(frame)+')'
                retval = hou.hscriptExpression(hexpr)
                valTZ = float(retval)
                hexpr = 'chopf(\"'+pathToChopRX+'\",'+str(frame)+')'
                retval = hou.hscriptExpression(hexpr)
                valRX = float(retval)
                hexpr = 'chopf(\"'+pathToChopRY+'\",'+str(frame)+')'
                retval = hou.hscriptExpression(hexpr)
                valRY = float(retval)
                hexpr = 'chopf(\"'+pathToChopRZ+'\",'+str(frame)+')'
                retval = hou.hscriptExpression(hexpr)
                valRZ = float(retval)			
                frameValList.append((frame, (valTX, valTY, valTZ, valRX, valRY, valRZ)))
		
        #make keys:
        parmTX = hou.parm(pathToNode+"/tx")
        parmTX.deleteAllKeyframes()
        parmTY = hou.parm(pathToNode+"/ty")
        parmTY.deleteAllKeyframes()
        parmTZ = hou.parm(pathToNode+"/tz")
        parmTZ.deleteAllKeyframes()
        parmRX = hou.parm(pathToNode+"/rx")
        parmRX.deleteAllKeyframes()
        parmRY = hou.parm(pathToNode+"/ry")
        parmRY.deleteAllKeyframes()
        parmRZ = hou.parm(pathToNode+"/rz")
        parmRZ.deleteAllKeyframes()


        for frameVal in frameValList:
                key = hou.Keyframe()
                key.setFrame(frameVal[0])
                key.setValue(frameVal[1][0])
                parmTX.setKeyframe(key)
                key = hou.Keyframe()
                key.setFrame(frameVal[0])
                key.setValue(frameVal[1][1])
                parmTY.setKeyframe(key)
                key = hou.Keyframe()
                key.setFrame(frameVal[0])
                key.setValue(frameVal[1][2])
                parmTZ.setKeyframe(key)
                key = hou.Keyframe()
                key.setFrame(frameVal[0])
                key.setValue(frameVal[1][3])
                parmRX.setKeyframe(key)
                key = hou.Keyframe()
                key.setFrame(frameVal[0])
                key.setValue(frameVal[1][4])
                parmRY.setKeyframe(key)
                key = hou.Keyframe()
                key.setFrame(frameVal[0])
                key.setValue(frameVal[1][5])
                parmRZ.setKeyframe(key)
Example #10
0
# -*- coding: utf-8 -*-
import hou
import os
input_path = "test"

current_path = hou.hscriptExpression("$HIPFILE")
current_file = hou.hscriptExpression("$HIPNAME")

current_folder = current_path.split("/")[-1]

abc_name = current_file + ".abc"
render_ame = current_file + ".$F4.exr"

root_path = current_path.split(current_folder)[0]
abc_output_path = os.path.normpath(
    os.path.join(root_path, "abc", current_file, abc_name))
render_path = os.path.normpath(
    os.path.join(root_path, "render", current_file, render_ame))

abc_in = hou.node("/obj").createNode("geo", "alembic_reader")
hou.node("/obj/alembic_reader/file1").destroy()
abc_input = abc_in.createNode("alembic", "Input_alembic")
abc_input.parm("fileName").set(input_path)

abc_out = hou.node("/obj").createNode("geo", "alembic_output")
hou.node("/obj/alembic_output/file1").destroy()
abc_output = abc_out.createNode("rop_alembic", "Output_abc")
abc_output.parm("filename").set(abc_output_path)
abc_output.parm("trange").set(1)

render = hou.node("/out").createNode("ifd", "mantra_render")
Example #11
0
def job():
    return hou.hscriptExpression('$JOB')
Example #12
0
def hip():
    return hou.hscriptExpression('$HIP')
Example #13
0
File: 456.py Project: jonntd/helga




#Check if $HELGA_SHOT_NAME variable exists and if not, set it
#------------------------------------------------------------------

# HELGA_SHOT_NAME
HELGA_SHOT_NAME = '$HELGA_SHOT_NAME'

# check if variable exists
try:
    
    # check
    hou.hscriptExpression('{0}'.format(HELGA_SHOT_NAME))

    # variable_value
    variable_value = hou.expandString('{0}'.format(HELGA_SHOT_NAME))
    
    # SuccessMsg
    print('Variable {0} is set to {1}'.format(HELGA_SHOT_NAME, variable_value))

except:

    # FailMsg
    print('Variable {0} does not exist. Setting it to empty value.'.format(HELGA_SHOT_NAME))

    #set $HELGA_SHOT_NAME
    hou.hscript("set -g HELGA_SHOT_NAME = {0}".format(''))
Example #14
0
import random
import hou

################################################
# Collection of useful Houdini Python snippets #
################################################

################################################
# Incremental random
start = 0
stop  = 1
step  = 0.15
precision = 0.01
f = 1 / precision
random.seed(hou.hscriptExpression('stamp("..", "FORVALUE", +0)'))
value = random.randrange(start*f, stop*f, step*f)/f
return value

################################################
# FBX Import
hou.hscript("fbximport '%s'" % (geo_dir + '/' + file))

################################################
# Mantra prerender script to create missing folders
import os

nodeOutPath = hou.node(".").parm("vm_picture").eval()
path, name = os.path.split(nodeOutPath)
if not(os.path.isdir(path)):
    os.makedirs(path)
    print "%s directory has been created" % path
Example #15
0
def currentPanetab():
	panename = hou.hscriptExpression('mousepane()').split('.')[-1] 
	#print(panename)
	return hou.ui.findPaneTab(panename)
Example #16
0
BP_PIPELINE_PATH = BP_BASE_PATH + "/_pipeline"
BP_OTL_PATH = BP_PIPELINE_PATH + "/otl/publish"

BP_HDRI_PATH = BP_BASE_PATH + "/2_production/0_footage/hdri"

BP_RENDER_PATH = BP_BASE_PATH + "/2_production/3_render"

BP_SCRIPTS_PATH = BP_PIPELINE_PATH + "/houdini/"

BP_SHOTS_PATH = "{0}/2_production/2_shots".format(BP_BASE_PATH)

# Set / Get shot name
BP_SHOT_NAME = "$BP_SHOT_NAME"

try:
    hou.hscriptExpression(BP_SHOT_NAME)
    BP_SHOT_NAME_VALUE = hou.expandString("$BP_SHOT_NAME")

except:
    hou.hscript("set -g BP_SHOT_NAME = {0}".format(""))
    print("Initialized {0} to an empty value".format(BP_SHOT_NAME))


# Set Environment
# -----------------------------------------------------------------------------

try:
    hou.hscript("set -g BP_SHOT_NAME = {0}".format(BP_SHOT_NAME))
    hou.hscript("set -g BP_SHOTS_PATH = {0}".format(BP_SHOTS_PATH))
    hou.hscript("set -g BP_HDRI_PATH = {0}".format(BP_HDRI_PATH))
    hou.hscript("set -g BP_OTL_PATH = {0}".format(BP_OTL_PATH))
Example #17
0
def bakeTransforms(pathToSource, pathToDest, startSampleFrame, endSampleFrame, stepFrame):
        frameValList = []
        for frame in range(startSampleFrame, endSampleFrame, stepFrame):
                hexprTX = 'chf(\"'+pathToSource+'\"/tx,'+str(frame)+')'
                hexprTY = 'chf(\"'+pathToSource+'\"/ty,'+str(frame)+')'
                hexprTZ = 'chf(\"'+pathToSource+'\"/tz,'+str(frame)+')'
                hexprRX = 'chf(\"'+pathToSource+'\"/rx,'+str(frame)+')'
                hexprRY = 'chf(\"'+pathToSource+'\"/ry,'+str(frame)+')'
                hexprRZ = 'chf(\"'+pathToSource+'\"/rz,'+str(frame)+')'						
                retvalTX = hou.hscriptExpression(hexprTX)
                retvalTY = hou.hscriptExpression(hexprTY)
                retvalTZ = hou.hscriptExpression(hexprTZ)
                retvalRX = hou.hscriptExpression(hexprTX)
                retvalRY = hou.hscriptExpression(hexprTY)
                retvalRZ = hou.hscriptExpression(hexprTZ)				
		
                TX = float(retvalTX)
                TY = float(retvalTY)
                TZ = float(retvalTZ)
                RX = float(retvalRX)
                RY = float(retvalRY)
                RZ = float(retvalRZ)
						
                frameValList.append((frame, (TX, TY, TZ, RX, RY, RZ)))
		
        #make keys:
	pathToDestTX = pathToDest+"/tx"
	pathToDestTY = pathToDest+"/ty"
	pathToDestTZ = pathToDest+"/tz"
	pathToDestRX = pathToDest+"/rx"
	pathToDestRY = pathToDest+"/ry"
	pathToDestRZ = pathToDest+"/rz"
	
        parmTX = hou.parm(pathToDestTX)
        parmTX.deleteAllKeyframes()

        parmTY = hou.parm(pathToDestTY)
        parmTY.deleteAllKeyframes()

        parmTZ = hou.parm(pathToDestTZ)
        parmTZ.deleteAllKeyframes()

        parmRX = hou.parm(pathToDestRX)
        parmRX.deleteAllKeyframes()

        parmRY = hou.parm(pathToDestRY)
        parmRY.deleteAllKeyframes()

        parmRZ = hou.parm(pathToDestRZ)
        parmRZ.deleteAllKeyframes()

        keyList = []
        for frameVal in frameValList:
                key = hou.Keyframe()
                key.setFrame(frameVal[0])
                key.setValue(frameVal[1][0])
                parmTX.setKeyframe(key)
		
                key = hou.Keyframe()
                key.setFrame(frameVal[0])
                key.setValue(frameVal[1][1])
                parmTY.setKeyframe(key)

                key = hou.Keyframe()
                key.setFrame(frameVal[0])
                key.setValue(frameVal[1][2])
                parmTZ.setKeyframe(key)

                key = hou.Keyframe()
                key.setFrame(frameVal[0])
                key.setValue(frameVal[1][3])
                parmRX.setKeyframe(key)

                key = hou.Keyframe()
                key.setFrame(frameVal[0])
                key.setValue(frameVal[1][4])
                parmRY.setKeyframe(key)

                key = hou.Keyframe()
                key.setFrame(frameVal[0])
                key.setValue(frameVal[1][5])
                parmRZ.setKeyframe(key)