# Attribute Create

The Ultimate Houdini node reference

# Visit the Node Bible

### Attribute Create

The Attribute Create node creates an attribute that's associated with your geometry. This attribute can be a float, integer, string, or vector information that's associated with your points, vertices, primitives, and/or the entire geometry stream itself through the detail context.
Drag to resize

Summary:

If you're new to Houdini, then you'll certainly want to learn all about attributes because they are responsible for controlling the behavior of anything in your scene!  This includes other nodes, solvers, shaders, lights, render settings, and more.  In your head, picture attributes as pieces of data that get attached to the points, primitives (which are usually polygon faces), vertices, or the entire node stream itself if you choose "detail."  In addition to this node, it's also common practice to add attributes using vex in wrangles.  Either way works in most circumstances.

Also keep in mind that the Attribute Create node has many advanced/misc. options.  If you get lost or confused with what some of these settings are trying to do - don't worry about it.  I've marked the Advanced/misc. options below to warn you about them.  95% of the time, you don't need to worry about the advanced/misc. sections in this node, so don't let them stress you out.

If you're new to understanding attributes, first understand what "Types" are referring to - (ex: "float," "integer," "vector," "string," etc...)  Here is a useful guide to what those terms mean.

Float
= A number which is allowed to have a decimal value (ex: 39.8, -1473.2, 0.3)

Integer
= A number which is not allowed to have a decimal value (ex: 3, 4, -1, 39)

Vector
= A collection of three values (often used to describe position and color).  (ex: {2,3,2}, {23.38,4.3,301.0})
**  Keep in mind that if something is a "Float Vector" or an "Integer Vector" that it is describing whether the numbers within the collection of three values are floats or integers.
String = Anything that uses letters instead of numbers. (ex: "Foo," "Le'goo", "\$HIP/myPath/")

= Arrays are basically a collection of values (not limited to 3 like vectors) and are often used to store data while running for-loops over things.  With arrays you cannot specify defaults or alter their values. The Size field also refers to tuple size, so a size of 3 means an array of vector 3s, not an array 3 floats long.  An example of an array is if you wanted to store a collection of color values.  These color values are vectors (a collection of three values), and in the array you are collecting multiple vectors in one place.

= "Since Houdini 18.5, SOP geometry supports dictionary attributes, an attribute type where each element (point, vertex, primitive/face, or the whole geometry/detail) can store a set of key/value pairs.
--  You could use a dictionary attribute to store complex "blind" element data, such as game engine data, or data for a foreign geometry format that Houdini does not support natively.
--  You could store metadata about geometry in a dictionary attribute on the detail.
--  You could store the parameter values of the node that created different elements, for debugging. You could even store a node network as geometry by representing nodes with points and wires and parameters in a dictionary point attribute. See the Attribute From Parms SOP.
--  (You can also create a dictionary array attribute, where the attribute value is an array of dictionaries, rather than a single dictionary.)
Dictionary keys are strings. Dictionary values can be string, number, an array, or a (nested) dictionary. Dictionary attributes essentially have the same data model as JSON. In fact, UI such as the geometry spreadsheet displays the contents of a dictionary attribute like a JSON-encoded string.
Currently, support for dictionary attributes is mostly in Python, VEX, VOPs. You can manipulate dictionary attributes on geometry using VEX snippets in an Attribute Wrangle, or with a Python SOP. There is also simple support for reading key values in parameter expressions."

https://www.sidefx.com/docs/houdini/model/attributes.html

Drag to resize

Main Parameters:

Group:

--  This allows you to only apply that attribute to certain points, primitives, or vertices of your mesh.

Encode Invalid Attribute Names:  (Misc. Advanced Parm)

--  When naming attributes, it's possible to enter invalid characters that mess it up.  According to the docs, "Valid attribute names contain only letters, numbers or underscore (_), and must not start with a number."  So, with this un-checked, the create attribute node will create a warning telling you all about it.  It will also try to replace the invalid characters with underscores.
If you check this box on, then Houdini will do this cool thing where it encodes the attribute name.   This means that it stores and displays the original name, but internally, it uses a different name so that Houdini doesn't have problems with calculating invalid names.
As an example, if I try to create an attribute called 698-foo and check on the "Encode Invalid Attribute Names," it will create an attribute called 698-foo and internally use something named "xn__698-foo_"  In order to restore the original name, you'll need to decode the attribute.  See the examples below:
Keep in mind that you may need to "Decode" these attributes to internally restore the original name.  For more information, please visit this link:  https://www.sidefx.com/docs/houdini/expressions/decode.html

Number of Attributes:

-  How many attributes would you like to create?

Drag to resize

