Prim Class

From TouchDesigner 099 Wiki

A Prim describes an instance to a single geometry primitive. They are accessible through the SOP.prims member.

Members

center Get or set the barycentric coordinate of this primitive. It is expressed as a named 4-tuple (x,y,z,w).
index (Read Only) The primitive index in the list.
normal (Read Only) The calculated normal vector of this primitive, expressed as a named 4-tuple (x,y,z,w).
owner (Read Only) The OP to which this object belongs.
weight (Read Only) The associated weight of the primitive. Only certain primitives, such as those created by the Metaball SOP can modify this value from its default of 2.0.
min (Read Only) The minimum coordinates of this primitive along each dimension, expressed as a named 4-tuple (x,y,z,w)
max (Read Only) The maximum coordinates of this primitive along each dimension, expressed as a named 4-tuple (x,y,z,w).
size (Read Only) The size of this primitive along each dimension, expressed as a named 4-tuple (x,y,z,w).

Attributes

In addition to the above members, all attributes are members as well.
For example, if the Prim contains texture coordinates, they may be accessed with: Prim.uv
See: Attribute Class for more information.


Methods

destroy(destroyPoints=True)

Destroy and remove the actual primitive this object refers to. This operation is only valid when the primitive belongs to a scriptSOP.
Note: after this call, other existing Prim objects in this SOP may no longer be valid.
  • destroyPoints - (Keyword, Optional) If True, its points are destroyed as well, if false, they are simply detached. The argument is True by default.

eval(u, v)Position

Evaluate the position on the primitive given the u,v coordinates. u,v should be in the range [0,1]. Polygons and curves ignore the v parameter.
   center = op('box1').prim[0].eval(0.5, 0.5)

Special Functions

len(Prim)int

Returns the total number of vertices.
   a = len(op('box1').prim[0])

[index]Vertex

Get specific vertex given an integer index.
   n = op('box1').prims[5][0]

[row, col]Vertex

Get specific vertex from a Mesh given integer row and column values.
   v = op('grid1').prims[2,3]


Iterator

Iterate over each vertex.
   for m in op('box1').prims[5]