Search Tips

Search is based on keyword.

`Ex: "Procedures"`

Do not search with natural language

`Ex: "How do I write a new procedure?"`

Give Feedback Support Portal

# Reading Graph State Variables

## Nodes

The following Katana node types perform some logic, based on the Graph State Variables passed to them.

### VariableSwitch

This node type is similar to the Switch node type, which uses a parameter to determine which input port should be followed. VariableSwitch nodes make this determination by reading a Graph State Variable and attempting to match its value against patterns defined for input ports, or input port names directly, should a port have no pattern define. For example, a VariableSwitch node could be configured to read a "levelofdetail" variable, with input ports named "high" and "low". The same effect can be achieved by defining the following patterns:

• i0 → “high”

• i1 → “low”

A pattern takes the form of a CEL statement, where the {@[name]=="value"} syntax may be used to specify requirements of additional Graph State Variables.

If no port matches the value of the Graph State Variable, the default behavior is to use the left-most input. If more than one pattern matches, the default behavior is to use the left-most matching input.

Note: If a VariableSwitch node defines no patterns, input selection is performed using a faster look-up operation. This may be useful for nodes with a large number of input ports.

### VariableEnabledGroup

The VariableEnabledGroup node type is an extension to the Group node type, which allows you to combine multiple nodes into a single unit. VariableEnabledGroup bypasses its internal nodes entirely, unless a given Graph State Variable matches a pattern. For example, if the group contained nodes responsible for material assignments, the node could be configured to read an "assignmaterials" variable, with the pattern set to “yes”. The material assignments would then only be active if the value of "assignmaterials" was set to "yes".

## Scripts

### OpScript

Graph State Variables can be read in OpScript nodes. The function signature for this is:

string Interface.GetGraphStateVariable(string variableName)

OpScripts cannot manipulate Graph State Variables as, by the time an OpScript is executed, the contributing nodes (and their associated Graph States) have already been determined.

### The getGraphState() Function

Instances of NodegraphAPI.Node have a .getGraphState() method for retrieving the local graph state seen by the node. This method takes two optional arguments:

• node - a NodegraphAPI.Node instance. This is used as a starting node for walking the node graph. If None or not given, this parameter defaults to the currently viewed node.

• graphState - a NodegraphAPI.GraphState instance. This is the global graph state that is passed to the start node (given above). If None, or not given, this parameter defaults to the scene-wide global graph state.

Additionally, the global graph state can be retrieved through NodegraphAPI.GetCurrentGraphState().