c4d.VertexColorTag

class c4d.VertexColorTag
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.

The instance object class of type Tvertexcolor.

New in version R18.020.

It consist to a list of dict{a, b, c, d: c4d.Vector4d}, the vertex colors for a polygon.

Methods Signatures

VertexColorTag.__init__(self, count)

Creates a c4d.VertexColorTag.

VertexColorTag.GetDataAddressR(self)

Gets the read-only data handle.

VertexColorTag.GetDataAddressW(self)

Gets the writable data handle.

VertexColorTag.IsPerPointColor(self)

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

VertexColorTag.SetPerPointMode(self, perPointColor)

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

Static Methods Signatures

c4d.VertexColorTag.GetPolygon(data, i)

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

c4d.VertexColorTag.SetPolygon(data, i, polygon)

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

c4d.VertexColorTag.GetPoint(data, nb, vadr, pIndex)

Retrieves the vertex color for the vertex pIndex.

c4d.VertexColorTag.SetPoint(data, nb, vadr, pIndex, ...)

Sets the vertex color for the vertex pIndex.

c4d.VertexColorTag.GetColor(data, nb, vadr, pIndex)

Retrieves the vertex color for the vertex pIndex.

c4d.VertexColorTag.SetColor(data, nb, vadr, pIndex, ...)

Sets the vertex color for the vertex pIndex.

c4d.VertexColorTag.GetAlpha(data, nb, vadr, pIndex)

Retrieves the vertex color alpha value for the vertex pIndex.

c4d.VertexColorTag.SetAlpha(data, nb, vadr, pIndex, ...)

Sets the vertex color alpha value for the vertex pIndex.

Inheritance

Parent Class:

Methods Documentation

VertexColorTag.__init__(self, 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.

VertexColorTag.GetDataAddressR(self)
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(self)
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(self)

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(self, perPointColor)

Sets whatever 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 Methods Documentation

static c4d.VertexColorTag.GetPolygon(data, i)

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

Example.

<c4d.PolygonObject object called Plane/Polygon with ID 5100 at 1694970385536>
>>> tag = op.GetTag(c4d.Tvertexcolor)
>>> tag
<c4d.VertexColorTag object called Vertex Color/Vertex Color with ID 431000045 at 1694956509632>
>>> data = tag.GetDataAddressR()
>>> data
<capsule object NULL at 0x0000018AA3491B00>
>>> for idx in range(op.GetPolygonCount()):
...     poly = c4d.VertexColorTag.GetPolygon(data, idx)
...     print(poly)
...
{'a': Vector4d(0, 0, 0, 0), 'b': Vector4d(0.845, 0, 0, 0), 'c': Vector4d(0, 0, 0.965, 0), 'd': Vector4d(0, 1, 0, 0)}
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 c4d.VertexColorTag.SetPolygon(data, i, polygon)

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

Example.

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 range(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 c4d.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.

>>> op
<c4d.PolygonObject object called Plane/Polygon with ID 5100 at 1694970348800>
>>> tag = op.GetTag(c4d.Tvertexcolor)
>>> tag
<c4d.VertexColorTag object called Vertex Color/Vertex Color with ID 431000045 at 1694956683136>
>>> data = tag.GetDataAddressR()
>>> data
<capsule object NULL at 0x0000018AA3491140>
>>> for idx in range(op.GetPointCount()):
...     point = c4d.VertexColorTag.GetPoint(data, None, None, idx)
...     print(point)
...
Vector4d(0, 0, 0, 0)
Vector4d(0.845, 0, 0, 0)
Vector4d(0, 0, 0.965, 0)
Vector4d(0, 1, 0, 0)
Parameters
  • data (PyCObject) – The data handle.

  • nb (Optional[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 (Optional[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 c4d.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 range(pointCount):
    c4d.VertexColorTag.SetPoint(data, None, None, idx, white)

c4d.EventAdd()
Parameters
  • data (PyCObject) – The data handle.

  • nb (Optional[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 (Optional[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 c4d.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.

>>> op
<c4d.PolygonObject object called Plane/Polygon with ID 5100 at 1694970435456>
>>> tag = op.GetTag(c4d.Tvertexcolor)
>>> tag
<c4d.VertexColorTag object called Vertex Color/Vertex Color with ID 431000045 at 1694956554240>
>>> data = tag.GetDataAddressR()
>>> data
<capsule object NULL at 0x0000018AA34B01C0>
>>> for idx in range(op.GetPointCount()):
...  color = c4d.VertexColorTag.GetColor(data, None, None, idx)
...  print(color)
...
Vector(0, 0, 0)
Vector(0.845, 0, 0)
Vector(0, 0, 0.965)
Vector(0, 1, 0)
Parameters
  • data (PyCObject) – The data handle.

  • nb (Optional[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 (Optional[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 c4d.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 range(pointCount):
    c4d.VertexColorTag.SetColor(data, None, None, idx, white)

c4d.EventAdd()
Parameters
  • data (PyCObject) – The data handle.

  • nb (Optional[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 (Optional[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 c4d.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.

>>> op
<c4d.PolygonObject object called Plane/Polygon with ID 5100 at 1694970435456>
>>> tag = op.GetTag(c4d.Tvertexcolor)
>>> tag
<c4d.VertexColorTag object called Vertex Color/Vertex Color with ID 431000045 at 1694956554240>
>>> data = tag.GetDataAddressR()
>>> data
<capsule object NULL at 0x0000018AA34B01C0>
>>> for idx in range(op.GetPointCount()):
...     alpha = c4d.VertexColorTag.GetAlpha(data, None, None, idx)
...     print(alpha)
...
0.0
0.0
0.0
0.0
Parameters
  • data (PyCObject) – The data handle.

  • nb (Optional[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 (Optional[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 c4d.VertexColorTag.SetAlpha(data, nb, vadr, pIndex, value)

Sets the vertex color alpha value for the vertex pIndex.

import c4d

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

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

c4d.EventAdd()
Parameters
  • data (PyCObject) – The data handle.

  • nb (Optional[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 (Optional[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.