Supercharged H20 extension (TouchDesigner Style)

   38794   122   8
User Avatar
Member
4730 posts
Joined: Feb. 2012
Offline
Xr_Blood
animatrix_
Xr_Blood
tpetrick 特佩特里克
Houdini has a script hook for external drag/drop, but currently only file path data is supported.

To use the script hook add a Python script named externaldragdrop.py to the Houdini script path, for example ~/houdini16.5/scripts/externaldragdrop.py. The script should define a function called dropAccept which takes a single parameter. Every time a drop event occurs on the main Houdini application it will call the dropAccept function with a list of file path(s) that were dropped onto Houdini. The function can return True to block the drop event from continuing on to Houdini, or False to indicate that Houdini should handle the drop event itself.

An example drop handler script that ignores .hip file drops and creates Font SOPs with the contents of the incoming files:

import hou
import os

def dropAccept(file_list):
    if len(file_list) == 1 and os.path.splitext(file_list[0])[1] == ".hip":
        return False

    for filename in file_list:
        with open(filename) as f:
            contents = f.read()

        obj = hou.node("/obj")
        geo = obj.createNode("geo", "geo1", False, False)
        font = geo.createNode("font")
        font.parm("text").set(contents[:20])

    return True

If the data in the drag/drop event contains arbitary text or binary data instead of file paths the script hook won't be invoked. This is something that would need to be fixed on our end - I can look into fixing that if necessary.

I saw a post on the forum where SideFX staff member tpetrick wrote.

Ok using that script, I get the drag and drop but it only seems to work on the 3d viewport. You manage to get it working using the regular network editor? I think this might require more to get it working for any network editor.

Yes, the Network Editor in the main panel supports this by default. You can modify it to drag and drop files into the Network Editor and print the file paths.
Now I have to press a shortcut to switch to the Network Editor in the main panel to drag and drop files, then switch back to the Supercharged Network Editor to work.

Oh ok I see where the confusion is. I was testing using another floating network editor. So it's not that it doesn't work on the overlay network editor, but that it doesn't work on floating panels, which the overlay network editor also is. So this has to be added by SideFX to work. That would be a good RFE.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
User Avatar
Member
14 posts
Joined: Oct. 2020
Offline
animatrix_
Xr_Blood
animatrix_
Xr_Blood
tpetrick 特佩特里克
Houdini has a script hook for external drag/drop, but currently only file path data is supported.

To use the script hook add a Python script named externaldragdrop.py to the Houdini script path, for example ~/houdini16.5/scripts/externaldragdrop.py. The script should define a function called dropAccept which takes a single parameter. Every time a drop event occurs on the main Houdini application it will call the dropAccept function with a list of file path(s) that were dropped onto Houdini. The function can return True to block the drop event from continuing on to Houdini, or False to indicate that Houdini should handle the drop event itself.

An example drop handler script that ignores .hip file drops and creates Font SOPs with the contents of the incoming files:

import hou
import os

def dropAccept(file_list):
    if len(file_list) == 1 and os.path.splitext(file_list[0])[1] == ".hip":
        return False

    for filename in file_list:
        with open(filename) as f:
            contents = f.read()

        obj = hou.node("/obj")
        geo = obj.createNode("geo", "geo1", False, False)
        font = geo.createNode("font")
        font.parm("text").set(contents[:20])

    return True

If the data in the drag/drop event contains arbitary text or binary data instead of file paths the script hook won't be invoked. This is something that would need to be fixed on our end - I can look into fixing that if necessary.

I saw a post on the forum where SideFX staff member tpetrick wrote.

Ok using that script, I get the drag and drop but it only seems to work on the 3d viewport. You manage to get it working using the regular network editor? I think this might require more to get it working for any network editor.

Yes, the Network Editor in the main panel supports this by default. You can modify it to drag and drop files into the Network Editor and print the file paths.
Now I have to press a shortcut to switch to the Network Editor in the main panel to drag and drop files, then switch back to the Supercharged Network Editor to work.

Oh ok I see where the confusion is. I was testing using another floating network editor. So it's not that it doesn't work on the overlay network editor, but that it doesn't work on floating panels, which the overlay network editor also is. So this has to be added by SideFX to work. That would be a good RFE.

Okay, I understand the issue. Thank you for your explanation. Hopefully, SideFX will update support soon.
User Avatar
Member
4730 posts
Joined: Feb. 2012
Offline
In the upcoming version, you'll be able to undo and redo network editor view changes independently for each network editor. This new history is completely separate from the scene change undo/redo history, ensuring it won't interfere with or bloat your regular undo/redo actions:

Attachments:
undoredo3.gif (4.9 MB)

Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
  • Quick Links