Jump to content
Sign in to follow this  

Make Difference in Alt Drag, Copy and Paste or Rename Node in Event Callbacks

Recommended Posts


Can it be possible to make difference in event callbacks with copy, alt drag and rename a node.

The problem is when Houdini make a node copy ( duplicate, or copy paste ) makes a renaming too.

So in scripting I could not figure out how to determine which event occurs.

So I want to know when rename or copy paste or alt drag happened.




Share this post

Link to post
Share on other sites

Thanks for your answer !

Have a nice day !

I extended the code like this:

def is_copy_paste_event(kwargs):
    if not kwargs['node'].name().startswith('original') and not kwargs['old_name'].startswith('original'):
        original_node = kwargs['node'].parent().node('original0_of_%s' % kwargs['old_name'])
        return True if original_node else False
def checkAltDown():
    from hutil.Qt import QtWidgets
    from hutil.Qt import QtCore
    m = QtWidgets.QApplication.keyboardModifiers()
    return m == QtCore.Qt.AltModifier
if is_copy_paste_event( kwargs) and checkAltDown():
    print 'alt_dup', kwargs['node']
    hou.session._node_copy_mode_ = 'alt_duplication'
elif is_copy_paste_event( kwargs):
    print 'copied', kwargs['node']
    hou.session._node_copy_mode_ = 'copy_of_node'
elif not 'original' in kwargs['node'].name():
    if hasattr( hou.session, '_node_copy_mode_'):
        if hou.session._node_copy_mode_ == 'alt_duplication':
            print 'alt_renamed', kwargs['node']
        elif hou.session._node_copy_mode_ == 'copy_of_node':
            print 'copy_renamed', kwargs['node']
        del( hou.session._node_copy_mode_)
        print 'simple_renamed', kwargs['node']


Edited by gemini
  • Like 1

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
Sign in to follow this