User guide

193
The GenericOp node converts the contents of its opArgs parameter into the opArgs GroupAttribute required by the
Op using an existing parameter-to-attribute convention established by the AttributeSet node.
The convention follows that:
String parameters become StringAttributes.
Non-empty Group parameters become GroupAttributes.
Number and numberArray parameters are converted into FloatAttributes. You can specify a different numeric
attribute type by adding a peer parameter with the same name prefixed with "__type__" whose value is "IntAttr",
"DoubleAttr" or "FloatAttr". Note: Because the user parameter editor disallows parameter names starting with "__"
(for legacy reasons) it is not possible to set this parameter via the UI, it can however, be created or renamed via the
scripting interface.
As a convenience, and to avoid the number types issue mentioned above, GenericOp node instances have a method
for constructing the "opArgs" parameter hierarchy (with any necessary "__type__" parameters) from an
FnAttribute.GroupAttribute or ScenegraphAttr.GroupAttr:
genericOpNode = NodegraphAPI.CreateNode("GenericOp", NodegraphAPI.GetRootNode())
genericOpNode.buildArgsParametersFromAttr(
FnAttribute.GroupBuilder()
.set("some.nested.int_param", FnAttribute.IntAttribute(4))
.set("some.nested.float_param", FnAttribute.FloatAttribute(42.0))
.set("my_string_array", FnAttribute.StringAttribute(["a", "b", "c"]))
.build())
One minor limitation of this method is that there's currently no means to force a single element attribute to be
constructed as an array parameter. This doesn't affect the resulting attribute built from the parameter, but is a
concern if you want to change the array length following creation.
Valid Ops cooked from input ports of GenericOp are added in sequence through setOpInputs(). These are not
added sparsely and no error checking is done, so invalid inputs are omitted. That's only relevant if your Op requires
more than one input and depends on knowing from which absolute port index an input Op was cooked.
The NodeTypeBuilder Class
Katana provides the NodeTypeBuilder class to simplify the definition of new nodes to represent your Op in the
nodegraph. For more information on the NodeTypeBuilder class, refer to NodeTypeBuilder on page198.
Op Toolchain
There is a very simple toolchain to allow you to produce the boilerplate code required to write your own Ops, the
steps below guide you through the process:
1. Run the CreateOp.py utility script
$KATANA_HOME/plugin_apis/CreateOp.py <Op_Name_1> ... <Op_Name_N>
24 OP API | INTEGRATING CUSTOM OPS