ColorSwatchData

New in version R18.011.

This type handles the Swatch Data stored globally, in a BaseDocument or a preset. It holds 2 kinds of groups:

  • A global color group that is shared between all Cinema 4D documents and has special methods to handle it.
  • Multiple document-based color groups: these groups are stored in a Cinema 4D document.

Definition

class c4d.modules.colorchooser. ColorSwatchData

Members

ColorSwatchData. __init__ ( [ doc=None , global=False ] )

Creates a new swatch data.

Parameters:
  • doc ( c4d.documents.BaseDocument ) – Optional document to load swatches from.
  • global ( bool ) – If True the Global Swatch Group will be loaded.
Return type:

c4d.modules.colorchooser.ColorSwatchData

Returns:

A new swatch data.

ColorSwatchData. LoadGlobalGroup ( )
Loads the colors global to all Cinema 4D documents. These are used in the current working Cinema 4D session and preserved between Cinema 4D sessions if the option WPREF_COLOR_MODE_SWATCHES_REMEMBER_GLOBAL is True . The GUI option is in Cinema 4D Preferences dialog / Units / Color Chooser / Default Set / Swatches Mode / Remember Global Swatches Last Layout. If the option is False , when Cinema 4D is restarted, the default colors will be loaded.

See also

SaveGlobalGroup() , LoadDefaultGlobalGroup() , SaveDefaultGlobalGroup() , GetGlobalGroup()

Return type: bool
Returns: True if successful, otherwise False .
ColorSwatchData. SaveGlobalGroup ( )
Saves the colors global to all Cinema 4D documents. These are used in the current working Cinema 4D session and preserved between Cinema 4D sessions if the option WPREF_COLOR_MODE_SWATCHES_REMEMBER_GLOBAL is True . The GUI option is in Cinema 4D Preferences dialog / Units / Color Chooser / Default Set / Swatches Mode / Remember Global Swatches Last Layout. If the option is False , when Cinema 4D is restarted, the default colors will be loaded.

See also

LoadGlobalGroup() , LoadDefaultGlobalGroup() , SaveDefaultGlobalGroup() , GetGlobalGroup()

Return type: bool
Returns: True if successful, otherwise False .
ColorSwatchData. LoadDefaultGlobalGroup ( [ ignoreFile=False ] )
Loads the default global colors. Default global colors are loaded when Cinema 4D starts and if the preference option WPREF_COLOR_MODE_SWATCHES_REMEMBER_GLOBAL is False . The GUI option is in Cinema 4D Preferences dialog / Units / Color Chooser / Default Set / Swatches Mode / Remember Global Swatches Last Layout. Default global colors are stored in the file “defaultswatches” in the Preferences folder. If that file is missing or if ignoreFile is True , a hardcoded default color set will be loaded instead.

See also

SaveDefaultGlobalGroup() , LoadGlobalGroup() , SaveGlobalGroup() , GetGlobalGroup()

Parameters: ignoreFile ( bool ) – If True , the file “defaultswatches” will be ignored and the hardcoded colors will be loaded instead.
Return type: bool
Returns: True if successful, otherwise False .
ColorSwatchData. SaveDefaultGlobalGroup ( )
Saves the default global colors. Default global colors are loaded when Cinema 4D starts and if the preference option WPREF_COLOR_MODE_SWATCHES_REMEMBER_GLOBAL is False . The GUI option is in Cinema 4D Preferences dialog / Units / Color Chooser / Default Set / Swatches Mode / Remember Global Swatches Last Layout. Default global colors are stored in the file “defaultswatches” in the Preferences folder. If that file is missing, a hardcoded default color set will be loaded instead.

See also

LoadDefaultGlobalGroup() , LoadGlobalGroup() , SaveGlobalGroup() , GetGlobalGroup()

Return type: bool
Returns: True if successful, otherwise False .
ColorSwatchData. GetGlobalGroup ( )

Retrieves the global colors group.

See also

LoadGlobalGroup() , SaveGlobalGroup() , LoadDefaultGlobalGroup() , SaveDefaultGlobalGroup()

Return type: c4d.modules.colorchooser.ColorSwatchGroup
Returns: The global group. Guaranteed to be valid.
ColorSwatchData. SetGlobalGroup ( group )

Replaces the global group.

Parameters: group ( c4d.modules.colorchooser.ColorSwatchGroup ) – The group to copy from.
Return type: bool
Returns: True if successful, otherwise False .
ColorSwatchData. Load ( doc [ , merge=False ] )

Loads the document-based color groups from the given document.

Parameters:
Return type:

bool

Returns:

True if successful, otherwise False .

ColorSwatchData. Save ( doc )

Saves the document-based color groups into the given document.

