On 02/02/2017 at 10:57, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R13
Platform: Windows ;
Language(s) : C++ ;
---------
Hi,
I'm trying to copy a specific UD item from one object to another. But I'm getting a strange, buggy behavior from it if that UD item is a child of a UD Group.
The item is indeed copied. But it does not show up in the AM until I open the UD manager and then press "OK".
Even using this core message does not make it update:
SendCoreMessage(COREMSG_CINEMA, BaseContainer(COREMSG_CINEMA_FORCE_AM_UPDATE));
If the item I'm copying is not a child of a group. It all works properly as expected.
I'm also getting the same buggy behavior in python.
BaseObject *source = doc->SearchObject("Cube");
if (!source) return false;
BaseObject *target = doc->SearchObject("Sphere");
if (!target) return false;
DynamicDescription *s_ud = source->GetDynamicDescription();
DynamicDescription *t_ud = target->GetDynamicDescription();
doc->AddUndo(UNDOTYPE_CHANGE, target);
LONG level = 2; //<---Change this to get the other UD items as desired
DescID item(DescLevel(ID_USERDATA, DTYPE_SUBCONTAINER, 0), level);
const BaseContainer *sbc = s_ud->Find(item);
String name = sbc->GetString(DESC_NAME);
LONG type = sbc->GetLong(DESC_CUSTOMGUI);
LONG unit = sbc->GetLong(DESC_UNIT);
GePrint(name + " " + LongToString(type) + " " + LongToString(unit));
//Get the value of the UD item
GeData d;
source->GetParameter(item, d, DESCFLAGS_GET_0);
//Copy the UD item to another object's UD master container and also copy the value
DescID udCopy(DescLevel(ID_USERDATA, DTYPE_SUBCONTAINER, 0), DescLevel(level));
const BaseContainer clonedBC = *sbc->GetClone(COPYFLAGS_0, NULL);
udCopy = t_ud->Alloc(clonedBC);
target->SetParameter(DescID(udCopy), GeData(d), DESCFLAGS_SET_0);
t_ud->Set(udCopy, clonedBC, target);
Can anyone tell me what's going on?
Why does the AM not update correctly when copying UD items that are children of a Group?
-ScottA