Hi @rsodre,
I am even more confused now by your answer :) So let me explain what I was talking about. I will refer to your first example as f1
and to your second example as f2
. I will assume that paramId
equals 1
and for simplicity I will also assume a DTYPE_LONG
(i.e. an integer value) instead of your custom data type. Let's assume that we write the value 42
.
After you have run f1
, the data container of the node will look like this:
// f1 wrote simply to the index `1` of the container, here the value `42`.
// This is dangerous, because Cinema stores internal data in the data container range 0 to 1000.
// You should never write to this range. I assumed value `1` for `paramID`, because user data IDs
// usually start in this very low range.
[1]: 42
...
// The user data container, it will be always in data container.
[700, i.e. ID_USERDATA]: BaseContainer
// In this case we assume the user data container to be empty
...
And after you have run f2
, the data container of the node will look like this:
...
// The user data container, it will be always in data container.
[700, i.e. ID_USERDATA]: BaseContainer
// The value written by `f2`
[1]: 42
...
Both values can be retrieved with GetParamater
which is mostly a convenience wrapper around the data container of a node. The differences for Get/SetParamater
are:
- They enforce the data type of the container at the given id, i.e. you cannot simply overwrite an existing value type with another value type.
- They allow for the access of node attributes which are not being stored in its data container, e.g. its name.
- They allow to reach "deeper" into a data container which can contain composed value types (e.g. a
BaseContainer
or a Vector
) . This is done via DescID
and DescLevel
.
To retrieve the value written by f1
, we simply need a DescID
with one DescLevel
, because paramId
was not a container type value.
const DescLevel dlvlParamId (paramId, DTYPE_LONG, 0);
const DescID did = DescID(dlvlParamId);
For f2
the DescID
would have to have two levels. This would be an example for reaching "deeper", here retrieving a DTYPE_LONG
in a DTYPE_SUBCONTAINER
. If dlvlParamId
would be of DTYPE_VECTOR
, we could also reach one more level further down, e.g., we could retrieve the first component of a vector inside a subcontainer.
const DescLevel dlvlUserData(ID_USERDATA, DTYPE_SUBCONTAINER, 0);
const DescLevel dlvlParamId(paramId, DTYPE_LONG, 0);
const DescID did = DescID(dlvlUserData, dlvlParamId);
So, I still don't quite get what your goals are, but yes, initializing an attribute in a data container will make it accessible as a parameter. But you do not clarify how the (dynamic) description of the data container hosting node is constituted, so there might be no GUI for your data. The "proper" way to create a new user data entry is described in the DynamicDescription Manual. Which then later can be written to in the way described here.
I hope this helps and happy holidays,
Ferdinand