Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

Can I refresh RND() ?

JGoode
Advocate
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
ArchiCAD 23

Windows 10
3 REPLIES 3
David Maudlin
Virtuoso
JGoode:

If I recall correctly, this function does not generate a random number, it selects from a predefined list of numbers, so the initial result is the same. When needing randomness, I have used something like the third decimal place of the object's x or y location (seemingly random number between 0 to 9) to generate a random number.

David
David Maudlin / Architect
www.davidmaudlin.com
Digital Architecture
AC27 USA • iMac 27" 4.0GHz Quad-core i7 OSX11 | 24 gb ram • MacBook Pro M3 Pro | 36 gb ram OSX14
Karl Ottenstein
Moderator
I recommend reading this thread from 2004 - little has changed since then, but two solutions are given for (pseudo) random object behavior. (The main change since then is a limitation on what can appear in the parameter script etc)

https://archicad-talk.graphisoft.com/viewtopic.php?f=6&t=2191
One of the forum moderators
AC 27 USA and earlier   •   macOS Ventura 13.6.6, MacBook Pro M2 Max 12CPU/30GPU cores, 32GB
Lingwisyer
Guru
The solution proposed over on the GDL forums for anyone who stumbles into here.

Péter wrote:
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)

Which I assume that you then pull a number from.

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win10 | R5 2600 | 16GB | GTX1660