コード例 #1
0
    def _addRemoveParm(
            self,
            parm,
            add=True):  ## does this expect a parm name obk or path?!

        node_path = parm.node().path()
        cur_take = curTake()
        cur_update_mode = hou.updateModeSetting()
        hou.setUpdateMode(hou.updateMode.Manual)
        setCurTake(self)

        remove_flag = ''
        if add != True:
            remove_flag = '-u '

        hscript_cmd = 'takeinclude ' + remove_flag + node_path + ' ' + parm.name(
        )
        hscript_cmd_results = hou.hscript(hscript_cmd)

        if _takeErr(hscript_cmd_results[1]):
            result = hscript_cmd_results[1]
        else:
            result = None

        setCurTake(cur_take)
        hou.setUpdateMode(cur_update_mode)

        return result
コード例 #2
0
    def addParmsFromTake(self, take, overwrite_existing=True):
        '''Include parameters from the specified Take in this Take.'''

        cur_take = curTake()
        cur_update_mode = hou.updateModeSetting()
        hou.setUpdateMode(hou.updateMode.Manual)
        setCurTake(self)

        force_flag = ''
        if overwrite_existing == True:
            force_flag = '-f '

        source = take.name()

        hscript_cmd = 'takemerge ' + force_flag + ' ' + self._name + ' ' + source
        hscript_cmd_results = hou.hscript(hscript_cmd)
        if _takeErr(hscript_cmd_results[1]):
            result = hscript_cmd_results[1]
        else:
            result = None

        setCurTake(cur_take)
        hou.setUpdateMode(cur_update_mode)

        return result
コード例 #3
0
ファイル: takes.py プロジェクト: hibernationTheory/sQuery
	def addParmsFromTake(self, take, overwrite_existing=True):
		
		'''Include parameters from the specified Take in this Take.'''
		
		cur_take = curTake()
		cur_update_mode = hou.updateModeSetting()
		hou.setUpdateMode(hou.updateMode.Manual)
		setCurTake(self)
		
		force_flag = ''
		if overwrite_existing == True:
			force_flag = '-f '
			
		source = take.name()
			
		hscript_cmd = 'takemerge ' + force_flag + ' ' + self._name +  ' ' + source
		hscript_cmd_results = hou.hscript(hscript_cmd)
		if _takeErr(hscript_cmd_results[1]):
			result = hscript_cmd_results[1]
		else:
			result = None
			
		setCurTake(cur_take)
		hou.setUpdateMode(cur_update_mode)
		
		return result
コード例 #4
0
def init_setup_the_scene(fps, in_frame, out_frame):
    """ set the scene in Manual """
    hou.setUpdateMode(hou.updateMode.Manual)
    """ set the timeline """
    hou.setFps(fps)
    hou.hscript("tset `((%s-1)/$FPS)` `(%s/$FPS)`" % (in_frame, out_frame))
    hou.playbar.setPlaybackRange(in_frame, out_frame)
    hou.setFrame(in_frame)
コード例 #5
0
ファイル: pdg_mutagen.py プロジェクト: TimeVfx/pdg_mutagen
def setupMutationFromMarkedWedges(marked_idx_list, wedge_anchor_node):

    print "\n\nSetup Starting...\n"

    idx_list = marked_idx_list
    wedge_node = wedge_anchor_node
    num_wedges = len(idx_list)

    #get current update mode
    update_mode_set = hou.updateModeSetting()
    #set update mode to manual
    hou.setUpdateMode(hou.updateMode.Manual)
    #set auto takes on
    hou.hscript("takeautomode on")

    #get root take
    roottake = hou.takes.rootTake()
    print "Root Take: {}".format(roottake.name())

    #cook pdg node first
    pdgnode = wedge_node.getPDGNode()
    #generate static items first to be able to access
    wedge_node.generateStaticItems()
    time.sleep(1.5)
    work_items = pdgnode.staticWorkItems

    #remove all existing takes first
    takes = roottake.children()
    for take in takes:
        take.destroy()

    #convert wedges to takes
    for idx in idx_list:
        take = roottake.addChildTake(idx)
        hou.takes.setCurrentTake(take)

        selectWedgeIndex(idx, wedge_node, work_items)

    #return to root take
    hou.takes.setCurrentTake(roottake)

    #reset update mode
    hou.setUpdateMode(update_mode_set)
    #set auto takes off
    hou.hscript("takeautomode off")

    print "\nSuccessfully converted Wedges to Takes\n"

    #create new wedge node in same Topnet as wedge_anchor_node
    topnet = wedge_node.parent()
    new_wedge_node = topnet.createNode("wedge", "wedge_base_from_marked")

    new_wedge_node.setPosition(wedge_node.position())
    new_wedge_node.move([-5, 0])
    #new_wedge_node.setSelected(1, clear_all_selected=True)

    remove_takes = True
    convertTakesToWedge(new_wedge_node, remove_takes)
コード例 #6
0
def manual():
    """setup scene to manual mode
    """
    help(manual)

    import hou
    mode = hou.updateModeSetting().name()
    if mode == 'AutoUpdate':
        hou.setUpdateMode(hou.updateMode.Manual)
    if mode == 'Manual':
        hou.setUpdateMode(hou.updateMode.AutoUpdate)
コード例 #7
0
    def __init__(self,nodes):
        super(live_renamer,self).__init__(hou.qt.mainWindow())
        self.nodes=nodes
        self.updateMode=hou.updateModeSetting()
        
        hou.setUpdateMode(hou.updateMode.Manual)

        self.storeNames()
        self.configure_dialog()
        self.widgets()
        self.layout()
        self.connections()
コード例 #8
0
def exit():
    """
    change scene mode in manual, save, and exit 
    """
    help(exit)
    import hou

    mode = hou.updateModeSetting().name()
    if mode == 'AutoUpdate':
        hou.setUpdateMode(hou.updateMode.Manual)
    hou.hipFile.save(file_name=None, save_to_recent_files=True)
    hou.exit(exit_code=0, suppress_save_prompt=False)
コード例 #9
0
def updateModeToggle():
    '''
    Toggle cook mode between 'auto update' and 'manual'.

    Author: Sean
    '''
    mode = hou.updateModeSetting().name()

    if mode == 'AutoUpdate':
        hou.setUpdateMode( hou.updateMode.Manual )

    if mode == 'Manual':
        hou.setUpdateMode( hou.updateMode.AutoUpdate )
