ColorSwatchGroup

New in version R18.011.

Members

ColorSwatchGroup.__init__(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 (maxon.BaseArray[maxon.ColorA]) – The colors to fill the group with.
Return type:

c4d.modules.colorchooser.ColorSwatchGroup

Returns:

A new swatch group.

ColorSwatchGroup.Merge(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(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()

Retrieves the group name.

Return type:str
Returns:The group name.
ColorSwatchGroup.SetName(name)

Sets the group name.

Parameters:name (str) – The new group name.
ColorSwatchGroup.GetColorCount()

Retrieves the number of colors stored in the group.

Return type:int
Returns:The number of colors stored in the group.
ColorSwatchGroup.GetColor(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(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(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(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 (c4d.Vector) – The initial selection state of the color.
  • insertAt (c4d.Vector) – 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(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()

Removes all colors from the group.

ColorSwatchGroup.RemoveColor(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()

Removes all selected colors from the group.

ColorSwatchGroup.HasDuplicatedColors()

Checks if the group has duplicated colors.

Return type:bool
Returns:True if duplicated colors were found, otherwise False.
ColorSwatchGroup.RemoveDuplicatedColors()

Removes duplicated colors in the group.

ColorSwatchGroup.InvertSelection()

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

ColorSwatchGroup.SelectColor(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(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(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()

Checks if the group is selected.

Return type:bool
Returns:True if the group is selected, otherwise False.
ColorSwatchGroup.SortColors()

Sorts colors in the group based on their HSV values.