User guide
183
For example, the StaticSceneCreate Op accepts a GroupAttribute called a that contains a list of attributes, which
contain values to set at a given location. This appears as:
StaticSceneCreate handles the a argument as follows:
FnAttribute::GroupAttribute a = interface.getOpArg("a");
if (a.isValid())
{
for (int i = 0; i < a.getNumberOfChildren(); ++i)
{
interface.setAttr(a.getChildName(i), a.getChildByIndex(i));
}
}
NOTE: It's important to check the validity of an attribute after retrieving it using the isValid() call. You
should check an attribute’s validity every time you are returned an attribute from the cook interface.
Passing Arguments to Child Locations
There is a common recursive approach to passing arguments down to child locations on which an Op runs. The
StaticSceneCreate Op exemplifies this pattern quite nicely.
StaticSceneCreate sets attributes and creates a hierarchy of child locations based on the value of one of the
arguments passed to it. This argument is a GroupAttribute that for each location describes:
• a - attributes values
• c - the names of any child locations
• x - whether an additional Op needs to be evaluated at that location
To pass arguments to the children it creates, it peels off the lower layers of the c argument and passes them to its
children. Conceptually, you can consider it as follows (details of a and x are omitted for brevity):
24 OP API | THE OP API EXPLAINED