About
A ColorSwatchData object can manage multiple color groups. These color groups can be loaded globally from Cinema 4D, a BaseDocument or a preset and saved back to these sources. Local color groups and global color groups are stored separately. The class is defined in the lib_colorchooser.h
header file.
if (colorSwatchData == nullptr)
freeData.
Assign(colorSwatchData);
for (
Int i = 0;
i < groupCount; ++
i)
{
if (group)
{
for (
Int c = 0;
c < colorCount; ++
c)
{
if (group->
GetColor(
c, color, &selected) && selected)
{
if (mat == nullptr)
const Vector rgb { color.
r, color.
g, color.
b };
doc->InsertMaterial(mat);
}
}
}
}
Py_ssize_t i
Definition: abstract.h:645
Definition: ge_autoptr.h:155
void Assign(TYPE *p)
Definition: ge_autoptr.h:234
Bool SetParameter(const DescID &id, const GeData &t_data, DESCFLAGS_SET flags)
Definition: lib_colorchooser.h:406
Int GetGroupCount(SWATCH_CATEGORY category=SWATCH_CATEGORY::DOCUMENT) const
ColorSwatchGroup * GetGroupAtIndex(Int index, SWATCH_CATEGORY category=SWATCH_CATEGORY::DOCUMENT)
static ColorSwatchData * Alloc(BaseDocument *doc=nullptr, Bool global=false)
Definition: lib_colorchooser.h:218
Bool GetColor(Int index, maxon::ColorA &color, Bool *selected=nullptr) const
Int GetColorCount() const
Definition: c4d_basematerial.h:241
static Material * Alloc()
Py_UNICODE c
Definition: unicodeobject.h:1200
maxon::Bool Bool
Definition: ge_sys_math.h:51
maxon::Int Int
Definition: ge_sys_math.h:60
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
#define ConstDescID(...)
Definition: lib_description.h:594
@ MATERIAL_COLOR_COLOR
Definition: mmaterial.h:56
const char * doc
Definition: pyerrors.h:226
Represents a level within a DescID.
Definition: lib_description.h:298
A color consisting of three components R, G, B and an alpha.
Definition: col4.h:16
Allocation/Deallocation
ColorSwatchData instances are created with the usual tools:
if (data == nullptr)
static void Free(ColorSwatchData *&p)
static String IntToString(Int32 v)
Definition: c4d_string.h:497
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:204
Document Colors
Color groups can be stored in a BaseDocument:
if (loadedDoc == nullptr)
colorSwatchData->
Load(loadedDoc,
true);
BaseDocument * LoadDocument(const Filename &name, SCENEFILTER loadflags, BaseThread *thread, maxon::String *errorString=nullptr, const ProgressDelegate &progressDelegate=ProgressDelegate())
maxon::Url MaxonConvert(const Filename &fn, MAXONCONVERTMODE convertMode)
@ NONE
No check if file exists under case-sensitive drives.
Definition: c4d_basedocument.h:497
static void Free(BaseDocument *&bl)
Bool Save(BaseDocument *doc, Bool saveGlobalColors=false)
Bool Load(BaseDocument *doc, Bool merge=false, Bool loadGlobalColors=false)
Manages file and path names.
Definition: c4d_file.h:94
Bool FileSelect(FILESELECTTYPE type, FILESELECT flags, const maxon::String &title, const maxon::String &force_suffix=maxon::String())
return OK
Definition: apibase.h:2735
Presets
Color swatches can also be stored in the preset library:
To make work with presets easier these utility functions exist:
- ColorSwatchData::PresetExists(): Returns true if the given preset name already exists.
- ColorSwatchData::ValidPreset(): Returns true if the given URL points to a valid preset.
- ColorSwatchData::GetPresetDirectory(): Returns the user's default Color Swatch Preset directory.
- ColorSwatchData::browserPresetType: The ID of color swatch preset objects.
Color Groups
The color swatches stored in a ColorSwatchData are stored in groups. These groups can either be stored with the document (SWATCH_CATEGORY::DOCUMENT) or with Cinema 4D itself (SWATCH_CATEGORY::GLOBAL).
for (
Int i = 0;
i < groupCount; ++
i)
{
if (group != nullptr)
{
}
}
ColorSwatchGroup * AddGroup(SWATCH_CATEGORY category=SWATCH_CATEGORY::DOCUMENT, const String &name=String(), Bool selected=false, Int insertAt=-1, const ColorAlphaArray &colors=ColorAlphaArray())
Further utility functions are:
Further Reading