Names:

Name:

--  This specifies the name of the attribute.  The name is then associated with a value described below.

Existing Name:

--  Trying to name this attribute the same thing as an existing attribute?  Well this dropdown tells the Attribute Create node how to deal with that situation.
*  Use the Better Type, Size, and Precision
**  In practice, you probably don't need to mess with this parameter, but here's what it means... You might be wondering, "what makes an attribute type, size, or precision 'better?'"  Well, the more complicated version of something is considered to be the "better" version.  As an example, integers can't have decimal values, but floats can.  So if you had an existing float attribute called "foo" with a value of 3.23 and the attribute create wants to make an integer attribute called "foo" as well with a value of 4, then the float "foo" would win because it's considered the "better" version.  Strings and numeric values are considered incompatible and so the requested type prevails in that situation.
*  Generate error on mis-matched attribute:
**  An error will be generated and the existing attribute, and its values will be left as-is.
*  Generate warning on mis-matched attribute:
**  The existing attribute definition will not be changed, but its values will be overwritten if Write Values is enabled.
*  Replace existing attribute:
**  The existing attribute definition will be replaced completely by the new definition.

Drag to resize

Local Variables:

--------------
Jeff from SideFX has a great video detailing what Local Variables are.  Check it out right here:
--------------
So, in the video we can see that nodes understand these "Local Variables" with the \$ and capital letters.  HOWEVER - keep in mind that this method is becoming obsolete.  If you want to access attribute data, the easiest way to do so is to right-click the parameter --> reference --> scene data

Local Variable

--  Let's say that you want to create your own local variable based on the attribute value that's specified in this node.  You can do so here.  So, as an example, you can create \$FOO by typing in "FOO" within the Local Variable parameter.  If you leave this blank, then it will simply take the attribute name and you can access it by using all capital letters along with the \$ sign.
*  This local variable is mapped by creating a detail attribute called 'varmap'
*  NOTE:  Using local variables for nodes further along the chain is becoming depreciated and may not work on every node.  If you want to use \$FOO on a poly-extrude node (as an example), then you will not return the correct values.  In general, it's advised to avoid this particular local variable and, instead, use attributes @foo instead of local variables \$FOO when trying to access values.

For more information, visit this forum post which offers a great comparison between attributes vs. variables:
https://www.sidefx.com/forum/topic/11090/

Drag to resize

Attribute Data/Values:

Class
:

S

--  It's possible to save out detail attribute information towards the beginning of the .bgeo file as metadata.  If you check this on, that's exactly what will happen when you cache out your data.  The reason why this is nice is because it allows you to load this attribute data WITHOUT loading the geometry.  This is possible by using the file sop along with the "Load" parameter set to "Info."

Type
:

--  See above in the Summary section

Type Qualifier (next to Type): (Advanced/Misc.)

--  In most situations, you will not need to concern yourself with this parameter.  "Qualifiers" act as an additional category that's universally understood by Houdini.  According to the user docs...
*  Guess from name = If the name is N, the qualifier will be "Normal". If the name is Cd, the qualifier will be "Color". If the name is v or up, the qualifier will be "Vector". Otherwise, the qualifier will be "None".
*  None = No special treatment
*  Position = This attribute is a geometric point. Houdini will transform the attribute as a position.
*  Vector = Houdini will transform the attribute as a vector.
*  Normal = Houdini will transform the attribute as a normal.
*  Color = The attribute is a color
*  Quaternion = Houdini will transform the attribute as a quaternion

--  When values are calculated, the computer is allowed to think of a certain range of values depending on the bit selected.  Lower bit = less memory to express that attribute which = smaller cache files sizes = faster to read caches.  The Houdini user docs actually has a pretty great explanation of this, so check out this link for more info:

https://www.sidefx.com/docs/houdini/nodes/sop/attribcast.html

This can make a pretty substantial impact on the size of your cache files and ought to be considered when optimizing your scene.

Size:

--  The "Size" can turn an attribute into a collection a values.  As an example, a "vector" is a collection of 3 values.  If I set the Type to Float and the "Size" to 3, then that is the same thing as saying that it's a "vector" and shows up in the geometry spreadsheet as the same thing.  The reason why "Vector" has a special category is just because it's so common.  To see this clearly, visit the geometry spreadsheet and adjust the "Size" parameter.

Default:

--  Lets say that you decide to use the "Group" parameter at the very top of the node settings and select something.  The things included in the group will get the "Value" that you list below.  Everything that's not selected by the group will get the "Default" that you specify here.

Write Values:

--  Toggles the Value section below

Allow Local Variables:

--  See the Variables section above

Value:

--  See the Default section above.