Parameters: doc ( c4d.documents.BaseDocument ) – The document to store the color groups into.
Return type: bool
Returns: True if successful, otherwise False .
ColorSwatchData. LoadPresetByName ( name [ , merge=False ] )

Loads the document-based swatch groups of the first preset with the given name found in the user’s Color Swatch Preset directory, including subdirectories.

See also

GetColorSwatchPresetDirectory()

Parameters:
  • name ( str ) – The preset name to load.
  • merge ( c4d.documents.BaseDocument ) – If True the colors of the preset are merged with the stored colors. Otherwise the existing colors are discarded (default).
Return type:

bool

Returns:

True if successful, otherwise False .

ColorSwatchData. LoadPresetByURL ( url , merge )

Loads the document-based swatch groups of the given preset.

Parameters:
  • url ( str ) – The preset url.
  • merge ( c4d.documents.BaseDocument ) – If True the colors of the preset are merged with the stored colors. Otherwise the existing colors are discarded (default).
Return type:

bool

Returns:

True if successful, otherwise False .

ColorSwatchData. SavePresetByName ( name [ , author=”“ , info=”“ , forceOverwrite=False ] )

Saves the document-based groups as a Color Swatch preset.

Parameters:
  • name ( str ) – The preset name.
  • author ( str ) – The preset author.
  • info ( str ) – Preset additional info.
  • forceOverwrite ( bool ) – Set to True to force overwriting the preset in case it already exists.
Return type:

bool

Returns:

True if the preset was saved successfully, otherwise False .

ColorSwatchData. SavePresetByURL ( url [ , author=”“ , info=”“ , forceOverwrite=False ] )

Saves the document-based groups as a Color Swatch preset.

Parameters:
  • url ( str ) – The url to save the preset to. Must include the preset name and must point to an existing library. Example: presetToSaveURL = c4d.modules.colorchooser.GetColorSwatchPresetDirectory() + “MyPreset”
  • author ( str ) – The preset author.
  • info ( str ) – The preset additional info.
  • forceOverwrite ( bool ) – Set to True to force overwriting the preset in case it already exists.
Return type:

bool

Returns:

True if the preset was saved successfully, otherwise False .

ColorSwatchData. Merge ( data )

Merges groups from data .

Parameters: data ( c4d.modules.colorchooser.ColorSwatchData ) – The data to merge groups from.
Return type: bool
Returns: True if the groups were successfully merged, otherwise False .
ColorSwatchData. CopyFrom ( )

Copies color swatch data.

Parameters: data ( c4d.modules.colorchooser.ColorSwatchData ) – The data to copy groups from.
Return type: bool
Returns: True if the color swatch data was successfully copied, otherwise False .
ColorSwatchData. GetGroupCount ( )

Retrieves the number of document-based groups stored. Global group is ignored.

Return type: int
Returns: The number of color groups.
ColorSwatchData. GetGroupAtIndex ( index )

Retrieves the document-based group at the given index .

Parameters: index ( int ) – The index of the color group. Must be 0 <= index < GetGroupCount() .
Return type: c4d.modules.colorchooser.ColorSwatchGroup
Returns: The swatch group or None .
ColorSwatchData. SetGroupAtIndex ( index , group )

Replaces the group at the given index .

Parameters:
Return type:

bool

Returns:

True if the group was successfully set, otherwise False .

ColorSwatchData. AddGroup ( [ name=”“ , selected=False , insertAt=-1 , colors=None ] )

Adds a new document-based group.

Parameters:
  • name ( str ) – The name of the new group. If empty the default string “Untitled” will be used.
  • selected ( bool ) – The initial selection state of the new group.
  • insertAt ( int ) – The index of the new group (the list size will increase and the existing elements will be moved) or -1 to add it to the end of the list (default).
  • colors (list of c4d.Vector ) – The colors to fill the group with.
Return type:

c4d.modules.colorchooser.ColorSwatchGroup

Returns:

The new swatch group or None .

ColorSwatchData. InsertGroup ( group [ , insertAt=-1 ] )

Inserts an existing document-based group.

Parameters:
  • group ( c4d.modules.colorchooser.ColorSwatchGroup ) – The group to insert.
  • insertAt ( int ) – The index of the new group (the list size will increase and the existing elements will be moved) or -1 to add it to the end of the list (default).
Return type:

bool

Returns:

True if the group was successfully inserted, otherwise False .

ColorSwatchData. RemoveGroup ( index )

Removes the document-based group at the given index .

Parameters: index ( int ) – The index of the color group to remove. Must be 0 <= index < GetGroupCount() .
Return type: bool
Returns: True if the group was successfully removed, otherwise False .
ColorSwatchData. RemoveSelectedItems ( )

Removes all selected groups and colors, including selected global colors.

ColorSwatchData. Reset ( )

Removes all groups and colors, including globals.

Table Of Contents