c4d.modules.colorchooser.ColorSwatchGroup

class c4d.modules.colorchooser.ColorSwatchGroup

New in version R18.011.

Methods Signatures

ColorSwatchGroup.__init__(self[, name, selected, ...])

Creates a new swatch group.

ColorSwatchGroup.Merge(self, group)

Merges colors from group.

ColorSwatchGroup.CopyFrom(self, group)

Copies a group.

ColorSwatchGroup.GetName(self)

Retrieves the group name.

ColorSwatchGroup.SetName(self, name)

Sets the group name.

ColorSwatchGroup.GetColorCount(self)

Retrieves the number of colors stored in the group.

ColorSwatchGroup.GetColor(self, index)

Retrieves the color at the given index.

ColorSwatchGroup.GetColors(self[, selectedOnly])

Retrieves the colors stored in the group.

ColorSwatchGroup.SetColor(self, index, color, ...)

Edits the color at the given index.

ColorSwatchGroup.AddColor(self, color[, ...])

Adds a new color to the group.

ColorSwatchGroup.AddColors(self, colors[, ...])

Adds colors to the group.

ColorSwatchGroup.Reset(self)

Removes all colors from the group.

ColorSwatchGroup.RemoveColor(self, index[, removeCount])

Removes the color at the given index.

ColorSwatchGroup.RemoveSelectedColors(self)

Removes all selected colors from the group.

ColorSwatchGroup.HasDuplicatedColors(self)

Checks if the group has duplicated colors.

ColorSwatchGroup.RemoveDuplicatedColors(self)

Removes duplicated colors in the group.

ColorSwatchGroup.InvertSelection(self)

Inverts the selection state of all colors, so the currently selected colors will be unselected and vice-versa.

ColorSwatchGroup.SelectColor(self, index, selected)

Selects/unselects the color at the given index.

ColorSwatchGroup.IsColorSelected(self, index)

Checks if the color at the given index is selected.

ColorSwatchGroup.SelectGroup(self, select)

Selects the group. This will select/unselect the group icon and all colors in the group.

ColorSwatchGroup.IsGroupSelected(self)

Checks if the group is selected.

ColorSwatchGroup.SortColors(self)

Sorts colors in the group based on their HSV values.

Methods Documentation

ColorSwatchGroup.__init__(self, name='', selected=False, colors=None)

Creates a new swatch group.

Changed in version R20: colors changed to a maxon.BaseArray of maxon.ColorA.

Parameters
  • name (str) – The name of the group.

  • selected (bool) – The selection state of the group.

  • colors (Optional[maxon.BaseArray [maxon.ColorA]]) – The colors to fill the group with.

ColorSwatchGroup.Merge(self, group)

Merges colors from group.

Parameters

group (c4d.modules.colorchooser.ColorSwatchGroup) – The group to merge colors from.

Return type

bool

Returns

True if successful, otherwise False.

ColorSwatchGroup.CopyFrom(self, group)

Copies a group.

Parameters

group (c4d.modules.colorchooser.ColorSwatchGroup) – The group to copy colors from.

Return type

bool

Returns

True if successful, otherwise False.

ColorSwatchGroup.GetName(self)

Retrieves the group name.

Return type

str

Returns

The group name.

ColorSwatchGroup.SetName(self, name)

Sets the group name.

Parameters

name (str) – The new group name.

ColorSwatchGroup.GetColorCount(self)

Retrieves the number of colors stored in the group.

Return type

int

Returns

The number of colors stored in the group.

ColorSwatchGroup.GetColor(self, index)

Retrieves the color at the given index.

Changed in version R20: The function returns a maxon.ColorA in the tuple.

Parameters

index (int) – The index of the color. Must be 0 <= index < GetColorCount().

Return type

Tuple[maxon.ColorA, bool]

Returns

The color value and its selection status.

ColorSwatchGroup.GetColors(self, selectedOnly=False)

Retrieves the colors stored in the group.

Changed in version R20: The function returns a maxon.BaseArray of maxon.ColorA.

Parameters

selectedOnly (bool) – Set to True to get only the selected colors, set to False to get all colors (default).

Return type

maxon.BaseArray[maxon.ColorA]

Returns

The list of colors.

ColorSwatchGroup.SetColor(self, index, color, selected)

Edits the color at the given index.

Changed in version R20: color changed to maxon.ColorA type.

Parameters
  • index (int) – The index of the color. Must be 0 <= index < GetColorCount().

  • color (maxon.ColorA) – The new color value.

  • selected (int) – The new selection status. Possible values are: -1 = keep current selection status unchanged, 0 = unselect, 1 = select.

Return type

bool

Returns

True if the color could be changed, otherwise False.

ColorSwatchGroup.AddColor(self, color, selected=False, insertAt=- 1)

Adds a new color to the group.

Changed in version R20: color changed to maxon.ColorA type.

Parameters
  • color (maxon.ColorA) – The color value.

  • selected (bool) – The initial selection state of the color.

  • insertAt (int) – The index of the new color (the list size will increase and the existing elements are moved) or -1 to add it to the end of the list.

Return type

int

Returns

The index of the new color or -1 if an error occurred.

ColorSwatchGroup.AddColors(self, colors, selected=False, merge=True, insertAt=- 1)

Adds colors to the group.

Changed in version R20: colors changed to a maxon.BaseArray of maxon.ColorA.

Parameters
  • colors (maxon.BaseArray[maxon.ColorA]) – The colors to add.

  • selected (bool) – The initial selection state of added colors.

  • merge (bool) – Set to True to merge the colors with current group colors. Set to False to replace the content of the group.

  • insertAt (int) – If merge is set to True, this is the index to insert the new colors.

Return type

int

Returns

The index of the new colors or -1 if an error occurred.

ColorSwatchGroup.Reset(self)

Removes all colors from the group.

ColorSwatchGroup.RemoveColor(self, index, removeCount=1)

Removes the color at the given index.

Parameters
  • index (int) – The index of the color. Must be 0 <= index < GetColorCount().

  • removeCount (int) – Number of colors to be removed. If removeCnt is higher than what is available only the number of remaining colors will be removed.

Return type

bool

Returns

True if successful, otherwise False.

ColorSwatchGroup.RemoveSelectedColors(self)

Removes all selected colors from the group.

ColorSwatchGroup.HasDuplicatedColors(self)

Checks if the group has duplicated colors.

Return type

bool

Returns

True if duplicated colors were found, otherwise False.

ColorSwatchGroup.RemoveDuplicatedColors(self)

Removes duplicated colors in the group.

ColorSwatchGroup.InvertSelection(self)

Inverts the selection state of all colors, so the currently selected colors will be unselected and vice-versa.

ColorSwatchGroup.SelectColor(self, index, selected)

Selects/unselects the color at the given index.

Parameters
  • index (int) – The index of the color. Must be 0 <= index < GetColorCount().

  • selected (bool) – The new selection status.

Return type

bool

Returns

True if successful, otherwise False.

ColorSwatchGroup.IsColorSelected(self, index)

Checks if the color at the given index is selected.

Parameters

index (int) – The index of the color. Must be 0 <= index < GetColorCount().

Return type

bool

Returns

True if the color is selected, False if it is unselected or index is invalid.

ColorSwatchGroup.SelectGroup(self, select)

Selects the group. This will select/unselect the group icon and all colors in the group.

Parameters

select (bool) – The new selection status.

ColorSwatchGroup.IsGroupSelected(self)

Checks if the group is selected.

Return type

bool

Returns

True if the group is selected, otherwise False.

ColorSwatchGroup.SortColors(self)

Sorts colors in the group based on their HSV values.