コード例 #10
0
def open():
    """change scene mode in manual, save, and open open windows"""

    help(open)

    import hou

    mode = hou.updateModeSetting().name()
    if mode == 'AutoUpdate':
        hou.setUpdateMode(hou.updateMode.Manual)

    hou.hipFile.save(file_name=None, save_to_recent_files=True)
    f = hou.ui.selectFile()
    hou.hipFile.load(f)
コード例 #11
0
def loop_through_dir(dir):
    sub_dirs = os.listdir(dir)
    for sub_dir in sub_dirs:
        path = dir + sub_dir
        if os.path.isdir(path) and not re.findall(".*?(?:bak|temp|back).*$",
                                                  path):
            loop_through_dir(path + "/")
        elif re.findall(".*?hip$", sub_dir):
            print "loaded: " + path
            hou.hipFile.load(path,
                             suppress_save_prompt=False,
                             ignore_load_warnings=True)
            hou.setSimulationEnabled(0)
            hou.setUpdateMode(hou.updateMode.Manual)
            write_sticky_to_file()
コード例 #12
0
def run():
    hou.hipFile.addEventCallback(scene_event_callback)
    hou.hipFile.clear(suppress_save_prompt=False)
    with hou.undos.group("Demo"):
        hou.setUpdateMode(hou.updateMode.Manual)
        demobox.DemoBox()
        create_cam()
        hou.setUpdateMode(hou.updateMode.AutoUpdate)
        hou.playbar.setRealTime(True)
        hou.setFrame(25)
        create_mantra()
        create_cop()
        hou.node('/obj').layoutChildren()
    hou.hipFile.removeEventCallback(scene_event_callback)
    hou.hipFile.save(hou.hscriptExpandString('$TEMP') + '/demo.hip')
コード例 #13
0
        def jump_to(self):
            if str(hou.updateModeSetting()) == 'updateMode.Manual':
                pass
            else:
                hou.ui.displayMessage('设置 updateMode 为 Manual',
                                      buttons=('确认', ),
                                      title='')
                hou.setUpdateMode(hou.updateMode.Manual)
            sl = self.tableWidget.selectedIndexes()

            try:
                rs = sl[0].row()
                node_path = self.tableWidget.item(rs, 2).text()
                hou.node(node_path).setCurrent(1, 1)
            except:
                pass
コード例 #14
0
def quatreCinqSix():
    """ set the houdini desktop 
    """

    help(quatreCinqSix)

    import hou

    #decrire la configuration du desktop avec python
    # close treeView close python open spreadsheet,chage parameter to python
    desktops_dict = dict((d.name(), d) for d in hou.ui.desktops())
    desktops_dict['Technical2'].setAsCurrent()

    mode = hou.updateModeSetting().name()
    if mode == 'AutoUpdate':
        hou.setUpdateMode(hou.updateMode.Manual)
コード例 #15
0
def createAlembic(data, sender="", settings=None):
    
    hou.setUpdateMode(hou.updateMode.Manual)
    
    fileName = data["NAME"]
    filePath = fetchMyReceivedFilesFolder() + os.sep + fileName
    filePath = incrementFile(filePath)
    
    with open(filePath, 'wb') as f:
        f.write(data["DATA"])
    
    geo = hou.node("/obj").createNode("geo", run_init_scripts=False)
    geo.setName("Alembic_container_from_" + sender, unique_name=True)
    geo.appendComment("Alembic_container_from_" + sender)
    
    alembicNode = geo.createNode("alembic")
    alembicNode.parm("fileName").set(filePath)
    
    return True
コード例 #16
0
ファイル: takes.py プロジェクト: hibernationTheory/sQuery
	def addAllParmsOfNode(self, node):
		
		'''Include all parameters from specified Node in this Take'''
		
		node_path = node.path()
		cur_take = curTake()
		cur_update_mode = hou.updateModeSetting()
		hou.setUpdateMode(hou.updateMode.Manual)
		setCurTake(self)

		hscript_cmd = 'takeinclude ' + node_path + ' *'
		hscript_cmd_results = hou.hscript(hscript_cmd)

		if  _takeErr(hscript_cmd_results[1]):
			result = hscript_cmd_results[1]
		else: result = None

		setCurTake(cur_take)
		hou.setUpdateMode(cur_update_mode)
		
		return result
コード例 #17
0
    def addAllParmsOfNode(self, node):
        '''Include all parameters from specified Node in this Take'''

        node_path = node.path()
        cur_take = curTake()
        cur_update_mode = hou.updateModeSetting()
        hou.setUpdateMode(hou.updateMode.Manual)
        setCurTake(self)

        hscript_cmd = 'takeinclude ' + node_path + ' *'
        hscript_cmd_results = hou.hscript(hscript_cmd)

        if _takeErr(hscript_cmd_results[1]):
            result = hscript_cmd_results[1]
        else:
            result = None

        setCurTake(cur_take)
        hou.setUpdateMode(cur_update_mode)

        return result
コード例 #18
0
def separateObject():
    selectedNode = hou.selectedNodes()
    geoPath = hou.node(
        selectedNode[0].children()[0].path()).parm("file").eval()
    subnetName = selectedNode[0].name()
    out = hou.node(selectedNode[0].path()).createNode("group", "out")
    hou.node(out.path()).parm("docreategrp").set(0)
    hou.node(out.path()).parm("destroyname").set("gGeo default")
    out.setFirstInput(selectedNode[0].children()[0])
    out.setDisplayFlag(1)

    out = hou.node(selectedNode[0].path()).displayNode()
    geo = out.geometry()
    objects = []

    for n in geo.primGroups():
        currentNode = hou.node("/obj").createNode("geo", n.name())
        objects.append(currentNode)
        currentNode.children()[0].destroy()
        fileNode = currentNode.createNode("file", n.name())
        hou.node(currentNode.children()[0].path()).parm("file").set(geoPath)
        facetNode = hou.node(currentNode.path()).createNode(
            "facet", "postcomputenormal")
        facetNode.setFirstInput(fileNode)
        hou.node(facetNode.path()).parm("postnml").set(1)
        deleteNode = hou.node(currentNode.path()).createNode(
            "delete", "isolate_" + str(currentNode))
        deleteNode.setFirstInput(facetNode)
        hou.node(deleteNode.path()).parm("group").set(str(currentNode))
        hou.node(deleteNode.path()).parm("negate").set(1)
        deleteNode.setDisplayFlag(1)
        deleteNode.setRenderFlag(1)
        #        deleteNode.setHardLocked(1)
        hou.node(currentNode.path()).layoutChildren()

    selectedNode[0].destroy()
    parentObjects = objects[0].parent()
    subnet = parentObjects.collapseIntoSubnet(objects, subnetName)
    hou.node(subnet.path()).layoutChildren()
    hou.setUpdateMode(hou.updateMode.AutoUpdate)
