math ross

mapoga

About Me

Connect

LOCATION
Not Specified
WEBSITE

Houdini Skills

Availability

Not Specified

Recent Forum Posts

Creating an HDA that Instantiates Multiple Nodes at Once May 9, 2024, 11:20 p.m.

I believe you need to create a custom shelf script that instantiate the 2 nodes. This is separate from creating the HDA itself.

Here is the content of the shelf tool labeled Karma from this file: $HFS/houdini/toolbar/ExtraLopTools.shelf
import loptoolutils
node = loptoolutils.genericTool(kwargs, 'karmarenderproperties', 'karmarendersettings')
node.setCurrent(True)
nodename = node.name()
kwargs['inputnodename'] = nodename
kwargs['inputs'] = [(nodename, 0)]
kwargs['nodepositionx'] = str(node.position().x())
kwargs['nodepositiony'] = str(node.position().y() - 0.5)
rop = loptoolutils.genericTool(kwargs, 'usdrender_rop')
rop.parm("rendersettings").setExpression('chs("../%s/primpath")' % nodename)
rop.parm("husk_instantshutter").setExpression('1 - ch("../%s/enablemblur")' % nodename)
node.setCurrent(True)
node.setSelected(True)

python: change node type May 9, 2024, 10:36 p.m.

Here is a possible solution.
Keep in mind that this is a naive approach since an hda file can contain multiple definitions.

I would be interested to know if someone has a better way.

import hou


def replace_type_instances(src_type, dst_type):
    for instance in src_type.instances():
        if instance.isEditableInsideLockedHDA():
            keep_network_contents = not instance.matchesCurrentDefinition()
            new_node = instance.changeNodeType(
                dst_type.name(),
                keep_parms=True,
                keep_network_contents=keep_network_contents
            )


def get_hda_first_type(hda_filepath):
    definitions = hou.hda.definitionsInFile(hda_filepath)
    for definition in definitions:
        return definition.nodeType()


def main():
    src_type = get_hda_first_type('/path/to/src.hda')
    dst_type = get_hda_first_type('/path/to/dst.hda')
    if src_type and dst_type:
        dst_type.definition().setIsPreferred(True)
        with hou.undos.group('Replace type instances'):
            replace_type_instances(src_type, dst_type)


main()

How to build nodes from a Geometry Graph? May 7, 2024, 10:35 a.m.

Is there a convenient way of building the nodes represented by a Geometry Graph?


Currently if i want to edit a graph, i have to start from the nodes that were used to generate the graph in the first place.
It would be nice if we could convert both ways. aka: nodes <-> graph
It might already be possible, but i have not found information related to this yet.

Thank you!