Jump to content

  • “Great art picks up where nature ends.”  Marc Chagall 

Sign in to follow this  
SolarPH

Python Node Date and Time Comparison

Recommended Posts

Good Day!

So, I do search some raw python codes, but there are so many, but I can't find one that is specifically made for Cinema4D R14.

 

Do anyone know how to get the current device date and time and compare it with a time that I have set?

I do want to use it in making a Demo Version of a rig I was making, but since majority of it's parts do work under Python Scripts inside Xpresso tags, I think I can use that certain part of code to disable the main module that connects the parts to make the rig work at all.

 

Also, is there any way to print how many days remaining before the set datetime to arrive?

For example, I want to print "You have " + days + " days remaining before this rig set expires".

 

I can print it in console, but I don't know how it will be included in a string output

Share this post


Link to post
Share on other sites

  • Topic Author
  • Actually, nevermind. I just got it solved by my own.

    But since it's here already, I'll share how to get days only to print in the string. You can also use some parts of it for logic script building.image.png.3c654e9ddc0749c56aca70284bc77fe4.png

    import c4d
    import datetime
    #Welcome to the world of Python
    
    
    def main():
        global Output1
        
        starttrial = datetime.date.today() # Date on your computer
        endtrial = datetime.date(2019,9,1) # Date on when it expires
        
        TimeComparison = endtrial - starttrial # Date comparison
        
        Output1 = "You only have " + (str(TimeComparison.days)) + " days before this rig expires..." #Print as String

     

    Share this post


    Link to post
    Share on other sites

    You could use a message box

     

    import c4d
    from c4d import gui
    
    def main():
        gui.MessageDialog('only 10 days left')

    as in 'Hello World' ...

    Share this post


    Link to post
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.
    Note: Your post will require moderator approval before it will be visible.

    Guest
    Reply to this topic...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    Sign in to follow this  

    • BLOGS / NEWS & SPECIAL ANNOUNCEMENTS

    About Us

    C4D Cafe is the largest Cinema 4D community. We provide facilities for discussion, showcasing and learning our favourite software.
    Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, watch tutorials directly from our video gallery,  get your own private messenger, post and upload images, manage your profile and much more. If you need to find solution to your problem or otherwise ask for help, C4D Cafe is the right place to be for learning 3D.  :cowboypistol:

    ×
    ×
    • Create New...