About
A BaseContainer is a collection of individual values. Each value has its own ID and type. A BaseContainer can also carry any number of child containers. 90% of Cinema 4D's internal values are stored in containers and all messages are working with containers, so this class is an essential part of the SDK. Containers can store any GeData type, including custom data types. It is recommended to use the available containers to store values in custom NodeData based plugins.
- Warning
- Keep in mind that there is no guarantee for a value to be in the container. Use default values whenever possible when accessing container's ID data.
-
Use the typed access methods (for example BaseContainer::GetBool()) whenever possible, instead of the low-level BaseContainer::GetData(). See Access.
-
Once a container value has been set using one type one must neither try to access it using another type, nor overwrite it with a value of another type. Using the wrong access will not crash, but it is illegal.
- Note
- To browse through all elements of a BaseContainer use the class BrowseContainer.
Access
Every BaseList2D based object of the Cinema 4D API has a BaseContainer that stores its data. This BaseContainer can be accessed with:
See BaseList2D Manual.
- Note
- Object parameters should be edited with C4DAtom::GetParameter() / C4DAtom::SetParameter(). Not all parameters of an object may be stored in the BaseContainer.
if (rdata == nullptr)
if (bitmap == nullptr)
PyCompilerFlags * flags
Definition: ast.h:14
RENDERRESULT RenderDocument(BaseDocument *doc, const BaseContainer &rdata, ProgressHook *prog, void *private_data, BaseBitmap *bmp, RENDERFLAGS renderflags, BaseThread *th, WriteProgressHook *wprog=nullptr, void *data=nullptr)
Bool ShowBitmap(const Filename &fn)
Definition: ge_autoptr.h:37
Definition: c4d_basecontainer.h:48
Int32 GetInt32(Int32 id, Int32 preset=0) const
Definition: c4d_basecontainer.h:348
const BaseContainer & GetDataInstanceRef() const
Definition: c4d_baselist.h:2518
Definition: c4d_basedocument.h:143
Py_UCS4 * res
Definition: unicodeobject.h:1113
@ RDATA_XRES
Definition: drendersettings.h:152
@ RDATA_YRES
Definition: drendersettings.h:153
maxon::Int32 Int32
Definition: ge_sys_math.h:56
IMAGERESULT
Definition: ge_prepass.h:3925
@ OK
Image loaded/created.
RENDERFLAGS
Definition: ge_prepass.h:4696
@ NODOCUMENTCLONE
Set to avoid an automatic clone of the scene sent to RenderDocument().
RENDERRESULT
Definition: ge_prepass.h:427
@ OK
Function was successful.
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
unsigned long Py_ssize_t width
Definition: pycore_traceback.h:88
const char * doc
Definition: pyerrors.h:226
BaseContainer elements are also often used as an argument in a function call.
Copy
The complete content of a BaseContainer object can be copied to another object:
It is also possible to copy a BaseContainer using the copy constructor.
if (clone == nullptr)
Bool CopyTo(BaseContainer *dst, COPYFLAGS flags, AliasTrans *trans) const
Definition: c4d_basecontainer.h:119
String GetString(Int32 id, const maxon::String &preset=maxon::String()) const
Definition: c4d_basecontainer.h:432
void SetString(Int32 id, const maxon::String &s)
Definition: c4d_basecontainer.h:651
BaseContainer * GetClone(COPYFLAGS flags, AliasTrans *trans) const
Definition: c4d_basecontainer.h:110
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:204
#define DeleteObj(obj)
Definition: newobj.h:159
- Note
- To merge containers see BaseContainer::MergeContainer() in chapter Functionality.
Data
ID
A BaseContainer can have an ID. This ID can be used to identify the container.
{
{
{
_interactStart = true;
break;
}
{
if (_undoStarted)
{
_undoStarted = false;
}
_interactStart = false;
break;
}
}
}
BaseDocument * GetActiveDocument()
Definition: c4d_basedocument.h:497
PyObject PyObject * result
Definition: abstract.h:43
@ BFM_INTERACTSTART
Definition: gui.h:924
@ BFM_INTERACTEND
Sent when user interaction ends.
Definition: gui.h:943
const char const char * msg
Definition: object.h:438
Access
A BaseContainer stores its data using GeData objects. It is possible to access these GeData objects or the stored values directly using typed access functions. It is recommended to prefer the typed access functions.
A copy of a GeData element can be obtained with:
- Note
- The DescLevel::id property is used as the actual ID.
Bool SetParameter(const DescID &id, const GeData &t_data)
Definition: c4d_basecontainer.h:723
Bool GetParameter(const DescID &id, GeData &t_data) const
Definition: c4d_basecontainer.h:716
Definition: c4d_gedata.h:83
const String & GetString() const
Definition: c4d_gedata.h:498
#define ConstDescID(...)
Definition: lib_description.h:594
Represents a level within a DescID.
Definition: lib_description.h:298
The GeData elements are also accessible via:
Bool SetData(Int32 id, const GeData &n)
Definition: c4d_basecontainer.h:274
const GeData & GetData(Int32 id) const
Definition: c4d_basecontainer.h:290
For fast access read-only pointers to the GeData elements are accessible:
Int32 ids[] = { 100, 200 };
if (data[0])
if (data[1])
Py_ssize_t count
Definition: abstract.h:640
void GetDataPointers(const Int32 *ids, Int32 cnt, const GeData **data) const
Definition: c4d_basecontainer.h:234
maxon::Int Int
Definition: ge_sys_math.h:60
A GeData element is also accessible via its index in the BaseContainer:
if (first != nullptr)
if (second != nullptr)
const GeData * GetIndexData(Int32 index) const
Definition: c4d_basecontainer.h:246
New GeData elements can be added to the BaseContainer:
GeData * InsDataAfter(Int32 id, const GeData &n, const GeData *last)
Definition: c4d_basecontainer.h:267
Definition: c4d_string.h:41
To access the values of primitive data types, these access functions are available:
See also Primitive Data Types Manual (Classic).
A BaseContainer can store a void pointer.
- Note
- This should not be used to store a reference to a C4DAtom based element; instead a BaseLink should be used.
SomeObject*
const obj =
static_cast<SomeObject*
>(bc.
GetVoid(100));
void SetVoid(Int32 id, void *v)
Definition: c4d_basecontainer.h:622
void * GetVoid(Int32 id, void *preset=nullptr) const
Definition: c4d_basecontainer.h:388
PyObject * obj
Definition: complexobject.h:60
A BaseContainer can store raw memory:
{
}
else
{
void* pArray = myArray.Disconnect().Begin().GetPtr();
if (pArray == nullptr)
}
void SetMemory(Int32 id, void *mem, Int count)
Definition: c4d_basecontainer.h:630
Py_ssize_t size
Definition: bytesobject.h:86
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:202
#define SIZEOF(...)
Calculates the size of a datatype or element.
Definition: apibasemath.h:214
if (memFromContainer !=
nullptr &&
size > 0)
{
if (myMem == nullptr)
}
for (
auto&
value : myOtherArray)
PyObject * value
Definition: abstract.h:715
void * GetMemoryAndRelease(Int32 id, Int &count, void *preset=nullptr)
Definition: c4d_basecontainer.h:399
Definition: basearray.h:415
MAXON_ATTRIBUTE_FORCE_INLINE void Connect(const Block< T > &block, Int capacity=0)
Definition: basearray.h:1571
void Set(T *ptr, Int size, Int stride=(STRIDED &&GENERIC) ? -1 :SIZEOF(StrideType))
Definition: block.h:551
A BaseContainer offers also access functions for mathematical data types:
See also Vector Manual (Classic) and Matrix Manual (Classic).
A BaseContainer offers further access functions for typical Cinema 4D data types:
See also String Manual (Classic) and Filename Manual.
See also BaseTime Manual.
A BaseContainer also offers special functions to store and handle BaseLink objects:
See also BaseLink Manual.
if (mat)
if (link)
const BaseMaterial * GetMaterialLink(Int32 id, const BaseDocument *doc) const
void SetLink(Int32 id, const C4DAtomGoal *link)
Definition: c4d_basecontainer.h:686
const BaseObject * GetObjectLink(Int32 id, const BaseDocument *doc) const
const BaseList2D * GetLink(Int32 id, const BaseDocument *doc, Int32 instanceof=0) const
Definition: c4d_basecontainer.h:488
Definition: c4d_baselist.h:2377
String GetName() const
Definition: c4d_baselist.h:2544
Definition: c4d_basematerial.h:28
Definition: c4d_baseobject.h:248
A BaseContainer object can also store further sub-containers:
void SetContainer(Int32 id, const BaseContainer &s)
Definition: c4d_basecontainer.h:679
BaseContainer GetContainer(Int32 id) const
Definition: c4d_basecontainer.h:463
A BaseContainer can also store custom data types. To set the value of the custom data type a GeData object is needed.
if (date == nullptr)
date->SetDateTime(time);
if (dateTimeData)
{
}
const DATATYPE * GetCustomDataType(Int32 id) const
Definition: c4d_basecontainer.h:533
Definition: customgui_datetime.h:157
void SetCustomDataType(const DATATYPE &v)
Definition: c4d_gedata.h:747
static String IntToString(Int32 v)
Definition: c4d_string.h:497
void GetDateTimeNow(DateTime &t)
Int32 minute
Minute.
Definition: customgui_datetime.h:67
Int32 day
Day in month.
Definition: customgui_datetime.h:64
Int32 month
Month.
Definition: customgui_datetime.h:63
Int32 second
Second.
Definition: customgui_datetime.h:68
Int32 year
Year.
Definition: customgui_datetime.h:62
DateTime GetDateTime() const
Int32 hour
Hour.
Definition: customgui_datetime.h:66
Represents a date and time.
Definition: customgui_datetime.h:39
These functions can be used to limit the values of a Vector or Float value inside a BaseContaier:
- Note
- These functions simply apply ClampValue(), see also Mathematical Functions Manual (Classic).
Index
The elements stored within a BaseContainer are accessible through their index and their ID:
See also BaseContainer::GetIndexData() above. To loop through values see also BrowseContainer.
while (true)
{
break;
else
}
Py_ssize_t i
Definition: abstract.h:645
Int32 GetIndexId(Int32 index) const
Definition: c4d_basecontainer.h:214
#define NOTOK
Definition: ge_sys_math.h:263
Remove
Elements can be removed from a BaseContainer:
{
}
Bool RemoveData(Int32 id)
Definition: c4d_basecontainer.h:169
Int32 GetType() const
Definition: c4d_gedata.h:436
@ DA_NIL
No value.
Definition: c4d_gedata.h:38
Functionality
Several operations can be performed on a BaseContainer object.
void MergeContainer(const BaseContainer &src)
Compare
Two BaseContainer are identical if they have the same ID, the same number of entries and if the entries are also identical and in the same order.
Detect Changes
The dirty state of a BaseContainer changes incrementally when a value stored in the BaseContainer is changed.
UInt32 GetDirty() const
Definition: c4d_basecontainer.h:157
static String UIntToString(UInt32 v)
Definition: c4d_string.h:513
maxon::UInt32 UInt32
Definition: ge_sys_math.h:57
BrowseContainer
The BrowseContainer class can be used to browse through the values stored in a BaseContainer. See also Index.
while (browse.GetNext(&id, &dat))
{
if (dat != nullptr)
{
}
}
Definition: c4d_gedata.h:760
@ DA_STRING
String.
Definition: c4d_gedata.h:47
Disc I/O
A BaseContainer can be stored in a HyperFile.
if (hf == nullptr)
{
hf->WriteContainer(bc);
hf->Close();
}
else
{
}
PyCompilerFlags const char * filename
Definition: ast.h:15
maxon::Url MaxonConvert(const Filename &fn, MAXONCONVERTMODE convertMode)
@ NONE
No check if file exists under case-sensitive drives.
@ ANY
Show an error dialog for any error.
if (hf == nullptr)
{
hf->ReadContainer(&bc, true);
@ READ
Open the file for reading.
See also HyperFile Manual on BaseContainer.
Further Reading