コード例 #19
0
ファイル: takes.py プロジェクト: hibernationTheory/sQuery
	def _addRemoveFlag(self, node,flag, add=True):
		
		cur_take = curTake()
		cur_update_mode = hou.updateModeSetting()
		hou.setUpdateMode(hou.updateMode.Manual)
		setCurTake(self)
		
		remove_flag = ''
		if add != True:
			remove_flag = '-u '
		
		hscript_cmd = 'takeinclude ' + remove_flag + '-' + flag +  ' ' + node.path()
		hscript_cmd_results = hou.hscript(hscript_cmd)
		if _takeErr(hscript_cmd_results[1]):
			result = hscript_cmd_results[1]
		else:
			result = None
			
		setCurTake(cur_take)
		hou.setUpdateMode(cur_update_mode)
		
		return result
コード例 #20
0
ファイル: utils.py プロジェクト: horitin/pipeline
def separateObject():
    selectedNode=hou.selectedNodes()
    geoPath=hou.node(selectedNode[0].children()[0].path()).parm("file").eval()
    subnetName=selectedNode[0].name()
    out=hou.node(selectedNode[0].path()).createNode("group","out")
    hou.node(out.path()).parm("docreategrp").set(0)
    hou.node(out.path()).parm("destroyname").set("gGeo default")
    out.setFirstInput(selectedNode[0].children()[0])
    out.setDisplayFlag(1)
    
    out=hou.node(selectedNode[0].path()).displayNode()
    geo = out.geometry()
    objects = []
    

    for n in geo.primGroups():
	currentNode=hou.node("/obj").createNode("geo",n.name())
        objects.append(currentNode)
        currentNode.children()[0].destroy()
        fileNode=currentNode.createNode("file",n.name())
        hou.node(currentNode.children()[0].path()).parm("file").set(geoPath)
        facetNode=hou.node(currentNode.path()).createNode("facet","postcomputenormal")
        facetNode.setFirstInput(fileNode)
        hou.node(facetNode.path()).parm("postnml").set(1)
        deleteNode=hou.node(currentNode.path()).createNode("delete","isolate_"+str(currentNode))
        deleteNode.setFirstInput(facetNode)
        hou.node(deleteNode.path()).parm("group").set(str(currentNode))
        hou.node(deleteNode.path()).parm("negate").set(1)
        deleteNode.setDisplayFlag(1)
        deleteNode.setRenderFlag(1)
#        deleteNode.setHardLocked(1)
        hou.node(currentNode.path()).layoutChildren()
    
    
    selectedNode[0].destroy()
    parentObjects=objects[0].parent()
    subnet=parentObjects.collapseIntoSubnet(objects,subnetName)
    hou.node(subnet.path()).layoutChildren()
    hou.setUpdateMode(hou.updateMode.AutoUpdate)
コード例 #21
0
ファイル: takes.py プロジェクト: hibernationTheory/sQuery
	def _addRemoveParm(self, parm, add=True): ## does this expect a parm name obk or path?!
	
		node_path = parm.node().path()
		cur_take = curTake()
		cur_update_mode = hou.updateModeSetting()
		hou.setUpdateMode(hou.updateMode.Manual)
		setCurTake(self)
		
		remove_flag = ''
		if add != True:
			remove_flag = '-u '
		
		hscript_cmd = 'takeinclude ' + remove_flag + node_path + ' ' + parm.name()
		hscript_cmd_results = hou.hscript(hscript_cmd)
		
		if  _takeErr(hscript_cmd_results[1]):
			result = hscript_cmd_results[1]
		else: result = None

		setCurTake(cur_take)
		hou.setUpdateMode(cur_update_mode)
		
		return result
コード例 #22
0
    def _addRemoveFlag(self, node, flag, add=True):

        cur_take = curTake()
        cur_update_mode = hou.updateModeSetting()
        hou.setUpdateMode(hou.updateMode.Manual)
        setCurTake(self)

        remove_flag = ''
        if add != True:
            remove_flag = '-u '

        hscript_cmd = 'takeinclude ' + remove_flag + '-' + flag + ' ' + node.path(
        )
        hscript_cmd_results = hou.hscript(hscript_cmd)
        if _takeErr(hscript_cmd_results[1]):
            result = hscript_cmd_results[1]
        else:
            result = None

        setCurTake(cur_take)
        hou.setUpdateMode(cur_update_mode)

        return result
コード例 #23
0
ファイル: openBackUp.py プロジェクト: sugiggy/Houdini
import hou
import os

#username = getpass.getuser()

#dir = '/mnt/LOCAL/TMP/'
#print dir
dir = hou.getenv("HOUDINI_TEMP_DIR") + "/"
print dir
files = []
for file in os.listdir(dir):
    if file.endswith(".hiplc"):
        files.append(dir + file)
newest = max(files, key=os.path.getctime)
#print newest

hou.setUpdateMode(hou.updateMode.Manual)
hou.hipFile.load(newest)
コード例 #24
0
def execute():
    if hou.ui.updateMode() == hou.updateMode.AutoUpdate:
        hou.setUpdateMode(hou.updateMode.Manual)
    else:
        hou.setUpdateMode(hou.updateMode.AutoUpdate)
        hou.ui.triggerUpdate()
