Access to BaseList parameters



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

    On 18/11/2008 at 09:23, xxxxxxxx wrote:

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

    ---------
        Hi!

    I wanted to ask whats the difference between BaseList2D::GetDataInstance and C4DAtom::GetParameter.

    I noticed, some settings can be set and get by using GetParameter/SetParameter and not stored in GetDataInstance.

    What should I use? Is GetParameter the better way?

    Thanks :)



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

    On 19/11/2008 at 06:48, xxxxxxxx wrote:

    Howdy,

    Well, I reckon it depends on what you need to do.

    BaseList2D::GetDataInstance() returns a pointer to the object container, so if you have several parameters you need to get and set within a function, it may be easier to use GetDataInstance() to hold the pointer to the entire container.

    I normally use GetDataInstance() for everything unless I need access to a parameter that can't be accessed with GetDataInstance().

    Adios,
    Cactus Dan



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

    On 19/11/2008 at 08:56, xxxxxxxx wrote:

    Use GetDataInstance() as often as you can as setting and getting values from it is faster than the other methods.



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

    On 19/11/2008 at 09:02, xxxxxxxx wrote:

    Howdy,

    Ah, I've been trying to learn more about C and C++ programming, and I'm assuming it's faster because you're working with pointers instead of the actual data?

    Adios,
    Cactus Dan



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

    On 19/11/2008 at 09:58, xxxxxxxx wrote:

    Howdy Dan,

    well, that really fully depends on how and where the pointer is used. It´s not necessarily faster, actually using a reference should generally be faster than a pointer (e.g. when passing a reference there are less constructor calls than for a pointer). But of course this also depends on compiler optimisation etc. There is no real convention.

    In this case however, I am simply following an advice from a C4D developer who once told me that using GetDataInstance() is indeed faster. :)



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

    On 19/11/2008 at 11:17, xxxxxxxx wrote:

    The one reason it would be faster is that you are getting the memory pointer to the actual BaseContainer and not a copy (which requires time to allocate and populate with the same data). Every time you send a class (on the stack) instead of a reference or a pointer, you are incurring this creation/duplication fee in time.

    Also, not to be too disparaging to the Cinema 4D developers, #define should be replaced with const variable declarations in every possible instance. enums are better though and they get credit for using them extensively.

    The book to read is "Effective C++ - Third Edition" by Scott Meyers.



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

    On 19/11/2008 at 11:37, xxxxxxxx wrote:

    Also make sure to consult the docs before you assume anything. For example, regarding BaseDraw (circa v9.603) :
    Note: Parameters must only be accessed using GetParameter()/SetParameter(), not using the container. A list of parameters can be found in the convenience GetParameterData() function.



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

    On 19/11/2008 at 12:37, xxxxxxxx wrote:

    Howdy,

    > Quote: Originally posted by kuroyume0161 on 19 November 2008
    >
    > * * *
    >
    > The one reason it would be faster is that you are getting the memory
    > pointer to the actual BaseContainer and not a copy (which requires time
    > to allocate and populate with the same data). Every time you send a class
    > (on the stack) instead of a reference or a pointer, you are incurring this
    > creation/duplication fee in time.
    >
    >
    > * * *

    Yes, that was what I was assuming.

    I've been learning C and C++ from these training videos:
    http://www.softwaretrainingtutorials.com/cprogramming.php
    http://www.softwaretrainingtutorials.com/c-plus-plus.php

    I just finished the part about pointers in the C tutorial and I'm moving on to structures. :o)

    Adios,
    Cactus Dan



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

    On 19/11/2008 at 22:40, xxxxxxxx wrote:

    Hi!

    Wow, thanks for all of your answers. In my case the problem is, that I don't get all of the settings-parameters.

    When I call GetDataInstance and check the type of the ID element 908 (this is the color value on the common tab which you can activate for each object) the return value is 0. When I do the same on GetParameter, I get that the element is of type Vector.

    > <code>
    > BaseObject* dl = BaseObject::Alloc(Ocube);
    >      GePrint(LongToString(dl->GetDataInstance()->GetType(907)));//returns DA_NIL (type id: 0)
    >      
    >      GeData t;
    >      dl->GetParameter(DescID(907), t, 0);
    >      GePrint(LongToString(t.GetType()));//returns DA_LONG (type id: 15)
    > </code>

    ID 907 is the elemnt in the Basic Tab -> "Use Color:"
    Bye,

    Sebastian



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

    On 20/11/2008 at 07:05, xxxxxxxx wrote:

    Howdy,

    All of those color parameters are in an ObjectColorProperties structure. Use BaseObject::GetColorProperties() and BaseObject::SetColorProperties() to work with those parameters. ;o)

    Adios,
    Cactus Dan



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

    On 20/11/2008 at 10:17, xxxxxxxx wrote:

    To add here, some things seem to have everything as parameters and are not accessible by the BaseContainer. Already mentioned was BaseDraw. The same goes for BaseChannels as well.

    Some of this discovering whether to use GetDataInstance() or GetParameter() will be trial and error. Start with the BaseContainer and if that doesn't work then it probably has another access methodology.



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

    On 20/11/2008 at 10:29, xxxxxxxx wrote:

    Hi!

    Okay, seems I have no other chance as try and error. Last point which I wanted to know:

    User datas can only be changed, set and added by using (BaseObject* )->GetDynamicDescription(), correct?

    Thanks, Shawni..


Log in to reply