Design with random values



  • Hello, I have a little programming design problem : I made a design that randomly builds a circular labyrinth. It has two modes, one to view the design in 3d as it would be when finished, and one in 2d with the background to lasercut. The idea is to first view 3d mode and update till the random arrangement looks good, then switch to 2d to save the pattern to .svg to cut it. My problem is that as the script uses Math.random(), when you switch from 3d to 2d, the design will change, is there a way to be able to use designs with random values that would not be lost when switching parameters (mode here) ?

    The script is here : https://openjscad.org/#https://raw.githubusercontent.com/gilboonet/designs/master/laby_rond.jscad



  • Thank you. I will try something similar, it just needs to add a parameter to choose a design number, if the table of random values doesn't have values for this number they are randomly feeded, else they are used for the rendering. Such "mechanism" could be handy for designs using both random values and more than one viewing mode.


  • administrators

    Maybe you could build a table of randon values while in 3D mode, then save those for use by the 2D mode.