def convertTakesToWedge(wedge_node, remove_takes):

    print "\n\nStarting to convert Takes to TOP Wedge...\n"
    print "_" * 100
    print "\n"

    wedge = wedge_node
    rem_takes = remove_takes

    #get current update mode
    update_mode_set = hou.updateModeSetting()
    #set update mode to manual
    hou.setUpdateMode(hou.updateMode.Manual)

    #get takelist and sort, get take number
    roottake = hou.takes.rootTake()
    takes = roottake.children()

    takelist = []
    for take in takes:
        takelist.append(take.name())
    #takelist = sorted(takelist)
    num_takes = len(takelist)

    print "Root Take: {}".format(roottake.name())
    print "Number of Child Takes / Wedge Count: {}".format(num_takes)
    print "Takelist: " + str(takelist) + "\n"

    #check if child takes present
    if num_takes > 0:
        #collect all edited parms in takes
        takeparm_list = []

        for takename in takelist:
            take = hou.takes.findTake(takename)
            #print "Takename: " + take.name()

            takeparms = take.parmTuples()
            for takeparm in takeparms:
                if takeparm not in takeparm_list:
                    takeparm_list.append(takeparm)
                    #print "Take Parameter appended to list: " + str(takeparm)

        num_takeparms = len(takeparm_list)
        print "{} edited Parameters found in Takes\n".format(num_takeparms)

        print "\nProcessing all edited Parameters in Takes."
        print "This might take up to a couple of minutes for very complex setups..."

        #set inital parms
        parm_wedgecount = wedge.parm("wedgecount")
        parm_wedgecount.set(num_takes)

        parm_wedgeattribs = wedge.parm("wedgeattributes")
        parm_wedgeattribs.set(num_takeparms)

        parm_preservenum = wedge.parm("preservenum")
        parm_preservenum.set(1)

        parm_previewselection = wedge.parm("previewselection")
        parm_previewselection.set(1)

        #edit interface wo hide wedge attribute parms for preformance

        parm_group = wedge.parmTemplateGroup()
        attribs_parm_temp = parm_group.find("wedgeattributes")
        attribs_parm_temp_clone = attribs_parm_temp.clone()

        new_parm_folder = hou.FolderParmTemplate(
            "parent_folder",
            "Wedge Attributes (Hidden)",
            folder_type=hou.folderType.Collapsible,
            default_value=0,
            ends_tab_group=False)

        parm_group.remove(attribs_parm_temp)
        new_parm_folder.addParmTemplate(attribs_parm_temp_clone)
        parm_group.append(new_parm_folder)

        wedge.setParmTemplateGroup(parm_group)

        #fill in takeparms
        i = 1
        for takeparm in takeparm_list:

            #print takeparm
            #list of parm tuples!!!
            takeparm_path = takeparm.node().path() + "/" + takeparm.name()

            takeparm_type = type(takeparm[0].eval())
            takeparm_is_tuple = len(takeparm) > 1

            #print takeparm.eval()
            #print takeparm_type
            #print "Is Tuple: " + str(takeparm_is_tuple)

            #set
            parm_name = wedge.parm("name" + str(i))
            parm_name.set(takeparm.name() + "_" + str(i))

            parm_exportchannel = wedge.parm("exportchannel" + str(i))
            parm_exportchannel.set(1)

            parm_channel = wedge.parm("channel" + str(i))
            parm_channel.set(takeparm_path)

            parm_type = wedge.parm("type" + str(i))
            if takeparm_type == float and takeparm_is_tuple == False:
                parm_type.set(0)
            if takeparm_type == float and takeparm_is_tuple == True:
                parm_type.set(1)
            if takeparm_type == int and takeparm_is_tuple == False:
                parm_type.set(2)
            if takeparm_type == int and takeparm_is_tuple == True:
                parm_type.set(3)
            if takeparm_type == str:
                parm_type.set(4)

            parm_wedgetype = wedge.parm("wedgetype" + str(i))
            parm_wedgetype.set(2)

            parm_values = wedge.parm("values" + str(i))
            parm_values.set(num_takes)

            #incr
            i += 1

        #iterate over takes again, actually set them active and evaluate & set corresponding parms in wedge
        root_take = hou.takes.rootTake()

        t = 1
        for takename in takelist:
            take = hou.takes.findTake(takename)
            #print "Set to Take: " + take.name()
            hou.takes.setCurrentTake(take)

            #fill in takeparms again with evalueted values from takes
            i = 1
            for takeparm in takeparm_list:

                #takeparm attribs
                takeparm_path = takeparm.node().path() + "/" + takeparm.name()

                takeparm_type = type(takeparm[0].eval())
                takeparm_size = len(takeparm)
                takeparm_is_tuple = takeparm_size > 1

                #check type and set valname accordingly
                if takeparm_type == float and takeparm_is_tuple == False:
                    valname = "floatvalue"
                if takeparm_type == float and takeparm_is_tuple == True:
                    valname = "floatvector"
                if takeparm_type == int and takeparm_is_tuple == False:
                    valname = "intvalue"
                if takeparm_type == int and takeparm_is_tuple == True:
                    valname = "intvector"
                if takeparm_type == str:
                    valname = "strvalue"

                #if tuple and size is 3 append 0 so it matches size of vector4 tuples in wedge node

                parm_val = wedge.parmTuple(valname + str(i) + "_" + str(t))

                if takeparm_size == 3:
                    val_t = takeparm.eval()
                    val_l = list(val_t)
                    val_l.append(0)
                    val = tuple(val_l)

                else:
                    val = takeparm.eval()

                #include parm_val in take so its editable
                take.addParmTuple(parm_val)
                #go back to root take
                hou.takes.setCurrentTake(root_take)
                #set value
                parm_val.set(val)
                #go back to current take
                hou.takes.setCurrentTake(take)
                #exclude parm_val in take to clear
                take.removeParmTuple(parm_val)

                #incr
                i += 1

            #incr
            t += 1

            #remove takes if chosen
            if rem_takes == True:
                #print "Take deleted"
                take.destroy()

        hou.takes.setCurrentTake(root_take)
        #print "\nReset to Root Take"

        #select node
        wedge.setSelected(on=True, clear_all_selected=True)
        wedge.setCurrent(1)

        print "\n"
        print "_" * 100
        print "Takes successfully converted to TOP Wedge."
        print "Creating Node UI, this might take another couple seconds."
        print "_" * 100
        print "\n" * 2

    #exception when no child takes found
    else:
        raise Exception("No Child Takes found.")

    #reset update mode
    hou.setUpdateMode(update_mode_set)
コード例 #26
0
# directly taken from a sidefx forum post
import hou
mode = hou.updateModeSetting().name()

