c4d.VertexColorTag

New in version R18.020.

c4d.VertexColorTag is a Variable Tag that stores RGBA colors for the polygons of the host polygon object. The data can be stored in 2 ways: per polygon (per polygon vertex mode, default) and per vertex (per point mode).

The tag provides methods to set/get color per polygons or per vertex (average) in per polygon vertex mode. It also defines some convenience functions to set/get just color or just alpha value in both modes.

Inheritance

Members

VertexColorTag.__init__(count)

Creates a c4d.VertexColorTag.

Parameters:count (int) – The number of elements in the tag. Must be equal to the object’s polygon count if the tag is in per polygon vertex mode, otherwise must be equal to the object’s point count in per vertex mode.
Return type:c4d.VertexColorTag
Returns:A new Vertex Color tag.
VertexColorTag.GetDataAddressR()

Gets the read-only data handle. It automatically recognizes if the tag is in per polygon vertex or per vertex mode.

Return type:PyCObject
Returns:The handle to the read-only vertex color data.
VertexColorTag.GetDataAddressW()

Gets the writable data handle. It automatically recognizes if the tag is in per polygon vertex or per vertex mode.

Return type:PyCObject
Returns:The handle to the writable vertex color data.
VertexColorTag.IsPerPointColor()

Checks if the data is stored per point (vertex) or per polygon vertex.

Return type:bool
Returns:True if vertex colors are stored per vertex, otherwise False.
VertexColorTag.SetPerPointMode(perPointColor)

Sets wether the data is stored per point (vertex) or per polygon vertex.

Note

The item count is automatically updated and the data converted if possible.

Warning

All handles are invalidated after the call.

Parameters:perPointColor (bool) – If True the data will be stored per vertex otherwise per polygon vertex.
Return type:bool
Returns:True if successful, otherwise False.
static VertexColorTag.GetPolygon(data, i)

Retrieves the vertex colors for the polygon i in per polygon vertex mode.

Example:

import c4d

tag = op.GetTag(c4d.Tvertexcolor)
data = tag.GetDataAddressR()

polyCount = op.GetPolygonCount()
for idx in xrange(polyCount):
  poly = c4d.VertexColorTag.GetPolygon(data, idx)
  print poly
Parameters:
  • data (PyCObject) – The data handle.
  • i (int) – The polygon index.
Return type:

dict(“a”: c4d.Vector4d, “b”: c4d.Vector4d, “c”: c4d.Vector4d, “d”: c4d.Vector4d)

Returns:

The retrieved vertex color data.

static VertexColorTag.SetPolygon(data, i, polygon)

Sets the vertex colors for the polygon i in per polygon vertex mode.

Example:

import c4d

tag = op.GetTag(c4d.Tvertexcolor)
data = tag.GetDataAddressW()

white = c4d.Vector4d(1.0, 1.0, 1.0, 1.0)
poly = {"a": white, "b": white, "c": white, "d": white}

polyCount = op.GetPolygonCount()
for idx in xrange(polyCount):
  c4d.VertexColorTag.SetPolygon(data, idx, poly)

c4d.EventAdd()
Parameters:
  • data (PyCObject) – The data handle.
  • i (int) – The polygon index.
  • polygon (Dict) – The vertex color data a, b, c and d to be set to the polygon
static VertexColorTag.GetPoint(data, nb, vadr, pIndex)

Retrieves the vertex color for the vertex pIndex.

Note

If the tag is in per polygon vertex mode it traverses all polygons attached to it. If different values are found then the average value will be returned.

Example:

import c4d

tag = op.GetTag(c4d.Tvertexcolor)
data = tag.GetDataAddressR()

pointCount = op.GetPointCount()
for idx in xrange(pointCount):
  point = c4d.VertexColorTag.GetPoint(data, None, None, idx)
  print point
Parameters:
  • data (PyCObject) – The data handle.
  • nb (c4d.utils.Neighbor) – A neighbor helper class. Can be initialized with a polygon selection to limit the function to a specific object part. Pass None if in per vertex mode.
  • vadr (PyCObject) – The object c4d.CPolygon array. Pass None if in per vertex mode. See PolygonObject.GetPolygonR().
  • pIndex (int) – The point index.
Return type:

c4d.Vector4d

Returns:

The RGBA color for the passed vertex, or the average color if multiple values were found.

static VertexColorTag.SetPoint(data, nb, vadr, pIndex, color)

Sets the vertex color for the vertex pIndex.

Example:

import c4d

tag = op.GetTag(c4d.Tvertexcolor)
data = tag.GetDataAddressW()

