Getting user data



  • On 08/12/2016 at 09:26, xxxxxxxx wrote:

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

    ---------
    Ok, I am lost on how to get the userdata of an object.
    I am trying to get userdata # 11 (float) and userdata #30(gradient).
    The float seems to work, but when I try to do the same for the gradient, it fails.

    The compiler tells me 'udEntry': redefinition; multiple initialization.

    Here is the code.

    Int32 gizmo;
    GeData d;
      
    BaseObject* c4domeObj = GetActiveDocument()->SearchObject("obj with userdata");
    if (!c4domeObj) return FALSE;
    DynamicDescription *dd = obj->GetDynamicDescription();
    if(!dd) return FALSE; 
      
      
    gizmo = 11;			//brightness
    DescID udEntry(DescLevel(ID_USERDATA, DTYPE_SUBCONTAINER, 0), DescLevel(gizmo));
    obj->GetParameter(udEntry, d, DESCFLAGS_GET_0);
    GePrint("Brightness: " + String::FloatToString(d.GetFloat()));
      
    //get the gradient custom data
    gizmo = 30;			//gradient
    DescID udEntry(DescLevel(ID_USERDATA, DTYPE_SUBCONTAINER, 0), DescLevel(gizmo));
    obj->GetParameter(udEntry, d, DESCFLAGS_GET_0);
    Gradient* gd = (Gradient* )d.GetCustomDataType(CUSTOMDATATYPE_GRADIENT);
      
    Int32 kcnt = gd->GetKnotCount();
    

    It feels, I do not completely understand what is going on.

    Is there not a simple routine to readthe user data for a specific number?

    -Pim



  • On 09/12/2016 at 05:09, xxxxxxxx wrote:

    I solved it by looking for the name instead of the id using BrowseGetNext.

    -Pim



  • On 09/12/2016 at 05:15, xxxxxxxx wrote:

    Hi Pim,

    the issue has nothing to do with userdata. It's actually as the compiler says, you defined the variable udEntry twice.


Log in to reply