if mode == 'AutoUpdate':
	hou.setUpdateMode(hou.updateMode.Manual)
if mode == 'Manual':
	hou.setUpdateMode(hou.updateMode.AutoUpdate)

コード例 #27
0
ファイル: collectFiles.py プロジェクト: Tronotrond/Houdini
def CollectSceneAssets(settings):
    IGNORE_BYPASSED = settings[0]
    IGNORE_PROXY = settings[1]
    IGNORE_NONDISPLAY = settings[2]
    FILTER_FILETYPES = settings[3]
    FILETYPES = settings[4]
    
    SceneAssets = []

    #Set to frame 0 and update to manual
    hou.setUpdateMode(hou.updateMode.Manual)        
    hou.setFrame(hou.playbar.playbackRange()[0])    
    #hou.hipFile.save()
    
    #collect all file references
    refs = hou.fileReferences():  
    
    # Find file caches and remove file references above in the same network   
    # We'll end up looping through twice for this
    for file_parm, file in refs:
        #IF file parameter is None, it's an HDA or something we shouldn't need to include
        if file_parm is None: 
            continue;
        if isinstance(file_parm.node(), hou.SopNode):
            if file_parm.name() == "file":
                p = file_parm.path().split("/")
                #SKIP IF WRITE OUT NODE - TWO FILES NODES EXISTS IN EACH FILE CACHE
                if "file_mode" in p:
                    continue;
                if file_parm
        
    
    string = "----\n\n"
    for file_parm, file in refs:
        #IF file parameter is None, it's an HDA or something we do not need to include
        if file_parm is None: 
            continue;
        
        #Remove ROP file references
        if type(file_parm.node()) == hou.RopNode:        
            continue;
        
        # Finding and ignoring referenced SOPs and not displayed
        # Hacky way, iterate 10 times; Returns the referenced parameter. If no parameter is referenced, returns this parameter.
        for i in xrange(10): 
            file_parm = file_parm.getReferencedParm()
            
        # Check and skip if node is disabled
        if IGNORE_BYPASSED and file_parm.isDisabled():
            continue;
        #Check if bypassed
        if IGNORE_BYPASSED and file_parm.node().isGenericFlagSet(hou.nodeFlag.Bypass):
            continue;
            
        # Testing for display flag. 
        # DOES NOT WORK because of assets objs are hidden
        """
        disp = True
        if isinstance(file_parm.node(), hou.SopNode):
            top = getObjParent(file_parm.node())
            if top:
                disp = top.isGenericFlagSet(hou.nodeFlag.Display)
        if IGNORE_NONDISPLAY and not disp:
            continue;
        """
        
        # GET FILE CACHE SOPS AND FILE RANGES
        if isinstance(file_parm.node(), hou.SopNode):
            if file_parm.name() == "file":
                p = file_parm.path().split("/")
                #SKIP IF WRITE OUT NODE - TWO FILES NODES EXISTS IN EACH FILE CACHE
                if "file_mode" in p:
                    continue;
                startFr = file_parm.node().parm("f1").eval()
                endFr = file_parm.node().parm("f2").eval()
                # Adjust frame ranges from which is smallest. Render or file cache range.
                if frameRange[0] > startFr:
                    startFr = frameRange[0]
                if frameRange[1] < endFr:
                    endFr = frameRange[1]
                files = CollectFrameRange(file_parm, startFr, endFr)
                for file in files:
                    SceneAssets.append(file)
                    continue;
        
        
        #Evaluate variables and expressions to the complete path
        expandedFile = file_parm.eval()
            
        #string += str(file_parm)
        #string += " :: " + expandedFile + "\n"
        
        SceneAssets.append(expandedFile)
        
    
    #Filter list and delete duplicates
    FilteredAssets = []
    for i in SceneAssets:
        if i not in FilteredAssets:
            FilteredAssets.append(i)
    
    return FilteredAssets
コード例 #28
0
def do_crash_recovery(calledFromUI=False):
    tmpdir = str( hou.getenv("TEMP") or hou.getenv("HOUDINI_TEMP_DIR") )
    files = glob.glob( os.path.join(tmpdir, '*.hip') )

    uicall = calledFromUI

    if hou.isUIAvailable() and len(files)>0:

        td = os.path.join(tmpdir, '') # dir with '/'
        files = [ (f, os.path.getmtime(f), ) for f in files ]
        files = sorted(files, key=lambda f: f[1], reverse=True)
        files = [ str(re.sub('^%s' % td, '', f[0])) for f in files ]
        
        sel = hou.ui.selectFromList(files, exclusive=True,
            title="Crash Recovery",
            message="Select .hip File to Recover")

        recovered = False
        if len(sel)>0:
            f = files[sel[0]]
            fn = os.path.join(tmpdir, f)

            # extract HIPNAME
            f = re.sub('^crash.', '', f)
            f = re.sub('\..+_[0-9]+\.hip', '.hip', f)

            # do recovery
            try:
                hou.hipFile.clear(True)
                hou.hipFile.load(fn, True)
                hou.setUpdateMode(hou.updateMode.Manual)
                recovered = True
            except:
                hou.ui.setStatusMessage("error while recovering file %s" % fn, hou.severityType.Error)
                print "ERROR: %s" % traceback.format_exc()

            hou.hipFile.setName(f)

        # delete crash file(s)

        msg = 'Cleanup: Delete all crash recovery hip files?'
        if recovered:
            msg = \
                'File recovered. Make sure to save it to a safe location.\n' \
                'NOTE: Update mode is set to "Manual" to avoid potential re-crashes.\n' \
                '\n%s' % msg

        d = hou.ui.displayMessage(msg, buttons=("DELETE", "Skip", ))
        if d==0:
            files = \
                glob.glob( os.path.join(tmpdir, 'crash.*') ) + \
                glob.glob( os.path.join(tmpdir, '*.hip') )
            for f in files:
                try:
                os.remove(f)
                except:
                pass

            hou.ui.setStatusMessage("crash recovery cleanup: deleted %d files" % len(files))
        else:
            pass # user cancelled

    else:
        # no crash files found
        #
        if uicall:
            hou.ui.setStatusMessage("  Crash Recovery:  No emergency-saved .hip file(s) found -- nothing to recover. (%s)" % tmpdir, hou.severityType.ImportantMessage)
            pass



