providing default values for plugin param



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

    On 15/01/2009 at 06:11, xxxxxxxx wrote:

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

    ---------
    Hi,

    I've written a file export/import plugin which uses a parameter to scale the data when reading/writing:

    > \> LONG SceneLoader::Load(PluginSceneLoader \*fp_node, const Filename &fcr;\_filename, BaseDocument \*fp_document, LONG f_flags, String \* /\*error\*/, BaseThread \*fp_thread) \> { \> GeData l_data; \> if (fp_node->GetParameter(DescLevel(VRM3DIMPORT_SCALE),l_data,0)) \> { \>     m_scalingFactor = l_data.GetReal(); \> } \> \> ... lots of code ... \> } \>

    the parameters are defined in res/descriptions/xxx.res:

    > \> CONTAINER Fvrm3dimport \> { \> NAME Fvrm3dimport; \> INCLUDE Fbase; \> \> GROUP Fvrm3dimport \> { \>     REAL VRM3DIMPORT_SCALE {MINEX; MIN 0.0; STEP 0.01;} \> } \> } \>

    so I can set the scaling value for the importer using C4D's preference dialog (Edit->Preferences Import/Export->MyImporterName)

    The value I set there seems be be managed by C4D, it stores it and restores when I restart the application.

    But on the first time I install the plugin and start C4D, it always has set the MIN-value (which is zero and quite bad as scaling factor). I would like to have it set to 1 (or something else) as initial value while still allowing the user to increase or decrease it later on.

    So how can I set an initial value which is used on the first time the plugin starts (i.e. the user hasn't set anything on his own)?

    Any help would be great.
    Thanks in advance!



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

    On 15/01/2009 at 06:28, xxxxxxxx wrote:

    Overload the Init() member of your scene loader class. In Init() just set the description elements' container entries. Look up some of the other plugin type SDK examples for Init().

    cheers,
    Matthias



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

    On 15/01/2009 at 06:42, xxxxxxxx wrote:

    wow, great, that was exactly what I was looking for since almost 2 days!

    I've already thought about the Init function, but I dropped the thought because I thought Init would surely get called on every start of C4D and therefore always overwrite what the user had set before with the initial values.

    But now I've tested it and it works exactly as you suggested.

    Thanks a lot!

    cheers
    Joachim



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

    On 15/01/2009 at 07:48, xxxxxxxx wrote:

    Init() simply lets you initialize such values after instantiation but these are set from file, for instance, after that. This is similar to how BaseContainer's Get..(id, preset) methods have a default value argument 'preset'. If the 'id' hasn't been added to the BaseContainer, the preset value is used. If the 'id' exists, the stored value is used.



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

    On 15/01/2009 at 09:11, xxxxxxxx wrote:

    ok, now I get it. So you always initialize each container in the Init() function although most of the time it gets overwritten by the stored values later on.

    I was searching for a 'DEFAULT' or 'INIT' flag for use in the .res file like that:
    REAL NONZERO_DISTANCE { UNIT METER; MINEX; MIN 0.0; INIT 10.0 }

    which would have been intuitive for me, but now I know better.

    thanks for the explanation.


Log in to reply