NodeTypeBuilder

class Nodes3DAPI.NodeTypeBuilder.NodeTypeBuilder(nodeTypeName)

Class used for defining Node3D node types via an abstracted interface.

class OpChainInterface(opChainInterface)

Interface to the op chain passed to the node NodeTypeBuilder’s callback.

FAIL = 0
NO_OP = 2
SKIP = 1
addInputRequest(inputPortName, graphState, invalidInputBehavior=0)
appendOp(opType, opArgs=None)

Append the given Op of type ‘opType’ to the op chain.

setExplicitInputRequestsEnabled(state)
setMinRequiredInputs(value)
classmethod NodeTypeBuilder.SetGenericAssignPolicyRegistrationCallback(callback)
NodeTypeBuilder.addInteractiveTransformCallbacks(gb)

Sets up the callbacks to interactively modify the ‘transform’ parameter exposed by the node. If the node doesn’t have a ‘transform’ parameter, it will be created.

Parameters:gb (FnAttribute.GroupBuilder) – The group builder to which add the transform group attribute if not already available.
NodeTypeBuilder.addMakeInteractiveParameter(gb)

Adds the ‘makeInteractive’ attribute to the given group builder. Useful to expose the ‘makeInteractive’ parameter in the node’s parameter interface.

Parameters:gb (FnAttribute.GroupBuilder) – The group builder to which the ‘makeInteractive’ attribute should be added.
NodeTypeBuilder.addTimingParameters(gb)

Adds the timing group attribute to the given group builder. Useful to expose a timing parameter in the node’s parameter interface.

Parameters:gb (FnAttribute.GroupBuilder) – The group builder to which add the timing group attribute.
NodeTypeBuilder.addTransformParameters(gb)

Adds the transform group attribute to the given group builder. Useful to expose a transform parameter in the node’s parameter interface.

Parameters:gb (FnAttribute.GroupBuilder) – The group builder to which add the transform group attribute.
NodeTypeBuilder.build()

Commits the definitions and registers as a node type. This should be called only once.

NodeTypeBuilder.setAddParameterHintsFnc(fnc)

Defines an optional callback function which allows a node to add additional parameter hints when a new parameter is added.

The function should have a signature matching: addCustomParameterHints(self, attrName, inputDict)

It does not return anything.

NodeTypeBuilder.setAppendToParametersOpChainFnc(fnc)

Allows users of NodeTypeBuilder to modify the standard Op chain with additional Ops (and their arguments) to influence the appearance of values in parameters of an edited node.

NodeTypeBuilder.setBuildOpChainFnc(fnc)

Registers the function to be used for building the node’s Op chain.

NodeTypeBuilder.setBuildParametersFnc(fnc)

Defines an optional callback function which has an opportunity to procedurally create parameters on the newly created node instance. This is called following the conversion of values provided by setParametersTemplateAttr.

The function should have a signature matching: buildParameters(node)

Its return value (if any) is discarded.

NodeTypeBuilder.setCustomMethod(fncName, fnc)

Allows specification of custom methods on the resulting node type. If the name is not valid or clashes with an existing member function on the base class, an exception will be thrown during build.

NodeTypeBuilder.setGenericAssignRoots(paramRoot, attrRoot)

Sets the parameter and attribute name to be used as roots by the GenericAssign mechanism.

Parameters:
  • paramRoot (str) – The name of a group parameter in the hierarchy of parameters on a node under which child parameters should show values from the incoming scene, in the form of //Enableable Parameter Groups//.
  • attrRoot (str) – The name of a group attribute that is the target for attributes that correspond to //Enableable Parameter Groups// under the group parameter specified by paramRoot.
NodeTypeBuilder.setGetScenegraphLocationFnc(fnc)

Defines an optional callback function which allows a node to partipate in widgets and parameter expressions

The function should have a signature matching: getScenegraphLocation(node, frameTime)

It should return a single str value in the form of a scenegraph location path. It is allowed to inspect but not mutate its parameters to do so.

NodeTypeBuilder.setHintsForNode(hints)

Sets the hint dictionary used for the node type itself. This is most useful for setting “help” text.

NodeTypeBuilder.setHintsForParameter(paramPath, hints)

Sets the hint dictionary for a given parameter path relative to the node’s top-level parameter group.

NodeTypeBuilder.setInputPortNames(names)

Defines the names and order of input ports to be created on node initialization. By default, newly created types have no input ports.

Parameters:names (sequence of str) – A list of names
NodeTypeBuilder.setIsHiddenFromMenus(state)

Allows you to specify whether the created node type should be hidden from UI menus.

NodeTypeBuilder.setNodeTypeVersion(nodeTypeVersion)

Setting this allows you to tag node instances with a version so that you can provide upgrade paths at katana document parse time. The value defaults to 1 if not set. As only one plug-in can register a node type of a given name, the version of the registered type is considered current for document update purposes. This value is recorded in the node’s XML representation as a “nodetypeversion” attribute.