white = c4d.Vector4d(1.0, 1.0, 1.0, 1.0)
pointCount = op.GetPointCount()
for idx in xrange(pointCount):
  c4d.VertexColorTag.SetPoint(data, None, None, idx, white)

c4d.EventAdd()
Parameters:
  • data (PyCObject) – The data handle.
  • nb (c4d.utils.Neighbor) – A neighbor helper class. Can be initialized with a polygon selection to limit the function to a specific object part. Pass None if in per vertex mode.
  • vadr (PyCObject) – The object c4d.CPolygon array. Pass None if in per vertex mode. See PolygonObject.GetPolygonW().
  • pIndex (int) – The point index.
  • color (c4d.Vector4d) – The new RGBA color to be assigned to the vertex.
static VertexColorTag.GetColor(data, nb, vadr, pIndex)

Retrieves the vertex color for the vertex pIndex.

Note

If the tag is in per polygon vertex mode it traverses all polygons attached to it. If different values are found then the average value will be returned.

Example:

import c4d

tag = op.GetTag(c4d.Tvertexcolor)
data = tag.GetDataAddressR()

pointCount = op.GetPointCount()
for idx in xrange(pointCount):
  color = c4d.VertexColorTag.GetColor(data, None, None, idx)
  print color
Parameters:
  • data (PyCObject) – The data handle.
  • nb (c4d.utils.Neighbor) – A neighbor helper class. Can be initialized with a polygon selection to limit the function to a specific object part. Pass None if in per vertex mode.
  • vadr (PyCObject) – The object c4d.CPolygon array. Pass None if in per vertex mode. See PolygonObject.GetPolygonR().
  • pIndex (int) – The point index.
Return type:

c4d.Vector

Returns:

The RGB color for the passed point index, or the average color if multiple values were found.

static VertexColorTag.SetColor(data, nb, vadr, pIndex, color)

Sets the vertex color for the vertex pIndex.

Example:

import c4d

tag = op.GetTag(c4d.Tvertexcolor)
data = tag.GetDataAddressW()

white = c4d.Vector(1.0, 1.0, 1.0)
pointCount = op.GetPointCount()
for idx in xrange(pointCount):
  c4d.VertexColorTag.SetColor(data, None, None, idx, white)

c4d.EventAdd()
Parameters:
  • data (PyCObject) – The data handle.
  • nb (c4d.utils.Neighbor) – A neighbor helper class. Can be initialized with a polygon selection to limit the function to a specific object part. Pass None if in per vertex mode.
  • vadr (PyCObject) – The object c4d.CPolygon array. Pass None if in per vertex mode. See PolygonObject.GetPolygonW().
  • pIndex (int) – The point index.
  • color (c4d.Vector) – The new RGB color to be assigned to the vertex.
static VertexColorTag.GetAlpha(data, nb, vadr, pIndex)

Retrieves the vertex color alpha value for the vertex pIndex.

Note

If the tag is in per polygon vertex mode it traverses all polygons attached to it. If different values are found then the average value will be returned.

Example:

import c4d

tag = op.GetTag(c4d.Tvertexcolor)
data = tag.GetDataAddressR()

pointCount = op.GetPointCount()
for idx in xrange(pointCount):
  alpha = c4d.VertexColorTag.GetAlpha(data, None, None, idx)
  print alpha
Parameters:
  • data (PyCObject) – The data handle.
  • nb (c4d.utils.Neighbor) – A neighbor helper class. Can be initialized with a polygon selection to limit the function to a specific object part. Pass None if in per vertex mode.
  • vadr (PyCObject) – The object c4d.CPolygon array. Pass None if in per vertex mode. See PolygonObject.GetPolygonR().
  • pIndex (int) – The point index.
Return type:

float

Returns:

The alpha value for the passed vertex, or the average alpha value if multiple values were found.

static VertexColorTag.SetAlpha(data, nb, vadr, pIndex, value)

Sets the vertex color alpha value for the vertex pIndex.

Example:

import c4d

tag = op.GetTag(c4d.Tvertexcolor)
data = tag.GetDataAddressW()

pointCount = op.GetPointCount()
for idx in xrange(pointCount):
  c4d.VertexColorTag.SetAlpha(data, None, None, idx, 0.5)

c4d.EventAdd()
Parameters:
  • data (PyCObject) – The data handle.
  • nb (c4d.utils.Neighbor) – A neighbor helper class. Can be initialized with a polygon selection to limit the function to a specific object part. Pass None if in per vertex mode.
  • vadr (PyCObject) – The object c4d.CPolygon array. Pass None if in per vertex mode. See PolygonObject.GetPolygonW().
  • pIndex (int) – The point index.
  • value (float) – The new alpha value to be assigned to the vertex.