Can I refresh RND() ?

Home Forums Problems and solutions in GDL Object design Can I refresh RND() ?

This topic contains 3 replies, has 2 voices, and was last updated by  James Goode 3 weeks, 5 days ago.

  • Author
    Posts
  • #18390

    James Goode
    Participant

    I have list of potential options in an object that I would like to have change whenever our template is opened. The easiest way I thought of was to just use rnd to pick between 0 and however many image options that we have. However it doesn’t refresh when a new instance is opened or if I use SHIFT+CTRL+ALT+R like I want it to.

    Is there any way that I can get this to work as intended? Is there a way to automatically create a new RND number whenever the object is ‘Updated’ or ‘Refreshed’?

    Thanks

  • #18392

    Péter Baksa
    Participant

    RND returns the same sequence of random numbers in each run. The sequence is different for each placed object. This makes it possible to create randomized objects (eg. trees) that look the same on different 3d views (different sections, animated fly-through rendering).

    It is possible to get the time using REQUEST(“DateTime”,…).
    You can convert the returned string to a number with SPLIT.
    Use that in a loop to get different number of random numbers in each run.

    n = REQUEST ("DateTime", "%S", datetimestring)
    split(datetimestring, "%n", rndseed)
    for i = 1 to rndseed + 1
    	random = int(rnd(100))
    next i
    text2 0,0, str(random, 1, 0)

    Péter Baksa
    Software Engineer, Library Team
    GRAPHISOFT SE

  • #18393

    James Goode
    Participant

    Hello,

    Thanks for the reply. How could I apply this to show a different image in 2D upon each refresh?
    Say for example I have a 8 different images that I’d like to show

    Thanks

  • #18394

    James Goode
    Participant

    No worries,

    I’ve figured it out. Thanks for your help!

You must be logged in to reply to this topic.