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

    Python effector using random [SOLVED]

    Scheduled Pinned Locked Moved PYTHON Development
    4 Posts 0 Posters 360 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

      On 08/03/2017 at 19:04, xxxxxxxx wrote:

      Hi,

      I am using random values in my Python effector. The tag refreshes every frame or every change in the interface so I get different values constantly. Say I want to stick with the first random values I get, how can I compare those first values with the following values in the python effector, so it always stays the same?

      Thanks!

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 09/03/2017 at 01:04, xxxxxxxx wrote:

        You can implement a seed value. And according to this seed the "random" value will be alway the same.

        If you have your own "random" function take it like an hashing function who only return number ๐Ÿ˜‰
        If you use the random module from python simply do

        import random
          
        seed = random.seed(your seed (can be exposed for more choice for the user)
        print random.random()
        

        A good readย https://pymotw.com/2/random/ ๐Ÿ˜‰
        Hope it's help you.

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 09/03/2017 at 06:54, xxxxxxxx wrote:

          Hi,

          gr4ph0s was too fast for me. That's basically what I wanted to post as well.
          Just a small additional idea. Depending on your needs you could for example derive the seed value from the current frame to get a different random value per frame. Or you could have a user parameter for the seed, that would be saved with the scene, so the user can change the random value but it stays constant with the scene.

          One thing I was confused about, you are talking about the Python Effector and on the other hand about a tag refreshing every frame. So if you keep having problems with this, you probably should shed some light here.

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 09/03/2017 at 12:34, xxxxxxxx wrote:

            Thanks so much, gr4ph0s and Andreas! It worked perfect!

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