Jump to content
konstantin magnus

Mass create nodes from tab menu

Recommended Posts

Maybe use the OnCreated script to do so. There is the python command toolMenuLocations() to check the the Menu Folder. If the node is in the Folder you can use allowEditingOfContens().

Share this post


Link to post
Share on other sites

Maybe I got you wrong. To create all of them just do it once by hand and then make a shelf out of it. (Select all Nodes and drag them to the shelf)

Edited by Drughi

Share this post


Link to post
Share on other sites

The question was rather how to create all nodes from a specific folder like "terrain" or "test geometry" via script.

Share this post


Link to post
Share on other sites

It's possible, but quite cumbersome because of how HDAs still use a xml to define these things. Also, it won't work with nodes that only have the category hardcoded (usually older nodes). It should work with the newer gamedev tools

 

import xml.etree.ElementTree as ET



def create_all_nodes_by_category(network, category):
    installed_hdas = hou.hda.loadedFiles()
    for hda in installed_hdas:
        definitions = hou.hda.definitionsInFile(hda)
        for definition in definitions:
            try:
                xml_content = definition.sections()["Tools.shelf"].contents()
                root = ET.fromstring(xml_content)
                tool = root.find("tool")
                submenu = tool.find("toolSubmenu").text
                if submenu == category:
                     network.createNode(definition.nodeTypeName())
            except:
                pass
                
create_all_nodes_by_category(hou.node("/obj/geo1"), "GameDev")

https://streamable.com/4yxqx

  • Like 4

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

×