How To: Use User Data with Attributes
In addition to using tags such as selection tags, you can use user data in an attribute tag.
As an example, consider this very simple node tree:
Placed on a sphere, this produces this result:
Which is hardly exciting, but shows what we would expect if the Color Ramp Fac value is set at 0.5 - the colour halfway along the gradient is purple.
To change the colour we can alter the Fac value to give red if it is zero and blue if the value is 1. But that means opening the node editor and editing the node directly. Wouldn't it be simpler if we could employ user data to do this for us, since this is accessible in the Cinema 4D attribute manager?
Adding the user data
First, we need some user data. This should be added to the sphere object; in this case, all we need is a Float value with a range of 0 to 1 (or 0% to 100% if you prefer). In the sphere object, we would see this:
Here the data item is named 'MyData' but you can call it what you like.
Adding the Attribute tag
Now we can add an Attribute tag to the sphere. We then add a new attribute by clicking the 'Add Attribute' button. The attribute must then be given the same name as the user data we want to use. The tag would look like this:
Note that the 'Tag' and 'Tag Name' fields are empty, since there is no tag to add to these fields.
Adding an Attribute node
We now add an Attribute node to the node tree. The type must be set to 'Custom' and the name to the user data we want to use - 'MyData' in this case. Then the 'Fac' output is linked to the 'Fac' input of the Color Ramp. The node tree then looks like this:
So what has changed? Well, we can now control the Fac value in the Color Ramp using the user data control in the sphere - we don't need to open the node editor at all. This is much more convenient. Since user data allows many different data types to be used, you can control many settings in a node by this method, and once the node tree is set up, never have to open it to change values.
You don't need multiple attribute tags to control more than one node setting. Use one tag and add as many user data items and attributes as you need. You will, however, need one attribute node in the node tree for each setting you want to control in this way.