hou.Attrib class

This class stores information about a Geometry attribute.

An attribute describes extra data you can attach to different elements of geometry. The attribute values are the individual instances of that data, and for each attribute there is exactly one attribute value per geometry element. For example, if you look at the points in Houdini’s geometry spreadsheet, the point numbers are listed down the side, the point attributes are listed across the top, and the point attribute values are contained in the table.

The attribute specifies which elements store the attribute values: points, primitives, or vertices. An attribute can also be global (also known as a detail attribute), in which case there is one instance of the attribute value in the geometry.

The attribute also specifies the data type of the attribute values.

To look up existing attributes, use hou.Geometry.findPointAttrib, hou.Geometry.findPrimAttrib, hou.Geometry.findVertexAttrib, and hou.Geometry.findGlobalAttrib. To add a new attribute, use hou.Geometry.addAttrib.

Note

Point positions are stored in a point attribute named P and point weights are stored in Pw. See hou.Point.position and hou.Point.weight for more information.

Methods

name(self)str

Return the attribute’s name. Each attribute in the geometry has a unique name.

type(self)hou.attribType enum value

Return the type of attribute (point, primitive, vertex, or global).

dataType(self)hou.attribData enum value

Return the attribute’s data type (int, float or string).

The size of the attribute also determines the format of the attribute values. For example, if the data type is int and the size is 3, the attribute value will be a tuple of 3 ints. If the size was 1, the attribute value would simply be an int.

Note that a string attribute’s size must be 1.

size(self)int

Return the number of data components in the attribute value. See hou.Attrib.dataType for more information.

strings(self) → tuple of str

Return the string table for this attribute. If the attribute is not a string, returns an empty tuple.

A string attribute does not store each string value inside the attribute element (i.e. point, primitive, etc.). Instead, the unique string attribute values are stored in a table inside the attribute, and each attribute value stores an index to that string.

For example, suppose this attribute stores strings on points. If all points have the attribute value "foo" then the string table will be just ("foo",) and each point will store the index 0. When you set some points' values to "bar", Houdini adds sets the string table to ("foo", "bar") and sets stores the index 1 in those points. When you set one of those points back to "foo", Houdini leaves the string table unchanged and stores the index 0 in that point.

When using string attribute values, this implementation is hidden from you, and you get and set those attributes as strings. This method is provided only in case you need access to the string table.

defaultValue(self)int or float or string or tuple

Not implemented yet

geometry(self)hou.Geometry

Return the Geometry object containing this attribute.

isTransformedAsNormal(self)bool

Return whether attribute values in the geometry are automatically transformed as a normal when Houdini transforms (e.g. rotates) the geometry.

For more information, see the hou.Geometry.addAttrib, in the transform_as_normal parameter documentation.

setDefaultValue(self, default_value)

Not implemented yet

destroy(self)

Not implemented yet