def open_dir(dir="", env=None):
    '''.'''
    dir=str(dir)

    if env:
        dir = str(hou.getenv(env))

    if not os.path.exists(dir):
        statmsg("Directory doesn't exist (%s)" % dir, warn=True)
        return

    if is_linux():
        statmsg("(linux) xdg-open %s" % dir)
        subprocess.call(["xdg-open", dir])

    if is_windows():
        dir = dir.replace('/', '\\')
        statmsg("(windows) start %s" % dir)
        subprocess.call(["start", dir])

    if is_mac():
        statmsg("(mac) open %s" % dir)
        subprocess.call(["open", dir])



def find_camera(oppattern, path=None):
    '''Finds a camera OBJ within nested subnets and returns its full path.'''
    r = ''
    try:
        root = hou.pwd()
        if path: root = hou.node(path)
        root = root.glob(oppattern)

        if len(root)>0:
            cam = [ n.path() for n in root[0].allSubChildren() if n.type().name()=='cam' ]
            if len(cam)>0:
                r = cam[0]
            else:
                pass # no camera found
        else:
            pass # no root node found

    except:
        pass # TODO: error handling

    return r



def backup_rop_output_file():
    '''Creates a dated backup of an output file of a ROP. Useful as a ROP Pre-Render call.'''
    pass
コード例 #29
0
def toggle_manualupdate():
    mode = hou.updateModeSetting().name()
    if mode == 'AutoUpdate':
        hou.setUpdateMode(hou.updateMode.Manual)
    if mode == 'Manual':
        hou.setUpdateMode(hou.updateMode.AutoUpdate)
コード例 #30
0
ファイル: qlibutils.py プロジェクト: follyx/qLib
def do_crash_recovery(calledFromUI=False):
	tmpdir = str( hou.getenv("TEMP") or hou.getenv("HOUDINI_TEMP_DIR") )
	files = glob.glob( os.path.join(tmpdir, '*.hip') )

	uicall = calledFromUI

	if hou.isUIAvailable() and len(files)>0:

		td = os.path.join(tmpdir, '') # dir with '/'
		files = [ (f, os.path.getmtime(f), ) for f in files ]
		files = sorted(files, key=lambda f: f[1], reverse=True)
		files = [ str(re.sub('^%s' % td, '', f[0])) for f in files ]
		
		sel = hou.ui.selectFromList(files, exclusive=True,
			title="Crash Recovery",
			message="Select .hip File to Recover")

		recovered = False
		if len(sel)>0:
			f = files[sel[0]]
			fn = os.path.join(tmpdir, f)

			# extract HIPNAME
			f = re.sub('^crash.', '', f)
			f = re.sub('\..+_[0-9]+\.hip', '.hip', f)

			# do recovery
			try:
				hou.hipFile.clear(True)
				hou.hipFile.load(fn, True)
				hou.setUpdateMode(hou.updateMode.Manual)
				recovered = True
			except:
				hou.ui.setStatusMessage("error while recovering file %s" % fn, hou.severityType.Error)
				print "ERROR: %s" % traceback.format_exc()

			hou.hipFile.setName(f)

		# delete crash file(s)

		msg = 'Cleanup: Delete all crash recovery hip files?'
		if recovered:
			msg = \
				'File recovered. Make sure to save it to a safe location.\n' \
				'NOTE: Update mode is set to "Manual" to avoid potential re-crashes.\n' \
				'\n%s' % msg

		d = hou.ui.displayMessage(msg, buttons=("DELETE", "Skip", ))
		if d==0:
			files = \
				glob.glob( os.path.join(tmpdir, 'crash.*') ) + \
				glob.glob( os.path.join(tmpdir, '*.hip') )
			for f in files:
			    try:
				os.remove(f)
			    except:
				pass

			hou.ui.setStatusMessage("crash recovery cleanup: deleted %d files" % len(files))
		else:
			pass # user cancelled

	else:
		# no crash files found
		#
		if uicall:
			hou.ui.setStatusMessage("  Crash Recovery:  No emergency-saved .hip file(s) found -- nothing to recover. (%s)" % tmpdir, hou.severityType.ImportantMessage)
			pass
コード例 #31
0
def toggleUpdateMode():
    mode = hou.updateModeSetting()
    if mode != hou.updateMode.AutoUpdate:
        hou.setUpdateMode(hou.updateMode.AutoUpdate)
    else:
        hou.setUpdateMode(hou.updateMode.Manual)
コード例 #32
0
    def __exit__(self, type, value, traceBack):

        hou.setUpdateMode(self.__prevMode)
