hou.Surface class

A Surface is a kind of geometry primitive (Prim object) that contains a two dimensional grid of vertices (Vertex objects). How these vertices are used depends on the type of surface: meshes, for example, use the vertices to define a quadrilateral mesh, while NURBS surfaces use them as control points.

Inheritence: hou.Prim >

A hou.Face, on the other hand, stores a sequence of vertices, and might be a polygon or NURBS curve.

Methods

numCols(self)

Return the number of columns in the 2D array of vertices.

numRows(self)

Return the number of rows in the 2D array of vertices.

vertex(self, u_index, v_index)

Return an element in the 2D array of vertices, given the u (column) and v (row) indices into the array.

Negative indices are allowed, in which case Houdini will index starting from the last vertex.

For non-negative indices, this method is roughly equivalent to writing surf.vertices()[v_index * surf.numCols() + u_index].

Raises hou.OperationFailed if the u or v indices are invalid.

# Use a grid SOP to create a NURBS grid with 3 rows and 2 columns.
geo = hou.node("/obj").createNode("geo").createNode("grid").geometry()
grid_node = geo.sopNode()
grid_node.setDisplayFlag(True)
for name, value in ("type", "nurbs"), ("rows", 5), ("cols", 4):
    grid_node.parm(name).set(value)

# Print out the x positions of all the vertices in the surface.
surf = geo.iterPrims()[0]
for v_index in surf.numRows():
    for u_index in surf.numCols():
        print surf.vertex(u_index, v_index).point().position()[0],
    print

See also:

verticesInCol(self, u_index)

Given a u (i.e. column) index, return a tuple containing all the vertices in that column.

See also hou.Prim.vertices.

verticesInRow(self, v_index)

Given a v (i.e. row) index, return a tuple containing all the vertices in that row.

See also hou.Prim.vertices.

addCol(self, after=-1)

Add a column of vertices after the given u (i.e. column) index. You would typically call this method from the code of a Python-defined SOP.

This method also adds one point per vertex added. The new points are located at the origin until you move them.

The u (i.e. column) index after may be negative, in which case the indexing starts from the end. By default, after is -1, meaning that the new column will go after the last column. Raises hou.OperationFailed if the after index is invalid.

# This code will work from inside a Python SOP, but not from the Python
# shell.
def vertexPos(vertex):
    return hou.Vector3(vertex.point().position())

# Build a NURBS surface.
geo = hou.pwd().geometry()
surf = geo.createNURBSSurface(10, 10)

# Add a new column, and set the new point positions to the average of
# the adjacent point positions.
surf.addCol(after=7)
for v_index in range(surf.numRows()):
    vertex_before = surf.vertex(7, v_index)
    vertex_after = surf.vertex(9, v_index)
    surf.vertex(8, v_index).point().setPosition(
        (vertexPos(vertex_before) + vertexPos(vertex_after)) * 0.5)
addRow(self, after=-1)

Add a row of vertices after the given v (i.e. row) index. The new vertices are located at the origin until you move them. You would typically call this method from the code of a Python-defined SOP.

See hou.Surface.addCol for more information.

positionAt(self, u, v) → Vector4

Given normalized (i.e. from 0 to 1) u and v values, returns the position of the surface at that parametric location.

See hou.Point.position for information about why the position is a Vector4.

See the surface_wires cookbook example for an example.

normalAt(self, u, v)

Given normalized (i.e. from 0 to 1) u and v values, returns the normal of the surface at that parametric location. The normal is a vector that is perpendicular to the surface at that location.

The normal vector is normalized (i.e. it is a unit vector, so its length is 1).

See the surface_wires cookbook example for an example.

attribValueAt(self, attrib_name, u, v, du=0, dv=0)

Return an attribute value at a normalized (u, v) parametric position on the surface. If du and dv are both 0, returns the interpolated attribute value; otherwise, returns the (partial) derivative of the attribute value.

Raises hou.OperationFailed if the attribute is not a point or vertex attribute. If you want a primitive attribute value, it doesn’t vary across the surface, so use hou.Prim.attribValue.

isClosedInU(self)

Return whether the first and last columns of vertices are connected.

A grid, for example, is open in both U and V. A tube is open in one of U or V and closed in the other. A torus is closed in both U and V.

isClosedInV(self)

Return whether the first and last rows of vertices are connected.

See hou.Surface.isClosedInU for more information.

uDegree(self)

Not implemented yet

vDegree(self)

Not implemented yet

curvature(self, u, v)

Not implemented yet

curveOnSurfaceLength(self, u_start, v_start, u_end, v_end)

Not implemented yet

knotValueU(self, knot_index)

Not implemented yet

knotValueV(self, knot_index)

Not implemented yet

parametricToUniformU(self, u)

Not implemented yet

parametricToUniformV(self, v)

Not implemented yet

uniformToParametricU(self, u)

Not implemented yet

uniformToParametricV(self, v)

Not implemented yet