How to add UserData with SDK



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

    On 23/07/2007 at 13:49, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   R10 
    Platform:      Mac OSX  ; 
    Language(s) :

    ---------
    Hello all,
    I'm trying to add userdata to a custom object through the sdk, I've looked at DynamicDescription, but have no idea on how to setup the whole thing.
    please help.



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

    On 23/07/2007 at 15:05, xxxxxxxx wrote:

    Is this custom object your plugin? If so, you don't even need userdata - just add GetDDescription() to your ObjectData class and add the dynamic data/types there.

    The basic way this works is that you fill in the static description - description->LoadDescription(node->GetType()). You then add dynamic ones by setting up the datatype, a container with description configuration parameters, and calling description->SetParameter();

    Here is a short example (probably not the best example, but a start to understanding) :

    // NodeData.GetDDescription - Descriptions and Parameters  
    //*---------------------------------------------------------------------------*  
    Bool IPPCamFrame::GetDDescription(GeListNode* node, Description* description, LONG& flags)  
    //*---------------------------------------------------------------------------*  
    {  
         if (!(node && description))               return FALSE;  
    // Load static descriptions first (!)  
         if (!description->LoadDescription(node->GetType())) return FALSE;  
      
         // Prepare data  
         BaseDocument* doc =          node->GetDocument();  
         if (!doc)     return FALSE;  
         BaseTag* tag =          static_cast<BaseTag*>(node);  
         if (!tag)     return FALSE;  
         BaseContainer* tbc =          tag->GetDataInstance();  
         if (!tbc)     return FALSE;  
      
         foListBC.FlushAll();  
         bpListBC.FlushAll();  
         foListBC.SetString(0L, "- NONE -");  
         bpListBC.SetString(0L, "- NONE -");  
         foIndex =     1L;  
         bpIndex =     1L;  
         foSelect =     tbc->GetLong(IPPCAMFRAME_FOSELECT);  
         bpSelect =     tbc->GetLong(IPPCAMFRAME_BPSELECT);  
      
         // Catalog all iPP Figures in Document  
         CatalogIPPFigures(doc->GetFirstObject());  
      
         // Update Drop-down lists  
         foComboBC.SetContainer(DESC_CYCLE,          foListBC);  
         bpComboBC.SetContainer(DESC_CYCLE,          bpListBC);  
         tbc->SetLong(IPPCAMFRAME_FOCOMBO,          foSelect);  
         tbc->SetLong(IPPCAMFRAME_BPCOMBO,          bpSelect);  
    // Add the dynamic descriptions for display in the A.M.  
    // The first arg is the dynamic ID, the second the configuration container, the last the parent GROUP under which the description is added  
         if (!description->SetParameter(DescLevel(IPPCAMFRAME_FOCOMBO,DTYPE_LONG,0),     foComboBC, DescID(ID_TAGPROPERTIES)))     return FALSE;  
         if (!description->SetParameter(DescLevel(IPPCAMFRAME_BPCOMBO,DTYPE_LONG,0),     bpComboBC, DescID(ID_TAGPROPERTIES)))     return FALSE;  
      
    // Set flags: the first flags should always appear when successfull  
         flags |=     DESCFLAGS_DESC_LOADED|DESCFLAGS_DESC_RECURSIONLOCK;  
      
    // This MUST BE CALLED!  
         return SUPER::GetDDescription(node,description,flags);  
    }
    


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

    On 23/07/2007 at 17:48, xxxxxxxx wrote:

    thanks kuroyume0161 I'm a newbie at this stuff.

    I have this working the node is created and I can see it in the property inspector of the object, except that I cannot set the actual string data.
    maybe I'm using the wrong tag id? CUSTOMGUI_STRING

    the reason I'm using the userdata is because I won't be able to retrieve the data from this object with coffee.

    so now the question is how do I set the actual string data?

    thanks

      
    Bool MyObject::Init(GeListNode *node) {       
         BaseObject          *op   = (BaseObject* )node;  
         BaseContainer *data = op->GetDataInstance();  
         DynamicDescription* ddesc = op->GetDynamicDescription();  
           
         BaseContainer bc;  
         bc.SetString(DESC_NAME, "AI Map Info");  
         bc.SetString(DESC_SHORT_NAME, "AI Map Info");  
         bc.SetLong(DESC_CUSTOMGUI, CUSTOMGUI_STRINGMULTI);  
         bc.SetString(CUSTOMGUI_STRING, "test string data");  
         DescID id = ddesc->Alloc(bc);  
           
         ddesc->Set(id, bc);  
           
         return TRUE;  
    }  
    


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

    On 23/07/2007 at 20:05, xxxxxxxx wrote:

    If you are doing this in Init() why can't you just use a static description in the .h and .res files? Then you could set the string and get it using whatever (including COFFEE).

    But if it is truly a dynamic description, doing it in Init() this way will not work. It must be done in GetDDescription().

    The gui type for a text edit is CUSTOMGUI_STRING. But there is more to this. The way you are doing it (which is much more work if a static description), you would need to do this as well:

    BaseContainer bc = GetCustomDataTypeDefault(DTYPE_STRING);  
    bc.SetString(DESC_NAME, "AI Map Info");  
    bc.SetString(DESC_SHORT_NAME, "AI Map Info");  
    bc.SetLong(DESC_CUSTOMGUI, CUSTOMGUI_STRING);  
    Description* desription;  
    op->GetDescription(description, 0L);  
    // This adds the description element to the Description  
    description->SetParameter(DescLevel(??,DTYPE_STRING,0),bc,DESC_ROOT);
    

    The ?? is because you MUST set an ID value (LONG) for the description element that is unique for this node. The static ones are usually defined in the plugin object header (Omyplugin.h or Tmyplugin.h). That is how you access the description resource - and it is the ONLY way. Cinema 4D runs on IDs - and for descriptions, it lives off of them. ;)

    To set the actual description value, you need to get the BaseContainer for the node object (op) and set using that:

    BaseContainer* obc = op->GetDataInstance();  
    obc->SetString(??, "test string data");
    

    Do the same to get the value:

    String str = obc->GetString(??);
    


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

    On 24/07/2007 at 07:29, xxxxxxxx wrote:

    I got it now that's what I needed :)
    I'll try to move the description stuff to the .h file as you suggested, I may come back later with more questions ;)

    thanks again!


Log in to reply