Read a c4d document
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 02/12/2007 at 08:58, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R10
Platform: Windows ; Mac ; Mac OSX ;
Language(s) : C++ ;---------
Hi,
I have a c4d document ("doc"), I'm trying to load an other c4d document ("doc2"), retrieve the first object of doc2 insert this in "doc", and then close "doc2".the equivalent in coffee :
> _
> var doc = GetActiveDocument();
> var f = GeGetStartupPath();
> f->AddLast("plugins");
> f->AddLast("scene.c4d");
> if(GeFileExist(f,FALSE))
> {
> LoadDocument(f);
> var doc2=GetActiveDocument();
> var objet = doc2->GetFirstObject();
> var newObject=objet->GetClone(CL_NO_TRACKS);
> doc->InsertObject(newObject,NULL,NULL);
> KillDocument(doc2);
> }
>
>
> _The file "scene.c4d" is in the plugin directory of Cinema4D folder.
I can not reproduce it in C++.
I hope somebody has the solution, thank a lot and sorry for my english,
xs_yann -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 02/12/2007 at 10:00, xxxxxxxx wrote:
In C++, LoadDocument() returns the new document so you don't have to get it. Best to allocate and use an AliasTrans:
> AutoAlloc <AliasTrans> trans;
> if (!trans) return FALSE;
> BaseDocument* doc2 = LoadDocument(f);
> if (!doc2) return FALSE;
> if (trans->Init(doc2))
> {
> BaseObject* objet = doc2->GetFirstObject();
> if (objet)
> {
> objet = objet->GetClone(COPY_NO_ANIMATION, trans);
> if (objet)
> {
> doc->InsertObject(objet, NULL, NULL);
> trans->Translate(TRUE);
> }
> }
> }
> KillDocument(doc2);
> EventAdd(); -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 03/12/2007 at 07:25, xxxxxxxx wrote:
Thank you kuroyume0161 for your help but when I try your code it generate some errors :
> _
> Filename f = GeGetPluginPath();
> f.SetFile("scene.c4d");
> AutoAlloc<AliasTrans> trans;
> if (!trans) return FALSE;
> BaseDocument* doc2 = LoadDocument(f); //error: at this point in file
> if (!doc2) return FALSE;
> if (trans->Init(doc2)) {
> BaseObject* objet = doc2->GetFirstObject();
> if (objet) {
> objet = objet->GetClone(COPY_NO_ANIMATION, trans); //error : invalid conversion from 'C4DAtom' to 'BaseObject*'
> if (objet) {
> doc->InsertObject(objet, NULL, NULL);
> trans->Translate(TRUE);
> }
> }
> }
> KillDocument(doc2);
> EventAdd();
>
> _Sorry I'm a beginner, I still sought in the SDK for a short time but I
found nothing to solve the problem. Thank you again. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 03/12/2007 at 08:13, xxxxxxxx wrote:
I didn't fill in the FLAGS since you need to determine which ones to 'OR' together. You do have the SDK Help files, correct? Setting this argument to 0L should do.
BaseDocument* doc2 = LoadDocument(f, 0L, NULL);
Unlike COFFEE, C++ is a typed language. To convert from one type to another sometimes requires casting (depending upon the direction and extent of change). Since BaseObject is derived from C4DAtom (as are almost all C4D Base classes), just static cast:
objet = static_cast<BaseObject*>objet->GetClone(COPY_NO_ANIMATION, trans);