Houdini Intergration - Publish HDA?

houdini_collector.py

In this file you should see a method called process_current_session. In there I gather all the digital assets by adding:

# HDAs
hda_nodes = list()
obj_network = hou.node("/obj")
all_nodes = obj_network.children()
for node in all_nodes:
    cur_type = node.type().definition()
    if cur_type is not None:
        hda_path = cur_type.libraryFilePath()
        hda_nodes.append(node)
if len(hda_nodes) != 0:
    self.collect_hdas(item, hda_nodes)

You decide how you want to collect them. I put an extra check in my version to make sure the hda name matches the current file name. Since I create versioned hda files, it makes it easier to only publish the one digital asset you need. That’s something you can decide.

This now points to a new collect_hdas method. This method will add a new item to the collection process. Using Shotgun’s create_item method you can go ahead and do this

    def collect_hdas(self, parent_item, hda_nodes):
        """
        Creates items for HDAs to be exported
        :param parent_item: Parent Item instance
        :param hda_nodes: list of items to export
        :return:
        """
        # print "\nSorting HDA imformation for: %s\n" % hda_nodes
        # print "parent_item = %s" % parent_item
        print("\nCOLLECTING HDA ITEMS")
        geo_items = list()
        for scene_geo in hda_nodes:
            geo_item = parent_item.create_item(
                "houdini.session.hda.hdaitem",
                "Digital Asset",
                scene_geo.name()
            )
            # get the icon path to display for this item
            icon_path = os.path.join(icon_dir, "generic", "files_32.png")
            geo_item.properties['hda_node'] = scene_geo
            print("\nSetting hda_node to: %s" % scene_geo)
            definition = scene_geo.type().definition()
            geo_item.properties['hda_location'] = definition.libraryFilePath()

            geo_item.set_icon_from_path(icon_path)
            geo_items.append(geo_item)
        return geo_items

For each item you create, you will eventually see it in the Shotgun Publish window with a checkmark beside it. Take note that I create a new item type called:

houdini.session.hda.hdaitem

This is the item type you will be looking for later. You can see I use a lot of print statements. You can either get your feedback this way or with the logger. The print statement just sends it to the Houdini Console of Python Tab if you have one open. I usually open a new Python Tab with every change I make so I can compare the results.
You can also create custom item properties. I have included the digital asset’s location so that it can be used in the publish process to copied over. For each item you can also attach an icon.

After this, the new publish_session_hdas.py script will be looking for the houdini.session.hda.hdaitem in its filter.

5 Likes