On 03/10/2014 at 04:07, xxxxxxxx wrote:
Hmmmm. Thanks for the ideas folks. I still can`t get my cloned object to be independant from the source doc.
Have tried a few different combinations, including Initialising the AliasTrans with both the Active Doc and the source Doc. Also, the documentation says that AliasTrans is for updating baselinks, i`m not using baselinks at all but i though maybe there might be one internally which references the original object in the source doc.. *shrugs*
I also thought that if the cloned object is still referencing the original object from the source doc, that the line BaseDocument::Free(sourcedoc) would probably throw an error or cause the object to not appear, but it doesnt the object still shows. Also tried the line that
s commented out below ( KillDocument(sourcedoc); ) which makes no difference to that either.
So a bit stuck at the moment. Have updated the code with AliasTrans and changed the doc name to sourcedoc
just for you Scott :)
BaseObject* LoadMyObject(const String *objName)
{
BaseDocument *doc = GetActiveDocument();
BaseDocument *sourcedoc = LoadDocument(GeGetPluginPath()+Filename("MyObjects.c4d"),SCENEFILTER_OBJECTS, NULL);
BaseObject *obj = sourcedoc->SearchObject(*objName);
AutoAlloc<AliasTrans> aliastrans;
if(!aliastrans || !aliastrans->Init(doc)) return NULL;
//if(!aliastrans || !aliastrans->Init(sourcedoc)) return NULL; // Tried this also
C4DAtom *newObj = obj->GetClone(COPYFLAGS_0,aliastrans);
aliastrans->Translate(TRUE);
//KillDocument(sourcedoc);
BaseDocument::Free(sourcedoc);
if (newObj == NULL) {
return NULL;
} else {
return (BaseObject* )newObj;
}
}
Maybe i have to actually insert the object into the ActiveDoc before it`ll break ties? *shruggety shrug*