HDA drag and drop python script

   690   0   1
User Avatar
Member
143 posts
Joined: Sept. 2017
Offline
Hi,

I'm trying to get drag and drop functionality for HDAs using a python script, but my noobishness is getting in the way.
This is what I've got so far:
(The file is called externaldragdrop.py and is placed inside the scripts folder.)
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:
        hou.hda.installFile(filename)

    return True

This does install the HDA into my current hip file as expected, but I'd like to add more functionality and I'm stuck at this point.
What I'd like the script to do, would be to determine the active network view context and place an instance of the installed HDA into the active context. So when I drag and drop the HDA from Explorer into a subnet, I'd like to have the HDA geo node in the subnet, where I dropped it.

Currently, I'm having trouble getting the definition of the installed HDA and creating a list of all HDAs before installation and then comparing it with a new list after seems like a very ineffective way to do this.

So to sum up, my questions would be:
How do I create an instance of the newly installed HDA and how do I create it in the currently active network view context, that it was dropped into?
  • Quick Links