How do I use DateTimeData?



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

    On 31/07/2011 at 05:40, xxxxxxxx wrote:

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

    ---------
    Hi there,

    might be a simple solution, but I don't get it at the moment.
    I have created a Tag that includes a DateTime field:

      
    DATETIME TORBIT_START   
    {   
    TIME_CONTROL;   
    DATE_CONTROL;   
    COMPACT_MODE;   
    }   
    

    Now I want to initalize this Control with the current time and date. What I tried was this (but it didn't work) :

      
    BaseTag* tag = (BaseTag* )node;   
    BaseContainer* data = tag->GetDataInstance();   
    DateTimeData *dtd = (DateTimeData* )data->GetCustomDataType(TORBIT_START, DATETIME_DATA);   
    if (dtd)   
    {   
    tagDateTime dt = dtd->GetDateTime();   
    DateTimeNow(dt);     // Aktuelle Zeit setzen   
    dtd->SetDateTime(&dt;);   
    }   
    

    With this I did not even get the datatype, i.e. dtd remains NULL.

    Would be great if someone could help!

    Juergen



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

    On 31/07/2011 at 10:13, xxxxxxxx wrote:

    This code should work:

      
    BaseContainer *pbc = ((BaseTag* )node)->GetDataInstance();  
      
    GeData dTime(DATETIME_DATA, DEFAULTVALUE);  
    DateTimeData* pDateTimeData = (DateTimeData* )dTime.GetCustomDataType(DATETIME_DATA);  
    if (pDateTimeData)  
    {  
      DateTime dt;  
      GetDateTimeNow(dt);  
      pDateTimeData->SetDateTime(dt);  
      pbc->SetData(MY_DATETIME, dTime);  
    }  
    

    cheers,
    Matthias



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

    On 31/07/2011 at 11:54, xxxxxxxx wrote:

    Works. Thanks a lot!

    Quick question again: is there something like the DateTime description element also for dialogs?

    Juergen



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

    On 11/08/2011 at 05:29, xxxxxxxx wrote:

    Custom GUIs can be added to dialogs via GeDialog::AddCustomGui. Some custom GUIs don't have any access functions though and some don't seem to work in dialogs. You have to check if it's working for the DateTime GUI.

    Example how to add the DateTime GUI.

      
    class MyDialog : public GeDialog  
    {  
      public:  
          MyDialog() { gad = NULL; }  
          virtual Bool CreateLayout(void);  
          virtual Bool InitValues(void);  
          virtual Bool Command(LONG id,const BaseContainer &msg);  
      
      private:  
          DateTimeControl *gad;  
    };  
      
    Bool MyDialog::CreateLayout()  
    {  
      Bool res = GeDialog::CreateLayout();  
      
      SetTitle("DateTime Test");  
      
      GroupBegin(0,BFH_SCALEFIT|BFV_SCALEFIT,0,1,String(),0);  
      
      // fill the container with the custom GUI's values (DATETIME_TIME_CONTROL, DATETIME_DATE_CONTROL, etc.)  
      BaseContainer customgui;  
      
      // adds the DateTime GUI to the dialog  
      gad = (DateTimeControl* )AddCustomGui(10000,DATETIME_GUI,String(),BFH_SCALEFIT|BFV_SCALEFIT,0,0,customgui);  
      
      GroupEnd();  
      
      return res;  
    }  
      
    ...  
    

    cheers,
    Matthias


Log in to reply