import Gaffer graph = Gaffer.GraphComponent() node1 = Gaffer.Node() graph.addChild(node1) node2 = Gaffer.Node() graph.addChild(node2)
import Gaffer import GafferUI class MyNode(Gaffer.Node): def __init__(self, name="MyNode"): Gaffer.Node.__init__(self, name) # Define inputs and outputs self.addChild(Gaffer.IntPlug("in", Gaffer.Plug.Direction.In)) self.addChild(Gaffer.IntPlug("out", Gaffer.Plug.Direction.Out)) def compute(self, plug): if plug.getName() == "out": inPlug = self["in"] outPlug = self["out"] outPlug.setValue(inPlug.getValue() * 2) # Register the node type Gaffer.Node.registerType("MyNode", MyNode)In this example, we define a custom node that multiplies an input value by two. We define inputs and outputs, and define the `compute` method that performs the computation. We also register the node type so that it can be used in a node graph. Python Gaffer Node is part of the Gaffer package library, which includes other modules such as GafferUI for building user interfaces, GafferScene for working with scene graphs, and GafferOSL for integrating OpenShadingLanguage.