saving as preset / or to library



  • On 28/10/2013 at 12:16, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   r14 
    Platform:      
    Language(s) :     C++  ;

    ---------
    hi there, i'd like to create a save/load functionality for my object generator plugin. how can i do this? optimum would be that there is a save button where a dialog pops up , user enters a name. and a dropdown (cycle element) where the user can recall the settings which where saved.

    or maybe it would be easier to save the current state to the library browser. is there an example anywhere?

    hope someone can help me with this.

    cheers,
    Ello



  • On 28/10/2013 at 14:02, xxxxxxxx wrote:

    You can store the presets in the user-library folder. Retrieve the path to this folder by calling

    > Filename library_dir = GeGetC4DPath(C4D_PATH_LIBRARY_USER) ;

    , then choose an arbitrary subdirectory but you should make sure to name it somewhat uniquely.
    For instance, you can prefix it with your (company) name.

    > Filename preset_dir = library_dir + Filename( "ello" ) + Filename( "presets" ) ;

    To get a list of all the available presets, simply list up all available files in the directory. As far as I
    know there is not built-in SDK function that can list up the files in a directory and you might need
    to use the C standard library for this (dirent.h), but I'll investigate on this topic.

    After you've gathered the list of available presets, you can fill your Combobox in GetDDescription()
    of your ObjectData plugin or open a dialog when the user presses a button on your description
    by catching the MSG_DESCRIPTION_COMMAND message in the Message() method.

    Best,
    -Niklas



  • On 28/10/2013 at 14:17, xxxxxxxx wrote:

    thank you for the input. can you tell me how to actually save the pluginobject where the save button is pressed? or point me to where to look in the sdk?



  • On 28/10/2013 at 14:25, xxxxxxxx wrote:

    Quick response from the devs: the BrowseFiles class! Does exactly what you need to iterate over a
    directories contents.

    You can save a complete instance of your object as a c4d file using the SaveDocument() method,
    or just its container using the HyperFile class. You can also serialize the preset settings using a
    completely different approach, that is really up to you! The only thing that is important for the
    format you chose is that you can re-construct the correct data from it (and maybe metadata
    like a description, a timestamp, preview image? for the latter you might also do it like the Script
    Manager and store an image with the same name as the preset file but with an image suffix).

    Best,
    -Niklas



  • On 28/10/2013 at 14:29, xxxxxxxx wrote:

    thank you very much. one question still remains is how to save only the selected object. like when doing a drag and drop of an object from the objects manager into the library. as SaveDocument will save the whole document. or do i need to create a temporary second document, copy my object into that one and save it??



  • On 28/10/2013 at 15:19, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    or do i need to create a temporary second document, copy my object into that one and save it??

    Exactly. Something along these lines:

    > BaseDocument* new_doc = BaseDocument::Alloc();
    >
    > if (!new_doc) {
    >
    > return false;
    >
    > }
    >
    >
    >
    >
    > BaseObject* clone = op->GetClone(COPYFLAGS_0, NULL);
    >
    > if (!clone) {
    >
    > BaseDocument::Free(new_doc);
    >
    > return false;
    >
    > }
    >
    >
    >
    >
    > new_doc->InsertObject(clone);
    >
    > Bool result = SaveDocument(doc, filename, flags, FORMAT_C4D);
    >
    > BaseDocument::Free(new_doc);
    >
    > return result;

    Best,
    -Niklas



  • On 29/10/2013 at 00:06, xxxxxxxx wrote:

    hi, could it be that there can occure right-problems? the filename seems correct to me:
    C:\Users\ello\AppData\Roaming\MAXON\CINEMA 4D R14_4A9E4467\library\myPlugin\presets\p1.c4d

    however, SaveDocument returns false.


Log in to reply