On 02/10/2014 at 15:49, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R14
Platform: Windows ;
Language(s) : C++ ;
---------
Inside my plugin i`m using LoadDocument to load a c4d file into a temp doc, then grabbing an object out of the loaded doc, then cloning the object with GetClone, then freeing up the temp doc with Free, and then passing the new cloned object back to my main function and adding it into the ActiveDocument..
The code looks like this:
BaseObject* LoadMyObject(const String *objName)
{
tempdoc = LoadDocument(GeGetPluginPath()+Filename("MyObjects.c4d"),SCENEFILTER_OBJECTS, NULL);
BaseObject *obj = tempdoc->SearchObject(*objName);
C4DAtom *newObj = obj->GetClone(COPYFLAGS_0,NULL);
//KillDocument(tempdoc);
BaseDocument::Free(tempdoc);
if (newObj == NULL) {
return NULL;
} else {
return (BaseObject* )newObj;
}
}
The interesting thing is that when i run my plugin, and the object loads and is displayed - if i then open the MyObjects.c4d scene and alter the source object in that and then save, the changes are automatically updated in the loaded object that my plugin is displaying..
I kind of thought that as the object had been loaded then Cloned, then added to the current active document that it would have broken any ties with the original object. I guess the fact that the line
C4DAtom *newObj = obj->GetClone(COPYFLAGS_0,NULL);
is returning a pointer means that it is still referencing the original..
So two questions:
- So what is the point of GetClone if it`s just a pointer and not actually a clone?
- What would be the way to actually clone an object so that it is independent?
Any ideas appreciated.