TakeData Manual

内容表

关于

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 );

Read-Only Properties

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

注意
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); }

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);

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 ; const DescID id { DescLevel { MATERIAL_COLOR_COLOR , DTYPE_COLOR , 0 } };

// 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 );

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 SaveDocument (takeTemplateDoc, savePath, SAVEDOCUMENTFLAGS::NONE , FORMAT_C4DEXPORT );

转换

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 SaveDocument (takeDoc, filename, SAVEDOCUMENTFLAGS::NONE , FORMAT_C4DEXPORT );

// free the document BaseDocument::Free (takeDoc); childTake = childTake-> GetNext (); }

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 );

延伸阅读

TakeData::SetUndoState
void SetUndoState(Bool state)
DescID
定义: lib_description.h:327
BaseTake
定义: lib_takesystem.h:319
BaseOverride
定义: lib_takesystem.h:78
BaseTake::IsMain
Bool IsMain()
SaveDocument
Bool SaveDocument(BaseDocument *doc, const Filename &name, SAVEDOCUMENTFLAGS saveflags, Int32 format)
Filename
Manages file and path names.
定义: c4d_file.h:93
maxon::OK
return OK
定义: apibase.h:2532
TakeData::AddTake
BaseTake * AddTake(const String &name, BaseTake *parent, BaseTake *cloneFrom)
TakeData::SaveTakesWithAssets
Bool SaveTakesWithAssets(Bool selected)
TakeData::GetMainTake
BaseTake * GetMainTake()
MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
定义: memoryallocationbase.h:66
DESCFLAGS_SET::NONE
@ NONE
None.
TakeData
定义: lib_takesystem.h:573
BaseTake::GetNext
BaseTake * GetNext() const
定义: lib_takesystem.h:338
String
定义: c4d_string.h:38
C4DAtom::SetParameter
Bool SetParameter(const DescID &id, const GeData &t_data, DESCFLAGS_SET flags)
TakeData::GetCurrentTake
BaseTake * GetCurrentTake()
TakeData::SetCurrentTake
Bool SetCurrentTake(BaseTake *take)
DescLevel
Represents a level within a DescID.
定义: lib_description.h:286
FORMAT_C4DEXPORT
#define FORMAT_C4DEXPORT
Cinema 4D export.
定义: ge_prepass.h:3280
BaseDocument::GetTakeData
TakeData * GetTakeData()
TakeData::TakeToDocument
BaseDocument * TakeToDocument(BaseTake *take)
BaseOverride::UpdateSceneNode
void UpdateSceneNode(TakeData *takeData, const DescID &descID)
GeData
定义: c4d_gedata.h:82
TakeData::FindOverrideCounterPart
BaseOverride * FindOverrideCounterPart(BaseOverride *overrideNode, const DescID &descID, BaseTake *&resultTake)
BaseDocument::Free
static void Free(BaseDocument *&bl)
AutoAlloc
定义: ge_autoptr.h:36
DESCFLAGS_GET::NONE
@ NONE
None.
MATERIAL_COLOR_COLOR
@ MATERIAL_COLOR_COLOR
定义: mmaterial.h:56
BaseList2D::GetName
String GetName() const
定义: c4d_baselist.h:2318
BaseTake::FindOverride
BaseOverride * FindOverride(TakeData *takeData, BaseList2D *node)
BaseTake::GetDown
BaseTake * GetDown() const
定义: lib_takesystem.h:356
DTYPE_COLOR
@ DTYPE_COLOR
Color.
定义: lib_description.h:57
C4DAtom::GetParameter
Bool GetParameter(const DescID &id, GeData &t_data, DESCFLAGS_GET flags)
BaseDocument
定义: c4d_basedocument.h:490
SAVEDOCUMENTFLAGS::NONE
@ NONE
None.

Copyright  © 2014-2025 乐数软件    

工业和信息化部: 粤ICP备14079481号-1