TakeData Manual

About

A TakeData object stores the take system related data of a BaseDocument.

Access

A TakeData object is returned by the host BaseDocument:

// This example accesses the take data
// fromn the given BaseDocument.
TakeData* const takeData = doc->GetTakeData();
if (takeData == nullptr)
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
Definition: lib_takesystem.h:589
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
const char * doc
Definition: pyerrors.h:226

Read-Only Properties

The TakeData object allows access to its parent document and to different settings of the Take Manager.

Note
The take mode can be toggled with command 431000081. See Command Utility Manual.

Takes

Accessing Takes

Existing takes are accessed from the TakeData object:

// This example checks if the current Take is the main take.
// If not, the main take becomes the current take.
// gets the current take
BaseTake* const currentTake = takeData->GetCurrentTake();
if (currentTake == nullptr)
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
// check if the current take is the main take
if (currentTake->IsMain() == false)
{
// if not, make the main take the current take
BaseTake* const mainTake = takeData->GetMainTake();
takeData->SetCurrentTake(mainTake);
}
Definition: lib_takesystem.h:335
Bool IsMain()
Bool SetCurrentTake(BaseTake *take)
BaseTake * GetCurrentTake() const
BaseTake * GetMainTake()

Create Takes

The TakeData object creates and deletes takes:

// This example simply creates a new take and makes it the current one.
TakeData* const takeData = doc->GetTakeData();
if (takeData == nullptr)
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
BaseTake* const newTake = takeData->AddTake("This is a new take", nullptr, nullptr);
if (newTake == nullptr)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
takeData->SetCurrentTake(newTake);
BaseTake * AddTake(const String &name, BaseTake *parent, BaseTake *cloneFrom)

Overrides

The TakeData object also provides access to the override backup for a given override and parameter:

// This example searches for the BaseOverride of the given material and its color parameter.
// If found, the color value is applied to the backup value to transfer the state of this take
// to the backup take (which might be the main take).
BaseTake* const take = takeData->GetCurrentTake();
if (take == nullptr)
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
// check if this is the main take
if (take->IsMain())
return maxon::OK;
// search for the override of the given material
BaseOverride* const baseOverride = take->FindOverride(takeData, material);
if (baseOverride == nullptr)
return maxon::OK;
// find the backup
BaseTake* result = nullptr;
BaseOverride* const backup = takeData->FindOverrideCounterPart(baseOverride, id, result);
if (backup == nullptr)
return maxon::OK;
GeData data;
// read the value of the take
baseOverride->GetParameter(id, data, DESCFLAGS_GET::NONE);
// set it as the new backup
backup->SetParameter(id, data, DESCFLAGS_SET::NONE);
backup->UpdateSceneNode(takeData, id);
Definition: lib_takesystem.h:79
void UpdateSceneNode(TakeData *takeData, const DescID &descID)
BaseOverride * FindOverride(TakeData *takeData, BaseList2D *node)
Bool SetParameter(const DescID &id, const GeData &t_data, DESCFLAGS_SET flags)
Bool GetParameter(const DescID &id, GeData &t_data, DESCFLAGS_GET flags) const
Definition: lib_description.h:355
Definition: c4d_gedata.h:83
BaseOverride * FindOverrideCounterPart(BaseOverride *overrideNode, const DescID &descID, BaseTake *&resultTake)
PyObject PyObject * result
Definition: abstract.h:43
return OK
Definition: apibase.h:2735
@ DTYPE_COLOR
Color.
Definition: lib_description.h:57
#define ConstDescID(...)
Definition: lib_description.h:594
@ MATERIAL_COLOR_COLOR
Definition: mmaterial.h:56
Represents a level within a DescID.
Definition: lib_description.h:298

Undo States

Several functions of the Take system like TakeData::AddTake() or TakeData::DeleteTake() create an undo step when used. This might not be necessary in some cases, so it is possible to disable the take system's undo state.

// This example disables the undo state of the take system
// since it operates on a BaseDocument that is not
// the active BaseDocument.
// create a new document
AutoAlloc<BaseDocument> takeTemplateDoc;
if (takeTemplateDoc == nullptr)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
TakeData* const takeData = takeTemplateDoc->GetTakeData();
if (takeData == nullptr)
return maxon::OK;
// disable undos since they are not needed in this situation
takeData->SetUndoState(false);
// add some takes
takeData->AddTake("Take 1", nullptr, nullptr);
takeData->AddTake("Take 2", nullptr, nullptr);
// save the document
Bool SaveDocument(BaseDocument *doc, const Filename &name, SAVEDOCUMENTFLAGS saveflags, Int32 format)
Definition: ge_autoptr.h:37
void SetUndoState(Bool state)
#define FORMAT_C4DEXPORT
Cinema&#160;4D export.
Definition: ge_prepass.h:3535

Convert

With TakeData::TakeToDocument() it is possible to create a BaseDocument with the state of the selected take.

// This example only loops through the child takes of the main take,
// but not through further child takes. The folder to save the files
// must be defined with "folder".
const BaseTake* const mainTake = takeData->GetMainTake();
BaseTake* childTake = mainTake->GetDown();
while (childTake != nullptr)
{
// create a BaseDocument with this take's settings
BaseDocument* takeDoc = takeData->TakeToDocument(childTake);
if (takeDoc == nullptr)
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
// create the final Filename
// two takes could have the same name so one should check if this file already exists
const String file = childTake->GetName() + ".c4d";
const Filename filename = folder + file;
// save the document as a Cinema 4D file
// free the document
childTake = childTake->GetNext();
}
PyCompilerFlags const char * filename
Definition: ast.h:15
Definition: c4d_basedocument.h:497
static void Free(BaseDocument *&bl)
String GetName() const
Definition: c4d_baselist.h:2544
BaseTake * GetNext() const
Definition: lib_takesystem.h:353
BaseTake * GetDown() const
Definition: lib_takesystem.h:371
Manages file and path names.
Definition: c4d_file.h:94
Definition: c4d_string.h:41
BaseDocument * TakeToDocument(BaseTake *take)
const char const char const char * file
Definition: object.h:439

Disc I/O

With TakeData::SaveTakesWithAssets() it is possible to save all takes as a separate project.

// This example saves each take with assets.
TakeData* const takeData = doc->GetTakeData();
if (takeData == nullptr)
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
takeData->SaveTakesWithAssets(false);
Bool SaveTakesWithAssets(Bool selected)

Further Reading