This documentation is for the free plugin Py4D in CINEMA 4D R11.5 and not for the C4DSDK of Python in CINEMA 4D R12. For R12, please visit PluginCafe.com
A container is a collection of individual values. Each value has its own ID and type. Container can also carry any number of child containers. There is no guarantee that a value is there in the container.
Keep in mind that there is no guarantee for a value to be in the container. Use default values whenever possible when accessing the values. Maybe your plugin won’t be able to change some values, but it will work anyway.
It is recommended that you use the available containers to store your own values as well. That way they will be automatically saved. However, if you want to store values in the top level of for example an object container, you’ll have to use a unique id. You can use a plugin id from PluginCafe for this. A good way is to store a sub-container with this id. Inside this sub-container you can use whatever ids you want.
Once you’ve set a container value using one type you 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.
| Parameter: | n (BaseContainer, int or None) – Use int if you just want to set the ID of the container. Pass a container if you want to clone it, or use None to use a standard empty container. |
|---|---|
| Return type: | BaseContainer |
| Returns: | The new container. |
The BaseContainer is iteratable so just use it like in the following example:
def iter_container(bc):
for element in bc:
print ">>", element
Automatically redirect the value to the corresponding Set* method. Its recommended to use the original Set* method to avoid type problems.
Warning
This method can replace types. Please check the types before when a special key is associated with a special type.
To delete a key, call del(bc[i]) or RemoveData().
| Parameters: |
|
|---|
Check if the compared containers have the same ID, have the same values, and all values are equal.
| Parameter: | other (BaseContainer) – Returns True if the compared containers are equal. |
|---|
Copies all values to dst.
| Parameters: |
|
|---|
Returns the ID of the container.
| Return type: | int |
|---|---|
| Returns: | The container ID. |
Sets the ID of the container.
| Parameter: | id (int) – The container ID. |
|---|
Removes the first data item with the specified ID.
| Parameter: | id (int) – The container ID. |
|---|---|
| Return type: | bool |
| Returns: | True if any value was removed, otherwise False. |
Removes the data item at the specified index i.
| Parameter: | i (int) – The index of the value to be removed. |
|---|---|
| Return type: | bool |
| Returns: | True if any value was removed, otherwise False. |
Returns the index for the value with the specified ID, or -1 if no such value exists.
| Parameter: | id (int) – The ID of the value. |
|---|---|
| Return type: | bool |
| Returns: | The index of the value, or -1. |
Returns the ID of the element at the specified index, or NOTOK if it doesn’t exist. Used to browse through the container.
| Parameter: | index (int) – The index of the value. |
||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Return type: | bool |
||||||||||||||||||||||||||||||
| Returns: | The ID of the value, or -1.
|
Sets an arbitrary data value at the specified ID. If a value exists under the same ID, its content will be changed.
| Parameters: |
|
|---|
Returns the data for an element by ID.
| Parameter: | id (int) – The ID of the element. |
|---|---|
| Return type: | any |
| Returns: | The data or None if it wasn’t found. |
Returns a bool value with the specified ID, or preset if it doesn’t exist.
| Parameters: |
|
|---|---|
| Return type: | bool |
| Returns: | The value. |
Returns a int value with the specified ID, or preset if it doesn’t exist.
| Parameters: |
|
|---|---|
| Return type: | int |
| Returns: | The value. |
Returns a long value with the specified ID, or preset if it doesn’t exist.
| Parameters: |
|
|---|---|
| Return type: | long |
| Returns: | The value. |
Returns a float value with the specified ID, or preset if it doesn’t exist.
| Parameters: |
|
|---|---|
| Return type: | float |
| Returns: | The value. |
Returns a Vector value with the specified ID, or preset if it doesn’t exist.
| Parameters: |
|
|---|---|
| Return type: | |
| Returns: | The value. |
Returns a Matrix value with the specified ID, or preset if it doesn’t exist.
| Parameters: |
|
|---|---|
| Return type: | |
| Returns: | The value. |
Returns a string value with the specified ID, or preset if it doesn’t exist.
| Parameters: |
|
|---|---|
| Return type: | str |
| Returns: | The value. |
Returns a string value with the specified ID, or preset if it doesn’t exist.
| Parameters: |
|
|---|---|
| Return type: | str |
| Returns: | The value. |
Returns a BaseTime value with the specified ID, or preset if it doesn’t exist.
| Parameters: |
|
|---|---|
| Return type: | |
| Returns: | The value. |
Returns a copy of the sub-container with the specified ID, or an empty container if it doesn’t exist.
| Parameter: | id (int) – The ID of the requested sub-container. |
|---|---|
| Return type: | BaseContainer |
| Returns: | The Sub-container. |
Returns a linked object, evaluated in the attached document. If instanceof is specified, None is returned if the object isn’t of this type.
| Parameters: |
|
|---|---|
| Return type: | |
| Returns: | The linked object, or None if the link is broken. |
Returns a linked base object, evaluated in the attached document. Returns None if the link doesn’t point to a base object.
| Parameters: |
|
|---|---|
| Return type: | |
| Returns: | The linked base object, or None if the link is broken. |
Returns a linked material object, evaluated in the attached document. Returns None if the link doesn’t point to a base object.
| Parameters: |
|
|---|---|
| Return type: | |
| Returns: | The linked material object, or None if the link is broken. |
Returns a copy of the custom data type or None if it doesn’t exist.
| Parameter: | id (int) – The ID of the requested sub-container. |
|---|---|
| Returns: | The custom data type. |
Sets the bool value with the specified ID to b, or inserts it if it didn’t exist.
| Parameters: |
|
|---|
Sets the int value with the specified ID to l, or inserts it if it didn’t exist.
| Parameters: |
|
|---|
Sets the long value with the specified ID to l, or inserts it if it didn’t exist.
| Parameters: |
|
|---|
Sets the float value with the specified ID to r, or inserts it if it didn’t exist.
| Parameters: |
|
|---|
Sets a new vector value with the specified ID to v, or inserts it if it didn’t exist.
| Parameters: |
|
|---|
Sets a new matrix value with the specified ID to m, or inserts it if it didn’t exist.
| Parameters: |
|
|---|
Sets a new string value with the specified ID to s, or inserts it if it didn’t exist.
| Parameters: |
|
|---|
Sets a new string value with the specified ID to s as a filepath, or inserts it if it didn’t exist.
| Parameters: |
|
|---|
Sets the BaseTime value with the specified ID to b as a filepath, or inserts it if it didn’t exist.
| Parameters: |
|
|---|
Sets the sub-container with the specified ID to b as a filepath, or inserts it if it didn’t exist.
| Parameters: |
|
|---|
Stores a link to an atom object with the specified ID.
| Parameters: |
|
|---|
Stores the values in src in this container, overwriting any elements with colliding IDs and keeping the rest.
| Parameter: | src (BaseContainer) – The source container. |
|---|