NodeTypeBuilder.setNodeTypeVersionUpdateFnc(nodeTypeVersion, updateFnc)

Calling this allows you to register a version upgrade function to the specified version from earlier versions. These functions are called during katana document parse and have this signature:

upgradeFnc(nodeElement)

The node element is an instance of PyXmlIO.Element and can be queried and manipulated with the NodegraphAPI.Xio module.

When parsing the document (prior to instantiating nodes), these scripts are run in sequence for the relevant version range. That range is defined by versions greater than document’s recorded version (via the “nodetypeversion” element attribute) and less than or equal to the current registered version.

NodeTypeBuilder.setOutputPortNames(names)

Defines the names and order of output ports to be created on node initialization. By default, newly created types have a single output port named ‘out’.

Parameters:names (sequence of str) – A list of names
NodeTypeBuilder.setParametersTemplateAttr(groupAttr, forceArrayNames=())

Defines the parameter layout of the node using a GroupAttribute as a template. Single-element FloatAttribute, IntAttribute and DoubleAttribute children are converted to number parameters. Single-element StringAttribute children are converted to string parameters. Multi-element attrs are created as array parameters of equivalent type. If forceArrayNames is specified, single-element attrs at the matching relative attribute paths will be created as equivalent array parameters. Child GroupAttributes are created as group parameters.

Op Chain Interfaces

class Nodes3DAPI.NodeTypeBuilder.BaseOpChainInterface(port, graphState)

This is the interface passed to the opchain’s builder method. It exposes some useful methods to get parameters from the node and pass them as arguments to the given Op.

addOpSystemArgs(gb)

Adds the default Op system arguments to the given group builder.

Parameters:gb (FnAttribute.GroupBuilder) – The GroupBuilder to be filled with the op system args.
buildAttrFromParam(param, multisample=False, numberType=<type 'PyFnAttribute.FloatAttribute'>, groupInherit=True)

Utility for converting parameters into attributes, optionally with multi-sampling. This can be run on scalar, array or group parameters. Unless specified, number and number array parameters are converted as FnAttribute.FloatAttribute

Parameters:
buildAttrListForEnableableParameters(enclosingGroupParam)

Utility for converting GenericAssign-style enableable parameter groups into a list of attrPath, attr pairs. This is useful for custom node types with GenericAssign-like behavior.

Parameters:enclosingGroupParam (NodegraphAPI.Parameter) – This should be a group parameter containing child parameters in the enableable parameter group form.
getExclusiveToNameAndAttribute()

Utility function to be used by nodes that accept interactive transformation, that returns a named tuple representing the relative ‘exclusiveTo’ attribute value, if present.

Return type:tuple of (str, StringAttribute) or tuple of (str, None).
Returns:A tuple whose first element is the string ‘attributeEditor.exclusiveTo’. The second element is a StringAttribute with the node’s name if the ‘makeInteractive’ parameter isn’t ‘No’, otherwise None.
getFrameTime()

Returns the frameTime from the context in which the current node is being cooked. This should be used instead of NodegraphAPI.GetCurrentTime() for any parameter evaluation.

Return type:float
getGraphState()

Returns the graphState from the context in which the current node is being cooked.

Return type:GraphState
getModifiedFrameTime()
Return type:float
Returns:The current frame time modified depending on the timing mode, assuming the node has a timing parameter.
getNumSamples()

Returns the “numSamples” hint available to nodes which are concerned with multi-sample values. For pre-sampled data, typical interpretation is to process animation when the value is greater than 1. For data sampled on the fly, this value is the recommendation for how frequently to sample.

Return type:int
getOutputPortName()

Returns the name of the output port from which the current node is being cooked.

Return type:str
getShutterClose()

Returns the “shutterClose” hint available to nodes which are concerned with multi-sample values. This is a frame-relative value.

Return type:float
getShutterOpen()

Returns the “shutterOpen” hint available to nodes which are concerned with multi-sample values. This is a frame-relative value.

Return type:float
getTransformAsAttribute()
Return type:FnAttribute.GroupAttribute
Returns:A GroupAttribute containing the values from the transform group parameter, if available.
class Nodes3DAPI.NodeTypeBuilder.OpChainInterface(opChainInterface)

Interface to the op chain passed to the node NodeTypeBuilder’s callback.

FAIL = 0
NO_OP = 2
SKIP = 1
addInputRequest(inputPortName, graphState, invalidInputBehavior=0)
appendOp(opType, opArgs=None)

Append the given Op of type ‘opType’ to the op chain.

setExplicitInputRequestsEnabled(state)
setMinRequiredInputs(value)
class Nodes3DAPI.NodeTypeBuilder.ParametersOpChainInterface(port, graphState)

Extended interface to the op chain passed to the node NodeTypeBuilder’s callback used for controlling what’s shown as values of enableable parameters that depend on the GenericAssign mechanism.

appendOp(opType, opArgs=None)
getOps()