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:47
Int32 GetInt32(Int32 id, Int32 preset=0) const
Definition: c4d_basecontainer.h:303
BaseContainer GetData()
Definition: c4d_baselist.h:2311
Definition: c4d_basedocument.h:144
Py_UCS4 * res
Definition: unicodeobject.h:1113
@ RDATA_XRES
Definition: drendersettings.h:154
@ RDATA_YRES
Definition: drendersettings.h:155
maxon::Int32 Int32
Definition: ge_sys_math.h:60
IMAGERESULT
Definition: ge_prepass.h:3914
@ OK
Image loaded/created.
RENDERFLAGS
Definition: ge_prepass.h:4681
@ NODOCUMENTCLONE
Set to avoid an automatic clone of the scene sent to RenderDocument().
RENDERRESULT
Definition: ge_prepass.h:419
@ 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:110
String GetString(Int32 id, const maxon::String &preset=maxon::String()) const
Definition: c4d_basecontainer.h:387
void SetString(Int32 id, const maxon::String &s)
Definition: c4d_basecontainer.h:569
BaseContainer * GetClone(COPYFLAGS flags, AliasTrans *trans) const
Definition: c4d_basecontainer.h:101
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:210
#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(void)
Definition: c4d_basedocument.h:498
PyObject PyObject * result
Definition: abstract.h:43
@ BFM_INTERACTSTART
Definition: gui.h:916
@ BFM_INTERACTEND
Sent when user interaction ends.
Definition: gui.h:935
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:635
Bool GetParameter(const DescID &id, GeData &t_data) const
Definition: c4d_basecontainer.h:628
Definition: lib_description.h:330
Definition: c4d_gedata.h:83
const String & GetString(void) const
Definition: c4d_gedata.h:463
The GeData elements are also accessible via:
const GeData & GetData(Int32 id) const
Definition: c4d_basecontainer.h:262
GeData * SetData(Int32 id, const GeData &n)
Definition: c4d_basecontainer.h:255
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:217
maxon::Int Int
Definition: ge_sys_math.h:64
A GeData element is also accessible via its index in the BaseContainer:
if (first != nullptr)
if (second != nullptr)
GeData * GetIndexData(Int32 index) const
Definition: c4d_basecontainer.h:229
New GeData elements can be added to the BaseContainer:
GeData * InsDataAfter(Int32 id, const GeData &n, GeData *last)
Definition: c4d_basecontainer.h:247
Definition: c4d_string.h:39
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:540
void * GetVoid(Int32 id, void *preset=nullptr) const
Definition: c4d_basecontainer.h:343
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:548
Py_ssize_t size
Definition: bytesobject.h:86
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:188
#define SIZEOF(...)
Calculates the size of a datatype or element.
Definition: apibasemath.h:205
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:354
Definition: basearray.h:412
MAXON_ATTRIBUTE_FORCE_INLINE void Connect(const Block< T > &block, Int capacity=0)
Definition: basearray.h:1722
void Set(T *ptr, Int size, Int stride=(STRIDED &&GENERIC) ? -1 :SIZEOF(StrideType))
Definition: block.h:550
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)
BaseObject * GetObjectLink(Int32 id, const BaseDocument *doc) const
BaseMaterial * GetMaterialLink(Int32 id, const BaseDocument *doc) const
BaseList2D * GetLink(Int32 id, const BaseDocument *doc, Int32 instanceof=0) const
Definition: c4d_basecontainer.h:443
void SetLink(Int32 id, C4DAtomGoal *link)
Definition: c4d_basecontainer.h:604
Definition: c4d_baselist.h:2190
String GetName() const
Definition: c4d_baselist.h:2363
Definition: c4d_basematerial.h:28
Definition: c4d_baseobject.h:225
A BaseContainer object can also store further sub-containers:
void SetContainer(Int32 id, const BaseContainer &s)
Definition: c4d_basecontainer.h:597
BaseContainer GetContainer(Int32 id) const
Definition: c4d_basecontainer.h:418
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 CustomDataType * GetCustomDataType(Int32 id, Int32 datatype) const
Definition: customgui_datetime.h:157
void SetCustomDataType(Int32 datatype, const CustomDataType &v)
Definition: c4d_gedata.h:664
static String IntToString(Int32 v)
Definition: c4d_string.h:495
#define DATETIME_DATA
DateTime custom data ID.
Definition: customgui_datetime.h:23
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
Base class for custom data types.
Definition: c4d_customdatatype.h:51
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:197
#define NOTOK
Definition: ge_sys_math.h:267
Remove
Elements can be removed from a BaseContainer:
{
}
Bool RemoveData(Int32 id)
Definition: c4d_basecontainer.h:160
Int32 GetType(void) const
Definition: c4d_gedata.h:407
@ 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:148
static String UIntToString(UInt32 v)
Definition: c4d_string.h:511
maxon::UInt32 UInt32
Definition: ge_sys_math.h:61
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:674
@ 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