Search - User list
Full Version: How do I drive a Switch SOP input from a Wedge TOP attribute
Root » Houdini Indie and Apprentice » How do I drive a Switch SOP input from a Wedge TOP attribute
bluemoon3
I'm wedging variations with a Wedge TOP and cooking my SOP network through an HDA Processor. I want the Switch SOP to pick its input based on the current wedge, but referencing the wedge attribute on the Switch doesn't seem to work.

I tried putting @wedgeindex in the Switch's Input parameter, and also tried a custom attribute I created on the Wedge node (@variant). Neither seems to resolve correctly when the network cooks through TOPs.

A few details:

Houdini 20.5
Switch SOP inside an HDA called by HDA Processor
Wedge TOP creates attributes: wedgeindex, variant (integer, range 0–3)
Switch has 4 inputs
Questions:

What is the correct expression syntax for the Switch Input parameter in this setup?
Should I use @wedgeindex, P@variant, or something else?
Does the Switch need to be configured differently when cooked via TOPs vs. interactively?
Any working examples would be appreciated. Thanks!
digzelot
I'm doing something similar, I have an HDA to expedite wedge params like folder paths, files names etc - on my HDA I have a "Preview Wedge" slider that will swap wedges, here you might just use the HDA param to control the wedge and the switch -

python script module in HDA:
def select_wedge(node, index):
    # ← CHANGE THIS path to your actual Wedge TOP
    top = node.node("topnet1/wedge1")
    
    if top is None:
        return

    pdg = top.getPDGNode()
    if pdg is None:
        return

    # Prefer matching by wedgeindex attribute
    for wi in pdg.workItems:
        if wi.intAttribValue("wedgeindex") == index:
            top.setSelectedWorkItem(wi.id)
            return

    # Fallback
    if 0 <= index < len(pdg.workItems):
        top.setSelectedWorkItem(pdg.workItems[index].id)

Callback script on int parameter:
kwargs["node"].hdaModule().select_wedge(kwargs["node"], kwargs["parm"].eval())
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.