Jump to content
jonp

Merge edit sops?

Recommended Posts

Is there some secret function or script that will let me merge multiple edit SOP operations into one node?

 

I'm not seeing a big performance hit with lots of them chained together but... OCD is kicking in.

 

 

Share this post


Link to post
Share on other sites
<?xml version="1.0" encoding="UTF-8"?>
<shelfDocument>
  <tool name="delta_edit" label="Delta Edit" icon="SOP_edit">
    <helpText>

<![CDATA[
#type: tool
#icon: SOP/edit

= Delta Edit =

"""Create Edit SOP from difference between two SOPs."""
]]>

    </helpText>
    <script scriptType="python">

<![CDATA[
def safe_name(network, name):
    '''
    Append a digit to the name making it unique within the network.

    Depends on existing nodes inside the network. E.g. if the network contains
    edit1, edit5 and edit6 nodes, 'edit7' will be returned, ignoring vacant
    numbers between edit1 and edit5, the way Houdini does it.
    '''
    digits = [n.digitsInName() for n in network.glob(name + '*')]
    return '{}{}'.format(name, max([0] + digits) + 1)


def delta_edit(selected_nodes):
    '''Create Edit SOP from difference between two SOPs.'''
    nodes = [x.name() for x in selected_nodes if isinstance(x, hou.SopNode)]
    if len(nodes) != 2:
        return

    network = selected_nodes[0].parent()
    name = safe_name(network, 'delta')
    script = 'cd {}; sopcreateedit {} {} {}'.format(network.path(), name, *nodes)
    hou.hscript(script)


delta_edit(hou.selectedNodes())
]]>

    </script>
  </tool>
</shelfDocument>

I made a shelf tool wrapping this command.

Usage:
Select "from this state" node, shift-select "into this state" node, click the tool. Origin and target nodes should share topology.

Installation:

  1. Save to $(HIP|JOB|HOUDINI_USER_PREF_DIR)/toolbar/delta_edit.shelf
  2. Launch Houdini
  3. Right-click on empty place in shelf tab, select "Edit Shelf Tab..."
  4. Find "Delta Edit" in the long list of tools, hightlight it
  5. Accept
Edited by f1480187
  • Like 2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×