Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Set DateTime Data from strings

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 415 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

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

      On 20/08/2011 at 07:57, xxxxxxxx wrote:

      Trying to set DateTime from external file (exif)
      Any pointer how to format the DateTimeData() object?
      What I have are strings that need to go "into" the:
      mytimedata = DateTimeData()

      The code here prints a skyobject datetime, I'd like to go
      the other way using my strings as base.

      Cheers
      Lennart

        
      import c4d   
      from c4d import gui, DateTimeData   
        
      def main() :   
          sky    = doc.GetFirstObject()   
          skybc = sky.GetDataInstance()   
          skydtd = skybc.GetData(c4d.SKY_DATE_TIME)   
          print DateTimeData.GetDateTime(skydtd)   
      
      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

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

        On 21/08/2011 at 04:53, xxxxxxxx wrote:

        Hi, here is a sample code how to parse a string into a DateTimeData object.
        And here you get a list of the directives for the string parser (strptime) :
        http://docs.python.org/library/datetime.html#strftime-strptime-behavior

        import c4d
        import datetime
          
        from datetime import datetime
        from c4d import gui, DateTimeData
          
        def main() :
            sky    = doc.GetFirstObject()
            skybc  = sky.GetDataInstance()
          
            td=datetime.strptime('16.07.2011 03:37:12',"%d.%m.%Y %H:%M:%S")
            
            dtd=DateTimeData()
            #set the datetime.datetime object to the DateTimeData object
            dtd.SetDateTime(td)
          
            skybc.SetData(c4d.SKY_DATE_TIME,dtd)
          
            c4d.EventAdd()
          
        main()
        
        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

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

          On 21/08/2011 at 05:31, xxxxxxxx wrote:

          Great, many thanks.

          Cheers
          Lennart

          1 Reply Last reply Reply Quote 0
          • First post
            Last post