Jump to content

Merge edit sops?


jonp

Recommended Posts

<?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 3
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...