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(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() or hou.Geometry.pointFloatAttribValuesAsString() 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(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(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 tuple of floats.
It is valid to call this method when the attribute’s size is 1. In this case, a tuple with one element is returned.
See also hou.Point.attribValue().
intAttribValue(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(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 tuple of ints. See hou.Point.floatListAttribValue() for more information.
stringAttribValue(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.
stringListAttribValue(name_or_attrib)
→ tuple
of str
Return the point attribute value for a particular string attribute. The attribute may be specified by name or by hou.Attrib object. The return value is a tuple of strings.
It is valid to call this method when the attribute’s size is 1. In this case, a tuple with one element is returned.
See also hou.Point.attribValue().
position()
→ 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()
→ 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(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(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(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()
→ 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()
→ hou.Geometry
Return the hou.Geometry object containing this point.
number()
→ 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(matrix)
destroy()
minDistanceToPrim(prim)
uvOfClosestLocationOnPrim(prim)
hasCollided()
isStuck()