THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/12/2012 at 03:04, xxxxxxxx wrote:
Originally posted by xxxxxxxx
I know it returns a const BaseContainer. But I cannot do anything with it.
I usually have no problems getting data from containers. But this thing is a different animal.
I can't read any data from it in this form: dd->Find(udEntry);
I need a way to read the data from that line of code.
You can only call the const methods on the returned container:
const BaseContainer *udDescription = dynDesc->Find(udID);
if (udDescription==NULL) return FALSE;
GePrint(udDescription->GetString(DESC_NAME));
DescID udEntry(DescLevel(ID_USERDATA, DTYPE_SUBCONTAINER, DESCFLAGS_GET_0), DescLevel(gizmo));
I think the description ID should be declared as:
DescID udID(DescLevel(ID_USERDATA, DTYPE_SUBCONTAINER, 0), DescLevel(gizmo, DTYPE_REAL, 0));
Originally posted by xxxxxxxx
Using EventAdd() didn't work.
This is just a wild guess on my part.
But the problem seems to be that when we add user data. C4D doesn't see it until we actually click on it with the mouse. And that's why my container named "d" is returning zero, instead the type value, until I manually click and edit that UD entry.
I can't reproduce this behavior. I created a user data with the UI (without clicking it) and also tried with the SDK, here's my code:
BaseObject *op = doc->GetActiveObject();
if (op==NULL) return FALSE;
GeData data;
DescID udID(DescLevel(ID_USERDATA, DTYPE_SUBCONTAINER, 0), DescLevel(1, DTYPE_REAL, 0));
DynamicDescription *dynDesc = op->GetDynamicDescription();
if (dynDesc==NULL) return FALSE;
BaseContainer udSettings;
if (!dynDesc->FillDefaultContainer(udSettings, DTYPE_REAL, "Name"))
return FALSE;
dynDesc->Set(udID, udSettings, NULL);
if (op->GetParameter(udID, data, DESCFLAGS_GET_0))
GePrint(LongToString(data.GetType()));
const BaseContainer *udDesc = dynDesc->Find(udID);
if (udDesc==NULL) return FALSE;
GePrint(udDesc->GetString(DESC_NAME));
Originally posted by xxxxxxxx
I do have another code snippet that loops through the UD and gets the types. And it that one works properly. But... it uses a BaseContainer (not GetParameter) and the BrowseGetNext() function.
What If I only want to make a small change to one specific user data item?
Do I have to loop through all of them. Every single time. Because that's the only way to get their current values?
Looping through the dynamic description parameters with BrowseGetNext() is the only way to modify the description of a user data.