def ramp_lib_get(): node = wf_selection.parmnode() parms = node.parms() string = ''' ramp_preset = [] ramp_basis = [] ramp_keys = [] ramp_values = [] ''' for parm in parms: if parm.parmTemplate().type() == hou.parmTemplateType.Ramp: #parm is Ramp parmName = parm.name() orig_ramp = parm.eval() basis = orig_ramp.basis() keys = orig_ramp.keys() values = orig_ramp.values() string = string + "ramp_preset.append( '%s' )" % parmName + "\n" string = string + "ramp_basis.append( %s ) " % (basis, ) + "\n" string = string + "ramp_keys.append( %s ) " % (keys, ) + "\n" string = string + "ramp_values.append( %s ) " % (values, ) + "\n" string = string + "\n" string = string.replace("rampBasis.", "hou.rampBasis.") print string
def folders_tab_go(dir): node = wf_selection.parmnode() if node.type() == hou.nodeType("Sop/switch"): ######################## ####### switch ####### ninputs = len(node.inputs()) parm = node.parm("input") if parm.eval() + dir > ninputs - 1: parm.set(0) elif parm.eval() + dir < 0: parm.set(ninputs - 1) else: parm.set(parm.eval() + dir) ######################## else: ######################## ######## tabs ######## A = node.parmTemplateGroup() A_names, A_counts = names_counts_in(node, A) for (iA, A_name) in enumerate(A_names): A_went = 0 B_went = 0 C_went = 0 A_actual = node.parm(A_name + "1").eval() A_count = A_counts[iA] pt_name = A_name if A_actual > 0: pt_name += "_" + str(A_actual) B = node.parmTemplateGroup().find(pt_name) B_names, B_counts = names_counts_in(node, B) for (iB, B_name) in enumerate(B_names): B_actual = node.parm(B_name + "1").eval() B_count = B_counts[iB] pt_name = B_name if B_actual > 0: pt_name += "_" + str(B_actual) C = node.parmTemplateGroup().find(pt_name) C_names, C_counts = names_counts_in(node, C) for (iC, C_name) in enumerate(C_names): C_count = C_counts[iC] C_went = folders_trygo(node, C_name, C_count, dir) if C_went == 0: B_went = folders_trygo(node, B_name, B_count, dir) if B_went == 0 and C_went == 0: A_went = folders_trygo(node, A_name, A_count, dir)
def flag_template_all_off(): parmnode = wf_selection.parmnode() container = parmnode.parent() for node in container.children(): try: node.setTemplateFlag(False) node.setSelectableTemplateFlag(False) except: has_no_flag = 1
def sort_by_x(): node_merge = wf_selection.parmnode() # list contains pairs [ [node,position] , [node,position] , ... ] node_list = [] for node in node_merge.inputs(): node_list_pair = [] node_list_pair.append(node) node_list_pair.append(node.position()[0]) node_list.append(node_list_pair) # first item is left node_list = sorted(node_list, key=lambda x: x[1]) # create connections for (i, pair) in enumerate(node_list): node_merge.setInput(i, pair[0])
def parm_generate () : node = wf_selection.parmnode() parm = node.parm("snippet") snippet = parm.unexpandedString() snippet_updated = '' lines = snippet.split('\n') for (linenum, line) in enumerate(lines): wf_midi.check_midi(node, line, linenum) for (linenum, line) in enumerate(lines): line_updated = line_parse (node, line, linenum) snippet_updated += line_updated if linenum < len(lines)-1 : snippet_updated += '\n' node.parm("snippet").set(snippet_updated)
def folders_tab_go (dir) : node = wf_selection.parmnode() A = node.parmTemplateGroup() A_names, A_counts = names_counts_in (node, A) for (iA,A_name) in enumerate(A_names) : A_went = 0 B_went = 0 C_went = 0 A_actual = node.parm(A_name+"1").eval() A_count = A_counts[iA] pt_name = A_name if A_actual > 0: pt_name += "_" + str(A_actual) B = node.parmTemplateGroup().find(pt_name) B_names, B_counts = names_counts_in (node, B) for (iB,B_name) in enumerate(B_names) : B_actual = node.parm(B_name+"1").eval() B_count = B_counts[iB] pt_name = B_name if B_actual > 0: pt_name += "_" + str(B_actual) C = node.parmTemplateGroup().find(pt_name) C_names, C_counts = names_counts_in (node, C) for (iC,C_name) in enumerate(C_names): C_count = C_counts[iC] C_went = folders_trygo(node, C_name, C_count , dir) if C_went == 0: B_went = folders_trygo(node, B_name, B_count , dir) if B_went == 0 and C_went == 0: A_went = folders_trygo(node, A_name, A_count , dir)
def recook_container(): container = wf_selection.parmnode() nodes = container.allSubChildren() for node in nodes: node.cook(force=True)
def flag_display () : parmnode = wf_selection.parmnode() containername = parmnode.parent().name() nodetype = "multiflag" if hou.sopNodeTypeCategory() == parmnode.parent().childTypeCategory(): nodetype = "singleflag" if hou.dopNodeTypeCategory() == parmnode.parent().childTypeCategory(): nodetype = "singleflag" ################################ ## unflag to the last flagged ## ################################ if nodetype == "singleflag": # get this if len(hou.selectedNodes()) == 0: thisnode = parmnode else: thisnode = hou.selectedNodes()[0] thispath = thisnode.path() # get last lastpath = hou.getenv("unflagged", thispath) try: #node exists if hou.node(lastpath).parent().name() != containername: lastpath = thispath except: #node was deleted / renamed lastpath = thispath # get flag flagpath = hou.getenv("flag", thispath) try: #node exists if hou.node(flagpath).parent().name() != containername: flagpath = thispath except: #node was deleted / renamed flagpath = thispath try: flag = hou.node(thispath).isDisplayFlagSet() except: flag = 2 if flag == 0 : # setting clean setpath = thispath unflag = flagpath hou.putenv("unflagged", unflag ) # set hou.putenv("flag", setpath ) setnode = hou.node( setpath ) setnode.setDisplayFlag(True) if flag == 1 : # setting flagged setpath = lastpath unflag = thispath hou.putenv("unflagged", unflag ) # set hou.putenv("flag", setpath ) setnode = hou.node( setpath ) setnode.setDisplayFlag(True) ################################ #### not SOP, just toggle #### ################################ if nodetype == "multiflag": # none is selected if len(hou.selectedNodes()) == 0: parmnode.setDisplayFlag(not parmnode.isDisplayFlagSet()) # for all selected for node in hou.selectedNodes(): try: node.setDisplayFlag(not node.isDisplayFlagSet()) except: hasnoflag = True
def parm_clean(): node = wf_selection.parmnode() ptg = node.parmTemplateGroup() ptg.clear() node.setParmTemplateGroup(ptg)
def hda_unlock(): parmnode = wf_selection.parmnode() parmnode.allowEditingOfContents(propagate=True)