bunker Posted April 26, 2020 Share Posted April 26, 2020 (edited) Houdini's pyro shelf tools create 3 nodes on /obj/ level. I really hate that and got tired of copy+paste+renaming nodes... I wrote a simple shelf tool python script to fix that. It works for PyoFX and Sparse PyoFX shelf tools. hope someone finds it useful and if anyone can improve that script or make it more generic, please post it here... import re # move dopnet to SOPs def dopnet2sop(): # find first dopnet (assuming there's only one) # replace relative external paths to absolute paths dopnet=hou.nodeType("Object/dopnet").instances()[0] sourceNode='' for dopnode in dopnet.children(): for parm in dopnode.parms(): nodepath=parm.evalAsNode() if nodepath!=None and len(nodepath.path().split(dopnet.path()))==1: # convert to absolute path path = parm.evalAsNode().path() parm.set(path) # find the pyro source's path if dopnode.type().name()=='volumesource': sourceNode=hou.node(path) sopDopnet = sourceNode.parent().createNode("dopnet") pos = sourceNode.position() sopDopnet.setPosition((pos[0],pos[1]-1)) hou.copyNodesTo(dopnet.children(),sopDopnet) dopnet.destroy() return sopDopnet # set dopnet as reference in dopnode's path def fixdopio(dopnet): di=None for dopio in hou.nodeType("Sop/dopio").instances(): dp=dopio.evalParm("doppath") dn=dopio.evalParm("dopnode") r = '`chsop("doppath")`' a = re.sub(dp,r,dn) dopio.parm("dopnode").set(a) dopio.parm("doppath").set(dopnet.path()) di=dopio return di # move import nodes to SOPs def moveDopioNodes(sopDopnet,dopio): dopIoParent=dopio.parent() # find highest node on y axis x=0 y=0 for i in dopIoParent.children(): pos=i.position() x=min(x,pos[0]) y=max(y,pos[1]) ioNodes=hou.copyNodesTo(dopIoParent.children(),sopDopnet.parent()) diffx=x-sopDopnet.position()[0] diffy=y-sopDopnet.position()[1] for ioNode in ioNodes: pos = ioNode.position() ioNode.setPosition((pos[0]-diffx,pos[1]-diffy-1)) dopIoParent.destroy() # remove unused Output dop nodes def removeUnusedOutputnodes(): for out in hou.nodeType("Dop/output").instances(): if len(out.inputs())==0: out.destroy() # move dopnet and dopio to SOPs hou.setUpdateMode(hou.updateMode.Manual) sopDopnet=dopnet2sop() dopio=fixdopio(sopDopnet) moveDopioNodes(sopDopnet,dopio) removeUnusedOutputnodes() hou.setUpdateMode(hou.updateMode.OnMouseUp) Edited April 26, 2020 by bunker 3 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.