.. _ogn_tutorial_bundle_add_attributes:

Tutorial 21 - Adding Bundled Attributes
=======================================

Sometimes instead of simply copying data from an input or input bundle into an output bundle you might want to
construct a bundle from some other criteria. For example a bundle construction node could take in an array of names
and attribute types and output a bundle consisting of those attributes with some default values.

The bundle accessor provides a simple method that can accomplish this task. Adding a new attribute is as simple as
providing those two values to the bundle for every attribute you wish to add.

There is also a complementary function to remove named bundle attributes.

OgnTutorialBundleAddAttributes.ogn
----------------------------------
The *ogn* file shows the implementation of a node named "omni.graph.tutorials.BundleData", which has one input bundle and one
output bundle.

.. literalinclude:: ../../../../../source/extensions/omni.graph.tutorials/tutorials/tutorial21/OgnTutorialBundleAddAttributes.ogn
    :linenos:
    :language: json

OgnTutorialBundleAddAttributes.cpp
----------------------------------
The *cpp* file contains the implementation of the compute method. It accesses the attribute descriptions on the inputs
and creates a bundle with attributes matching those descriptions as its output.

.. literalinclude:: ../../../../../source/extensions/omni.graph.tutorials/tutorials/tutorial21/OgnTutorialBundleAddAttributes.cpp
    :linenos:
    :language: c++

OgnTutorialBundleAddAttributesPy.py
-----------------------------------
The *py* file contains the same algorithm as the C++ node, with only the implementation language being different.

.. literalinclude:: ../../../../../source/extensions/omni.graph.tutorials/tutorials/tutorial21/OgnTutorialBundleAddAttributesPy.py
    :linenos:
    :language: python
