Save BaseObject stored internally to .c4d



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 13/08/2009 at 13:01, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   R10-R11 
    Platform:   Windows  ;   Mac OSX  ; 
    Language(s) :     C++  ;

    ---------
    How would one go about saving a BaseObject (children, tags and all) stored in memory (not attached to the document!!) and member of a class which is part of the plugin being written (CopyTo/Read/Write) along with the C4D document?

    Basically, I want to embed these objects being used by my generator plugin so that the external object file (.c4d) does not have to exist in order to use the document in other locations (such as a render farm, for instance).

    Once again, thanks!



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 13/08/2009 at 16:16, xxxxxxxx wrote:

    Aha! Found C4DAtom::WriteObject() which will do the trick. :)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 13/08/2009 at 16:26, xxxxxxxx wrote:

    Yes, that works fine, but ReadObject() seems to be private. Do you know how to use?

    Thanks :)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 13/08/2009 at 17:19, xxxxxxxx wrote:

    Seems purely accessible here. Are you getting some sort of build error when using it?

    My problem is bigger though. Some of the 'internal' objects may have textures/materials which ReadObject() and WriteObject() probably won't retain and restore. I may end up needing to insert the objects into the document afterall - not my best solution but at least it would guarantee them being embedded (literally in the document). It was hoped that such a maneuver could be avoided (as an external user library of objects is being employed). And everytime the user decides to disable/enable use of various objects, those inserted into the document need to reflect that so as to avoid, well, a mess. ;)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 13/08/2009 at 20:15, xxxxxxxx wrote:

    I just had a thought (don't have too many of those). ;) Can C4DAtom::ReadObject() and WriteObject() be used with a BaseDocument considering that it is C4DAtom derived? I'm going to try that as it will make everything much simpler if it does indeed work. This way there is no need to embed the objects into the real document but just write and read the already in-memory BaseDocuments containing the custom user objects. Yay (we'll see). :D



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 14/08/2009 at 01:51, xxxxxxxx wrote:

    I dont get any compiler errors, but I dont really understand how to use C4DAtom::ReadObject(). Writing an object seems to be much simpler.

    BaseList2D *op = BaseList2D::Alloc(Ocube);
    op->WriteObject(fn);
    ...

    But how do I read the object? C4DAtom::ReadObject() doesnt seem to work. WriteObject returns True on writing, and ReadObject always returns false.

    Bye, Shawni



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 14/08/2009 at 05:03, xxxxxxxx wrote:

    Oh. That confused me a bit at first too. You need to allocate the type first then use this to 'fill' it from the read.

    BaseObject* op = BaseObject::Alloc(Ocube);
    if (!op) return FALSE;
    op->ReadObject(hf, TRUE);

    Same as showed for WriteObject() except that the object probably already existed. ;)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 17/08/2009 at 03:47, xxxxxxxx wrote:

    Read/WriteObject are not really meant for plugins. Please use a dummy document with Save/LoadDocument.

    Writing anobject to HyperFile

    cheers,
    Matthias



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 17/08/2009 at 08:37, xxxxxxxx wrote:

    I've since opted simply to insert the objects into the document so there's no need for Read/WriteObject. :)

    They are already saved into documents in file (library) and loaded as documents into memory.

    Thanks,



  • On 07/04/2013 at 06:26, xxxxxxxx wrote:

    I've found this example by Matthias were he uses a GeListHead to write a custom hierarchy
    of BaseList2D objects. I didn't try it, but it should work for any type of objects, shouldn't it?

    https://plugincafe.maxon.net/topic/5000/4913_nodedata-list


Log in to reply