A little script to find/replace strings in selected nodes’, parameter expressions:

import hou

sel = hou.selectedNodes()
        
dialog = hou.ui.readMultiInput('Find/Replace In Expression', input_labels=['Find: ', 'Replace: ',], buttons=("Find/Replace", "Cancel"),
     severity=hou.severityType.ImportantMessage, title='Find/Replace', close_choice=1)

find = dialog[1][0]
replace = dialog[1][1]


if dialog[0] == 0:
    for n in sel:
        for parms in n.parms():
            try:
                newString = str(parms.eval()).replace(find, replace)
                parms.set(newString)
            except:
                print ''
            try:
                newExpression = str(parms.expression()).replace(find, replace)
                parms.setExpression(newExpression)
            except:
                print ''
        

Leave a Reply

Your email address will not be published. Required fields are marked *