hou.Geometry class
Methods
addAttrib(self, type, name, default_value, transform_as_normal=False)→ AttribaddGlobalAttrib(self, name, size, default_value)addPointAttrib(self, name, size, default_value)addPrimAttrib(self, name, size, default_value)addTransformableGlobalAttrib(self, name, size, default_value)addTransformablePointAttrib(self, name, size, default_value)addTransformablePrimAttrib(self, name, size, default_value)addTransformableVertexAttrib(self, name, size, default_value)addVertexAttrib(self, name, size, default_value)attribType(self)→ hou.attribType enum valueattribValue(self, name) -> int, float, string, or tuple OR attribValue(self, attrib)→int,float,str, ortupleaveragePointAttribValue(self, attrib_name, index)averagePointAttribValueByType(self, attrib_type, index)averagePrimAttribValue(self, attrib_name, index)averagePrimAttribValueByType(self, attrib_type, index)averageVertexAttribValue(self, attrib_name, index)averageVertexAttribValueByType(self, attrib_type, index)boundingBox(self)→ BoundingBoxcentroid(self)→ Vector3createBezierCurve(self)→ BezierCurvecreateBezierSurface(self)→ BezierSurfacecreateMetaball(self)→ MetaballcreateNURBSCurve(self)→ NURBSCurvecreateNURBSSurface(self)→ NURBSSurfacecreatePoint(self)→ PointcreatePolygon(self)→ PolygoncreateVolume(self)→ VolumedeletePrims(self, prims, keep_points=False)-
Delete a sequence of primitives. You would typically call this method from the code of a Python-defined SOP.
Raises hou.GeometryPermissionError if this geometry is not modifiable.
keep_points
if
True, the primitive will be deleted but its points will remain.To delete a single primitive, pass in a list with one primitive.
# Delete every other primitive: prims = [p for p in geo.prims() if p.number() % 2 == 0] geo.deletePrims(prims) # Delete the first primitive: geo.deletePrims([geo.prims()[0]])
findClosestPoint(self, pos3)→ Point or NonefindClosestPrim(self, pos3)→ Prim or NonefindGlobalAttrib(self, name)→ Attrib or NonefindParticleById(self, particle_id)→ Point or NonefindPointAttrib(self, name)→ Attrib or NonefindPointGroup(self, group_name)→ PointGroup or NonefindPointGroups(self, pattern)→ tuple of PointGroupsfindPrimAttrib(self, name)→ Attrib or NonefindPrimGroup(self, group_name)→ PrimGroup or NonefindPrimGroups(self, pattern)→ tuple of PrimGroupsfindVertexAttrib(self, name)→ Attrib or NonefloatAttribValue(self, name) -> float OR floatAttribValue(self, attrib)→ floatfloatListAttribValue(self, name) -> tuple of floats OR floatListAttribValue(self, attrib)→ tuple of floatsfreeze(self)→ GeometryglobalAttribs(self)→ tuple of AttribsglobPoints(self, patern)→ tuple of hou.PointintAttribValue(self, name) -> int OR intAttribValue(self, attrib)→ intintListAttribValue(self, name) -> tuple of ints OR intListAttribValue(self, attrib)→ tuple of intsiterPoints(self)→ iter of hou.Point-
Return a generator that iterates through all the points in the geometry.
Whereas hou.Geometry.points allocates and returns a tuple of all the points in the geometry, this method returns a generator object that will allocate hou.Point objects on demand.
If you're accessing a specific point by index and the geometry contains many points, it is faster to use iterPoints() than points(). If, however, you are iterating over all the points in the geometry, it is generally faster to use points() than iterPoints().
# This is preferred: geo.iterPoints()[23] # over this: geo.points()[23] # But this is preferred: for point in geo.points(): ...process point... # over this: for point in geo.iterPoints(): ...process point...
iterPrims(self)→ iter of hou.Prim-
Return a generator that iterates through all the primitives in the geometry.
Whereas hou.Geometry.prims allocates and returns a tuple of all the primitives in the geometry, this method returns a generator object that will yield hou.Prim objects on demand.
If you're accessing a specific primitive by index and the geometry contains many primitives, it is faster to use iterPrims() than prims(). If, however, you are iterating over all the primitives in the geometry, it is generally faster to use prims() than iterPrims().
# This is preferred: geo.iterPrims()[23] # over this: geo.prims()[23] # But this is preferred: for prim in geo.prims(): ...process prim... # over this: for prim in geo.iterPrims(): ...process prim...
metaballWeight(self, pos3)pointAttribs(self)→ tuple of AttribspointFloatAttribValues(self, name)→ tuple offloat-
Return a tuple of floats containing one attribute’s values for all the points.
This method only works on int or float attributes. If the attribute contains more than one element, each point will correspond to multiple values in the result. For example, if “Cd” is a float attribute of size 3 and there are 3 point with values (0.1, 0.2, 0.3), (0.5, 0.5, 0.5), and (0.8, 0.7, 0.6) then the result will be (0.1, 0.2, 0.3, 0.5, 0.5, 0.5, 0.8, 0.7, 0.6).
If the attribute name is invalid or the attribute is not an int or float (e.g. it’s a string attribute), this method raises hou.OperationFailed.
pointGroups(self)→ tuple of PointGroupspoints(self)→ tuple of hou.Point-
Returns a tuple of all the points in the geometry.
primAttribs(self)→ tuple of AttribsprimFloatAttribValues(self, name)→ tuple offloat-
Return a tuple of floats containing one attribute’s values for all the primitives.
This method only works on int or float attributes. If the attribute contains more than one element, each primitive will correspond to multiple values in the result. For example, if “Cd” is a float attribute of size 3 and there are 3 primitives with values (0.1, 0.2, 0.3), (0.5, 0.5, 0.5), and (0.8, 0.7, 0.6) then the result will be (0.1, 0.2, 0.3, 0.5, 0.5, 0.5, 0.8, 0.7, 0.6).
If the attribute name is invalid or the attribute is not an int or float (e.g. it’s a string attribute), this method raises hou.OperationFailed.
primGroups(self)→ tuple of PrimGroupsprims(self)→ tuple of hou.Prim-
Return a tuple of all the primitives in the geometry.
saveToFile(self, file_name)seamPoints(self, seam_half)→ tuple of PointssetGlobalAttribValue(self, attrib_name, attrib_value) OR setGlobalAttribValue(self, attrib, attrib_value)sopNode(self)→ SopNodestringAttribValue(self, name) -> string OR stringAttribValue(self, attrib)→ stringtransform(self, matrix)vertexAttribs(self)→ tuple of Attribs