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.
Each point can store arbitrary values in named attributes.
Methods ¶
Point data ¶
geometry()
→ hou.Geometry
Returns the hou.Geometry object containing this point.
number()
→ int
Returns the point number of this point. Points are numbered sequentially across the entire Geometry starting from 0, and the points returned by hou.Geometry.points are in point number order.
prims()
→ tuple
of hou.Prim
Returns a tuple of the primitives that reference this point.
vertices()
→ tuple
of hou.Vertex
Returns a tuple of the vertices that reference this point.
This requires a search through a primitive’s vertices, so the cost grows with the total number of vertices across this point’s primitives.
position()
→ hou.Vector3
Return the position of this point as a hou.Vector3 containing the (X, Y, Z) values.
You can transform the Vector3
using a hou.Matrix4:
xform = hou.node("/obj/geo1").worldTransform() # Matrix4 new_pos = point.position() * xform
This method is a shortcut for accessing the P
attribute of the point. However, it is not equivalent, because point.attribValue("P")
returns a 3-tuple of floats, not a Vector3
object:
point.position() # is equivalent to hou.Vector3(point.attribValue("P"))
setPosition(position)
Changes the point’s location. You would typically call this method from the code of a Python-defined SOP.
position
is any sequence of floats, such has a hou.Vector3 or a tuple or list of
floats, of length 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 or 4.
weight()
→ float
Return the weight of this point. Point weights are displayed in Houdini’s geometry spreadsheet as the fourth component of the position. Point weights are used by NURBS.
Usually, the weight is 1.0.
This method is an alternative for accessing the Pw
attribute of the point
that will still work even when the Pw
attribute does not exist.
point.weight() # is equivalent to point.attribValue("Pw") # if the "Pw" attribute exists, and otherwise returns 1.0
You can build a hou.Vector4 containing both the position and weight:
hou.Vector4(tuple(point.position()) + (point.weight(),))
See also hou.Point.position.
setWeight(weight)
Change the point’s weight. You would typically call this method from the code of a Python-defined SOP.
This method is an alternative for calling hou.Point.setAttribValue on
the Pw
attribute that will create the attribute if necessary.
See hou.Point.weight for more information about a point’s weight. See also hou.Point.setPosition.
Attributes ¶
attribType()
→ hou.attribType enum value
Always returns hou.attribType.Point
.
This is only useful if you want to write generic code that works whether the input objects are hou.Prim, hou.Point, or hou.Vertex. They all have an attribType()
method that returns the right attribType
value for the given object.
attribValue(name_or_attrib)
→ int
, float
, str
, tuple
or dict
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)
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.
If the attribute is an array, the seqeunce must be a flat array, not an array of tuples. If the attribute is float, ensure the python objects are float, and not integer (1.0, not 1).
Raises hou.GeometryPermissionError if this geometry is not modifiable.
See hou.Geometry.addAttrib for an example.
See also:
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 hou.Point.floatAttribValue for more information.
dictAttribValue(name_or_attrib)
→ dict
Return the point attribute value for a particular dictionary attribute. The attribute may be specified by name or by hou.Attrib object. See hou.Point.floatAttribValue for more information.
dictListAttribValue(name_or_attrib)
→ tuple
of str
Return the point attribute value for a particular dictionary attribute. The attribute may be specified by name or by hou.Attrib object. The return value is a tuple of dictionaries.
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 hou.Point.floatAttribValue for more information.