コード例 #33
0
ファイル: HComHoudiniUtils.py プロジェクト: GJpy/HCom
def createOtl(data, sender="", settings=None):
    
    nodeName = data["OTL_NAME"]
    parentType = data["OTL_PARENT_TYPE"]
    subOtlLibs = data["OTL_ALL_LIBS"]
    
    # Switch houdini to manual update according to settings
    if settings["SWITCH_TO_MANUAL_UPDATE"]:
        hou.setUpdateMode(hou.updateMode.Manual)
    
    # Check otl libs
    if subOtlLibs:
        
        allLoadedFiles = [os.path.basename(n) for n in hou.hda.loadedFiles()]
        
        for e in subOtlLibs:
            libName = e[0]
            libData = e[1]
            
            if libName in allLoadedFiles:
                continue
            
            otlLibToInstall = fetchMyReceivedFilesFolder() + os.sep + libName
            
            with open(otlLibToInstall, 'wb') as f:
                f.write(libData)
            
            hou.hda.installFile(otlLibToInstall)
    
    comment = " Node sent by {0} ({1})".format(str(sender), time.ctime())
    pyCode = data["PY_CODE"].split("\n")
    
    outPyCode = ""
    houNodeFound = False
    for c in pyCode:
        
        # Change code to create a geo container for sop node
        if parentType == "geo":
            if c.replace(" ", "").startswith("hou_parent") and not houNodeFound:
                houNodeFound = True
                outPyCode += c + "\n"
                outPyCode += "hou_parent = hou.node('/obj').createNode('geo', run_init_scripts=False)\n"
                outPyCode += "hou_parent.setName('{0}_container_' + '_from_{1}', unique_name=True)\n".format(nodeName, str(sender))
                outPyCode += "hou_parent.appendComment('HCom:')\n"
                outPyCode += "hou_parent.appendComment('{0}')\n".format(comment)
            else:
                outPyCode += c + "\n"
        
        # Change parent to shopnet for shop nodes       
        elif parentType == "shop":
            if c.replace(" ", "").startswith("hou_parent") and not houNodeFound:
                houNodeFound = True
                outPyCode += c + "\n"
                outPyCode += "container = hou.node('/obj').createNode('geo', run_init_scripts=False)\n"
                outPyCode += "container.setName('{0}_container_' + '_from_{1}', unique_name=True)\n".format(nodeName, str(sender))
                outPyCode += "container.appendComment('HCom:')\n"
                outPyCode += "container.appendComment('{0}')\n".format(comment)
                outPyCode += "hou_parent = container.createNode('shopnet', run_init_scripts=False)\n"
            else:
                outPyCode += c + "\n"
                
        # Change parent to dopnet for dop nodes       
        elif parentType == "dop":
            if c.replace(" ", "").startswith("hou_parent") and not houNodeFound:
                houNodeFound = True
                outPyCode += c + "\n"
                outPyCode += "container = hou.node('/obj').createNode('geo', run_init_scripts=False)\n"
                outPyCode += "container.setName('{0}_container_' + '_from_{1}', unique_name=True)\n".format(nodeName, str(sender))
                outPyCode += "container.appendComment('HCom:')\n"
                outPyCode += "container.appendComment('{0}')\n".format(comment)
                outPyCode += "hou_parent = container.createNode('dopnet', run_init_scripts=False)\n"
            else:
                outPyCode += c + "\n"
                
        # Change parent to copnet for cop nodes       
        elif parentType == "cop":
            if c.replace(" ", "").startswith("hou_parent") and not houNodeFound:
                houNodeFound = True
                outPyCode += c + "\n"
                outPyCode += "container = hou.node('/obj').createNode('geo', run_init_scripts=False)\n"
                outPyCode += "container.setName('{0}_container_' + '_from_{1}', unique_name=True)\n".format(nodeName, str(sender))
                outPyCode += "container.appendComment('HCom:')\n"
                outPyCode += "container.appendComment('{0}')\n".format(comment)
                outPyCode += "hou_parent = container.createNode('cop2net', run_init_scripts=False)\n"
            else:
                outPyCode += c + "\n"
                
        # Change parent to ropnet for rop nodes       
        elif parentType == "rop":
            if c.replace(" ", "").startswith("hou_parent") and not houNodeFound:
                houNodeFound = True
                outPyCode += c + "\n"
                outPyCode += "container = hou.node('/obj').createNode('geo', run_init_scripts=False)\n"
                outPyCode += "container.setName('{0}_container_' + '_from_{1}', unique_name=True)\n".format(nodeName, str(sender))
                outPyCode += "container.appendComment('HCom:')\n"
                outPyCode += "container.appendComment('{0}')\n".format(comment)
                outPyCode += "hou_parent = container.createNode('ropnet', run_init_scripts=False)\n"
            else:
                outPyCode += c + "\n"
        
        # Change code to change node name
        elif parentType == "obj":
            if c.startswith("hou_node") and not houNodeFound:
                houNodeFound = True
                outPyCode += c + "\n"                   
                outPyCode += "hou_node.setName('{0}' + '_from_{1}', unique_name=True)\n".format(nodeName, str(sender))
                outPyCode += "hou_node.appendComment('HCom:')\n"
                outPyCode += "hou_node.appendComment('{0}')\n".format(comment)
            else:
                outPyCode += c + "\n"
                
        # Change parent to vopsop for vex nodes       
        elif "vop" in parentType:
            
            parentTypeContainer = parentType.split(";")[1]
            parentClass = parentType.split(";")[2]
            
            # is a sop vop network
            if parentClass == "sop":
                if c.replace(" ", "").startswith("hou_parent") and not houNodeFound:
                    houNodeFound = True
                    outPyCode += c + "\n"
                    outPyCode += "container = hou.node('/obj').createNode('geo', run_init_scripts=False)\n"
                    outPyCode += "container.setName('{0}_container_' + '_from_{1}', unique_name=True)\n".format(nodeName, str(sender))
                    outPyCode += "container.appendComment('HCom:')\n"
                    outPyCode += "container.appendComment('{0}')\n".format(comment)
                    outPyCode += "hou_parent = container.createNode('{0}', run_init_scripts=False)\n".format(parentTypeContainer)
                else:
                    outPyCode += c + "\n"
            
            # it's a material network      
            elif parentClass == "material":
                if c.replace(" ", "").startswith("hou_parent") and not houNodeFound:
                    houNodeFound = True
                    outPyCode += c + "\n"
                    outPyCode += "container = hou.node('/obj').createNode('geo', run_init_scripts=False)\n"
                    outPyCode += "container.setName('{0}_container_' + '_from_{1}', unique_name=True)\n".format(nodeName, str(sender))
                    outPyCode += "container.appendComment('HCom:')\n"
                    outPyCode += "container.appendComment('{0}')\n".format(comment)
                    outPyCode += "shopnet = container.createNode('shopnet', run_init_scripts=False)\n"
                    outPyCode += "hou_parent = shopnet.createNode('{0}', run_init_scripts=False)\n".format(parentTypeContainer)
                else:
                    outPyCode += c + "\n"
                    
            # it's a cop network      
            elif parentClass == "cop":
                if c.replace(" ", "").startswith("hou_parent") and not houNodeFound:
                    houNodeFound = True
                    outPyCode += c + "\n"
                    outPyCode += "container = hou.node('/obj').createNode('geo', run_init_scripts=False)\n"
                    outPyCode += "container.setName('{0}_container_' + '_from_{1}', unique_name=True)\n".format(nodeName, str(sender))
                    outPyCode += "container.appendComment('HCom:')\n"
                    outPyCode += "container.appendComment('{0}')\n".format(comment)
                    outPyCode += "copnet = container.createNode('cop2net', run_init_scripts=False)\n"
                    outPyCode += "hou_parent = copnet.createNode('{0}', run_init_scripts=False)\n".format(parentTypeContainer)
                else:
                    outPyCode += c + "\n"
    try:
        
        exec(outPyCode)
    except Exception as e:
        print("ERROR: exec pyCode " + str(e))
