Example #1
0
def setProject():
    import os
    # get root dir
    start_dir = hou.expandString("$HMEGA") + "/! Projects/"
    answer = hou.ui.selectFile(start_directory=start_dir,
                               file_type=hou.fileType.Directory)

    if answer is not '':
        # Make dirs
        os.makedirs(answer)
        os.makedirs(answer + "/Hip")
        os.makedirs(answer + "/Flipbook")
        os.makedirs(answer + "/Render")
        os.makedirs(answer + "/Cache")
        os.makedirs(answer + "/Cache/Abc")
        os.makedirs(answer + "/Cache/Sim")
        os.makedirs(answer + "/Cache/Stash")
        os.makedirs(answer + "/Cache/Redshift")

        hipname = answer.split("/").pop()

        hou.appendSessionModuleSource(
            "import lzutil\nlzutil.updateJobFromHipLocation()")

        hou.hscript('setenv JOBNAME =' + hipname)
        #print answer
        hou.hscript('setenv JOB =' + answer)

        hou.hipFile.save(answer + "/hip/" + hipname + ".000" + ".hip")

        print("Updated JOBNAME to: " + hipname)
        print("Updated JOB to: " + answer)
Example #2
0
def installOtlLibsUI():
	import glob
	path = hou.expandString('$OTLS') + "\\*/"
	libs =  glob.glob(path)
	libs = [e.split("\\")[-2] for e in libs]
	print libs

	answer =  hou.ui.selectFromList(libs)
	for ans in answer:
		lib = libs[ans]
		installOtlLib(lib)
		print  "\nimport lzutil\nlzutil.installOtlLib('"+lib +"')"
		hou.appendSessionModuleSource( "import lzutil\nlzutil.installOtlLib('"+lib +"')" )
    def create_box_subnet():
        obj = hou.node('/obj')
        box_geo = obj.createNode('geo', 'box_geo', run_init_scripts=False)

        box1 = box_geo.createNode('box', 'box1')
        box1.parm('scale').set(0.8)

        box2 = box_geo.createNode('box', 'box2')
        box2.parmTuple('size').set((0.5, 0.5, 0.5))

        copy = box_geo.createNode('copytopoints', 'copy')
        copy.parm('transform').set(False)
        copy.setInput(0, box2)
        copy.setInput(1, box1)

        hou.appendSessionModuleSource('volume_size = 100')
        hou.appendSessionModuleSource('volume_amp = 10')

        python_code = """
                      node = hou.pwd()
                      geo = node.geometry()
                      temp = hou.Geometry()
                      sops = hou.sopNodeTypeCategory()
                      box = sops.nodeVerb("box")
                      box.setParms({'scale':1.2})
                      box.execute(temp, [])
                      vdb = sops.nodeVerb("vdbfrompolygons")
                      vdb.setParms({'builddistance':0,'buildfog':1,'voxelsize':0.02})
                      vdb.execute(temp, [temp])
                      geo.merge(temp)
                      """
        python = box_geo.createNode('python', 'python')
        python.parm('python').set(textwrap.dedent(python_code))
        python.setInput(0, copy)

        xform = box_geo.createNode('xform', 'xform')
        xform.setInput(0, python)
        xform.setDisplayFlag(True)
        xform.setRenderFlag(True)

        note = box_geo.createStickyNote('test_note')
        note.setText('This is a test note')

        box_geo.layoutChildren()
        note.setPosition(xform.position() + hou.Vector2((2, 0)))

        children = (box1, box2, copy, python, xform, note)
        box_subnet = box_geo.collapseIntoSubnet(children,
                                                subnet_name='box_subnet')
        return box_subnet
 def init_Session(self):
     HOUDINI_SESSION_PATH = self.project.HOUDINI_SESSION_PATH
     for (k, v) in HOUDINI_SESSION_PATH.items():
         hou.appendSessionModuleSource('{}="{}"'.format(k, v))
Example #5
0
'''
文件复制到 %HOMEPATH%\Documents\houdini17.0\scripts\456.py
或在 houdini.env 文件里加入 "HOUDINI_PATH = 路径",会自动读取路径里的 scripts\456.py
'''

import hou
import os


hou.setFps(25)
hou.appendSessionModuleSource('''hou.hscript("autosave off")''')


def SetProjectPath():
    '''
    从 $HIPFILE 路径后面往前,搜到带 "houdini" 就设置此路径为 $JOB
    '''
    filePath = hou.hipFile.path()
    filePath = filePath.split('/')
    for i in range(len(filePath)):
        if 'houdini' in filePath[-1].lower():
            break
        filePath.pop()
    prjPath = '/'.join(filePath)
    hou.putenv('JOB', prjPath)
    print('$' + 'JOB = ' + hou.getenv('JOB', 'None'))
SetProjectPath()


def Install_HDA(path, hdaFolderWhiteLists=['hda','otls'], hdaFolderBlacklists=['old','olds','backup','history'], hdaExtension=['.hda','.otl']):
    '''