User guide

63
In certain cases, like when viewing all attributes of a scene graph location in the Attributes tab, Katana iterates over
all names provided by the getLocalAttrNames() function and calls getLocalAttr() (see below) with each of them.
In other cases, such as during a render and in the viewer, Katana only asks for the attributes it needs at that time.
The getLocalAttrNames() and getLocalAttr() functions can also be used to provide error messages to the user in
case the creation of locations and/or attributes fails. Refer to Providing Error Feedback for more information.
FnKat::Attribute getLocalAttr(const std::string & name)
Returns an object of the Attribute class representing the value of the attribute with the given name. All attribute
values have to be wrapped in objects of classes derived from the Attribute class, for example, IntAttribute,
DoubleAttribute, and StringAttribute.
The attribute returned may be a group of attributes, represented by a GroupAttribute object, and therefore contain
other attributes or an entire hierarchy of attributes.
An empty attribute can be returned to indicate that no value is available for a given attribute name if the attribute is
not supported by a scene graph context, as in the last line in the following function block.
The following code snippet shows an example implementation from the CubeRootContext class:
FnKat::Attribute CubeRootContext::getLocalAttr(
const std::string& name) const
{
if (name == "type")
{
return FnKat::StringAttribute("group");
}
else if (name == "xform")
{
FnKat::GroupBuilder gb;
double translate[] = {0.0, 0.0, -10.0};
gb.set("translate",
FnKat::DoubleAttribute(translate,
3, 3));
gb.setGroupInherit(false);
return gb.build();
}
return FnKat::Attribute(0x0);
}
Groups of attributes can be built using the GroupBuilder class which provides a function called build() that returns a
GroupAttribute instance based on attributes that were added to a group using the set() function.
8 SCENE GRAPH GENERATOR PLUG-INS | SGG PLUG-IN API CLASSES