コード例 #34
0
ファイル: aepypanel.py プロジェクト: MaxSteven/Aepanel
    def hipIncrementVersion(self):
        # SETTINGS ==================
        setToFirstFrame = True  # Sets playback frame of saved file to first frame (does not affect open file)
        setToManualUpdate = False  # Sets update mode of saved file to manual (does not affect open file)
        autoversion = True  # If no versioning exists, create a new version
        autoversionzfill = 3  # digit padding for autoversioning
        debug = 0  # print some items to console
        # ===========================

        orighip = hou.hipFile.name()
        hipname = hou.hipFile.basename()
        # hipfile = hipname.split(".")[0]
        # version which works for filenames with periods
        hipfile = os.path.splitext(hipname)[0]

        # check current filename for version prefix and split accordingly
        # Uses regex so a filename like myfile_verycool_v001.hip will get picked up correctly (not match the first _v)
        versionSections = ""
        versionType = ""
        if len(re.findall('_v(?=\d+)', hipfile)) > 0:
            versionSections = re.split('_v(?=\d+)', hipfile, 1)
            versionType = "_v"
        elif len(re.findall('_V(?=\d+)', hipfile)) > 0:
            versionSections = re.split('_V(?=\d+)', hipfile, 1)
            versionType = "_V"

            # if no version prefix found, create it
        if versionSections == "":
            if (autoversion):
                versionSections = [hipfile, "0" * autoversionzfill]
                versionType = "_v"
                orighip = orighip.replace(
                    hipfile, hipfile + versionType + "0" * autoversionzfill)
                print "No version found in hip name - Autoversioning"
            else:
                print "No version found in hip name - Exiting"
                return 1

        # regex - match numbers after version splitter. Match until non-numeric value is hit.
        match = re.match('\d+', versionSections[1])
        if match:
            versionNumber = match.group(0)
        else:
            print "Problem encountered matching version number - Exiting"
            return 1

        # Create new filename
        oldVersion = versionType + versionNumber
        if debug:
            print "Old version: " + oldVersion
        newVersion = versionType + str(int(versionNumber) + 1).zfill(
            len(versionNumber))
        newhip = orighip.replace(oldVersion, newVersion)
        if debug:
            print "New file: " + newhip

        # Save the file
        confirm = 0
        if os.path.isfile(newhip):
            text = "Overwrite existing hip file?"
            confirm = hou.ui.displayMessage(text,
                                            buttons=("Yes", "No"),
                                            severity=hou.severityType.Message,
                                            title="New Hip")
        if confirm == 0:
            # update mode and frame settings
            updateMode = hou.updateModeSetting()
            frame = hou.frame()
            if (setToManualUpdate):
                hou.setUpdateMode(hou.updateMode.Manual)
            if (setToFirstFrame):
                # hou.setFrame(1)
                hou.setFrame(hou.playbar.playbackRange()[0])

            hou.hipFile.save(newhip)

            # reset update mode and frame
            hou.setUpdateMode(updateMode)
            hou.setFrame(frame)
コード例 #35
0
ファイル: UpdateMode.py プロジェクト: mor-vfx/cortex
    def __enter__(self):

        hou.setUpdateMode(self.__mode)
コード例 #36
0
 def restoreUpdateMode(self):
     hou.setUpdateMode(self.updateMode)
コード例 #37
0
ファイル: UpdateMode.py プロジェクト: mor-vfx/cortex
    def __exit__(self, type, value, traceBack):

        hou.setUpdateMode(self.__prevMode)
コード例 #38
0
def do_crash_recovery(calledFromUI=False):
    """Performs crash recovery from an emergency-saved file.
    """
    tmpdir = str(hou.getenv("TEMP") or hou.getenv("HOUDINI_TEMP_DIR"))
    files = glob.glob(os.path.join(tmpdir, '*.hip'))

    uicall = calledFromUI

    if hou.isUIAvailable() and len(files) > 0:

        td = os.path.join(tmpdir, '')  # dir with '/'
        files = [(
            f,
            os.path.getmtime(f),
        ) for f in files]
        files = sorted(files, key=lambda f: f[1], reverse=True)
        files = [str(re.sub('^%s' % td, '', f[0])) for f in files]

        sel = hou.ui.selectFromList(files,
                                    exclusive=True,
                                    title="Crash Recovery",
                                    message="Select .hip File to Recover")

        recovered = False
        if len(sel) > 0:
            f = files[sel[0]]
            fn = os.path.join(tmpdir, f)

            # extract HIPNAME
            f = re.sub('^crash.', '', f)
            f = re.sub('\..+_[0-9]+\.hip', '.hip', f)

            # do recovery
            try:
                hou.hipFile.clear(True)
                hou.hipFile.load(fn, True)
                hou.setUpdateMode(hou.updateMode.Manual)
                recovered = True
            except:
                hou.ui.setStatusMessage("error while recovering file %s" % fn,
                                        hou.severityType.Error)
                print "ERROR: %s" % traceback.format_exc()

            hou.hipFile.setName(f)

        # delete crash file(s)

        msg = 'Cleanup: Delete all crash recovery hip files?'
        if recovered:
            msg = \
                'File recovered. Make sure to save it to a safe location.\n' \
                'NOTE: Update mode is set to "Manual" to avoid potential re-crashes.\n' \
                '\n%s' % msg

        d = hou.ui.displayMessage(msg, buttons=(
            "DELETE",
            "Skip",
        ))
        if d == 0:
            files = \
                glob.glob(os.path.join(tmpdir, 'crash.*')) + \
                glob.glob(os.path.join(tmpdir, '*.hip'))
            for f in files:
                try:
                    os.remove(f)
                except:
                    pass

            hou.ui.setStatusMessage(
                "crash recovery cleanup: deleted %d files" % len(files))
        else:
            pass  # user cancelled

    else:
        # no crash files found
        #
        if uicall:
            hou.ui.setStatusMessage(
                '  Crash Recovery:  No emergency-saved .hip file(s) found -- nothing to recover. (%s)'
                % tmpdir, hou.severityType.ImportantMessage)
            pass
コード例 #39
0
    def __enter__(self):

        hou.setUpdateMode(self.__mode)