hou.Point class

Each Point object resides inside a Geometry object and stores a 3D position. Points may be shared between primitives (such as polygons), and the set of points and primitives describes a 3D shape.

The set of points may also store arbitrary data in the form of attributes, and each point instance stores a unique attribute value.

Methods

attribValue(self, name_or_attrib)int, float, str or tuple

Return value stored in this point for a particular attribute. The attribute may be specified by name or by hou.Attrib object.

Looking up an attribute value using a hou.Attrib object is slightly faster than looking it up by name. When looking up attribute values inside a loop, look up the hou.Attrib object outside the loop, and pass it into this method.

Note that the point position attribute is named P and is 4 floats in size. This attribute always exists.

When looking up the attribute values of all points, it is faster to call hou.Geometry.pointFloatAttribValues than to call this method for each point in the geometry.

Raises hou.OperationFailed if no attribute exists with this name.

# Create an object containing two SOPs: a box SOP wired into a color SOP.
geo_node = hou.node("/obj").createNode("geo")
box = geo_node.createNode("box")
color = geo_node.createNode("color")
color.setFirstInput(box)

# Grab the color SOP's geometry, get its first point, and print out the
# value of the Cd attribute.
geo = color.geometry()
point = geo.iterPoints()[0]
print point.attribValue("Cd")

# Look up the Cd attribute and illustrate how to access the attribute
# value using the attribute object.
cd_attribute = geo.findPointAttrib("Cd")
print point.attribValue(cd_attribute)
floatAttribValue(self, name_or_attrib)float

Return the point attribute value for a particular floating point attribute. The attribute may be specified by name or by hou.Attrib object.

Raises hou.OperationFailed if no attribute exists with this name or the attribute is not float of size 1.

In most cases, you’ll just use hou.Point.attribValue to access attribute values. Houdini uses this method internally to implement attribValue.

floatListAttribValue(self, name_or_attrib)tuple of float

Return the point attribute value for a particular floating point attribute. The attribute may be specified by name or by hou.Attrib object. The return value is a list of floats.

It is valid to call this method when the attribute’s size is 1. In this case, a list with one element is returned.

See also hou.Point.attribValue.

intAttribValue(self, name_or_attrib)int

Return the point attribute value for a particular integer attribute of size 1. The attribute may be specified by name or by hou.Attrib object. See hou.Point.floatAttribValue for more information.

intListAttribValue(self, name_or_attrib)tuple of int

Return the point attribute value for a particular integer attribute. The attribute may be specified by name or by hou.Attrib object. The return value is a list of ints. See hou.Point.floatListAttribValue for more information.

stringAttribValue(self, name_or_attrib)str

Return the point attribute value for a particular string attribute. The attribute may be specified by name or by hou.Attrib object. See hou.Point.floatAttribValue for more information.

position(self)hou.Vector3

Return the position of this point as a Vector3 containing the (X, Y, Z) position values.

This method is a shortcut for accessing the P attribute of the point.

point.position()
# is equivalent to
hou.Vector3(point.attribValue("P"))

Because the position is returned as a Vector3, it can be accessed as a sequence. However, you can also easily use hou.Matrix4 to transform the position.

See also:

weight(self)float

Return the weight of this point. Point weights are displayed in Houdini’s geometry spreadsheet as the fourth component of the position, and are used in NURBS curves and surfaces.

Most of the time, the weight is 1.0.

This method is a shortcut for accessing the Pw attribute of the point.

point.weight()
# is equivalent to
point.attribValue("Pw")

You can build a hou.Vector4 containing both the position and weight as follows:

hou.Vector4(tuple(point.position()) + (point.weight(),))

See also hou.Point.position.

setAttribValue(self, name_or_attrib, attrib_value)

Store an attribute value in this point. The attribute may be specified by name or by hou.Attrib object, and must be an existing point attribute in the geometry. You would typically call this method from the code of a Python-defined SOP.

Raises hou.OperationFailed if no attribute exists with this name or if the attribute’s data type does not match the value passed in. If the attribute’s size is more than 1, the attribute value must be a sequence of integers/floats, and the size of the sequence must match the attribute’s size.

Raises hou.GeometryPermissionError if this geometry is not modifiable.

See hou.Geometry.addAttrib for an example.

See also:

setPosition(self, position)

Changes the point’s location. You would typically call this method from the code of a Python-defined SOP.

position

Any sequence of floats, such has a hou.Vector3 or a tuple of floats, of length either 3 or 4. The fourth coordinate corresponds to the weight, and is usually 1. The weight is typically used by NURBS curves and sequences. If the sequence is of size 3, the weight will be unchanged.

This method is a shortcut for calling hou.Point.setAttribValue on the P attribute.

point.setPosition((x, y, z))
# is the same as
point.setAttribValue("P", (x, y, z))

Raises hou.GeometryPermissionError if the geometry is not modifiable. Raises hou.InvalidSize if the length of position is not 3.

See also hou.Point.setWeight.

setWeight(self, weight)

Change the point’s weight. You would typically call this method from the code of a Python-defined SOP.

This method is a shortcut for calling hou.Point.setAttribValue on the Pw attribute.

See hou.Point.weight for more information about a point’s weight. See also hou.Point.setPosition.

attribType(self)hou.attribType enum value

Return the enumerated value hou.attribType.Point. Points, primitives, vertices, and geometry support the same set of methods for querying their attributes, and this method is one of them.

See also:

geometry(self)hou.Geometry

Return the hou.Geometry object containing this point.

number(self)int

Return the number of this point. Points are numbered sequentially starting from 0, and the points returned by hou.Geometry.points are in order by their number.

transform(self, matrix)

Not implemented yet

destroy(self)

Not implemented yet

closestPrim(self)hou.Prim or None

Not implemented yet

minDistanceToPrim(self, prim)

Not implemented yet

pointsOnPrimsSharingThisPoint(self, num_prims)tuple of hou.Point

Not implemented yet

uvOfClosestLocationOnPrim(self, prim)

Not implemented yet

hasCollided(self)

Not implemented yet

isStuck(self)

Not implemented yet