User guide
185
NOTE: It is important to remember the distinction between the set of functions described here and those
described in Reading Scene Graph Input on page188. All functions described here operate on the output
of an Op at a given Scene Graph location. The functions described in Reading Scene Graph Input
relate only to reading the scene graph data on the input of an Op at a given scene graph location, which is
immutable.
The setAttr() Function
void setAttr(const std::string& attrName,
const FnAttribute::Attribute& value,
const bool groupInherit = true);
The setAttr() function allows you to set an attribute value at the location at which your Op is currently being
evaluated. For example, to set a StringAttribute at your Op’s root location you can do the following:
if (interface.atRoot())
{
interface.setAttr("myAttr", FnAttribute::StringAttribute("Val"));
}
It is not possible to set attributes at locations other than those where your Op is currently being evaluated. If you call
setAttr() for a given attribute name multiple times on the same location, the last one called is the one that is used.
The groupInherit parameter is used to determine if the attribute should be inherited by its children.
NOTE: Since setAttr() sets values on the Op’s output, while getAttr() is reading immutable values on a
given input, if a call to setAttr() is followed immediately by getAttr(), the result is still just the value from
the relevant input, rather than returning the value set by the setAttr().
The createChild() Function
void createChild(const std::string& name,
const std::string& optype = "",
const FnAttribute::Attribute& args = FnAttribute::Attribute(),
ResetRoot resetRoot = ResetRootAuto,
void* privateData = 0x0,
void (*deletePrivateData)(void* data) = 0x0);
The createChild() function allows you to create children under the scene graph location at which your Op is being
evaluated. In the simplest case it requires the name of the location to create, and arguments that should be passed
to the Op that is evaluated at that location. For example:
interface.createChild(childName, "", childArgs);
24 OP API | THE OP API EXPLAINED