# Curtain wall panel type - randomization

This is my first real experiment the dynamo of something of production. What I would like to do is select a curtain wall which is in my revit 2015 project. Then run a script which will randomize the type of curtain wall panel (3 or 4 different curtain panel types).

Conceptually this seamed simple, if any one could give some brief guidance of how to acheive this function (or let me know that it won’t work) it would be great.

thoughts?

Hi,

It is a bit difficult to respond in a so abstract case. But you can make a list with the family types and call the index via Math.Random.

the function to take the type of panel via random
def RandomType (ListOfTypes:var)
{
NumTypes=Count(ListOfTypes);
NIndexPre=Math.Random(0,(NumTypes-1));
//To get the integer
NIndex=Math.Round(NIndexPre);

return=ListOfTypes[NIndex];
}

You can call the function when you make the revit component. Or make a function that include the component, like for example

def RandomPanel (Quad:var,ListOfTypes:var)
{
NumTypes=Count(ListOfTypes);
NIndexPre=Math.Random(0,(NumTypes-1));
//To get the integer
NIndex=Math.Round(NIndexPre);

return=AdaptiveComponent.ByPoints(Quad,ListOfTypes[NIndex]);
}

Thanks for this example, Eduardo. I’ve done a few similar things before as well, for example, to place an instance of one of N types of families. If the span is in some range, place the beam family type at index 0, if the span is larger than something else, place the family type at index 1, etc.

Nice touch defining a DesignScript function!

Random number generation is awesome, and more complicated than it looks. My son has been using a wicked random generation tool in MineCraft involving a chicken in a box with a Redstone pressure plate.

The above script is cool, I haven’t used the function definition that much. But one problem I THINK is that it is going to going to disproportionately ignore Index 0 when multiplying by Count(ListOfTypes) and then rounding. This will make for very few instances where rounding down to 0 happens.

Here’s my attempt with Remap Range in the operation. Putting an integer slider into the mix with random taking a “seed” value allows you to generate multiple iterations of random numbers (the warning messages are about converting Doubles to integers, which is not really a problem here) and scroll through hundereds of random variations.

I think this is actually a little better:

The Remap Range is now from -0.5 to 3.4 (instead of 0 to 3), which gives an equal amount of parametric “space” around 0, 1, 2, and 3 for the rounding to happen within

Trying to get curtain wall panels to randomly select one of 4 panel types using your great advice above.

This is the script I have so far, but can’t find a way to finish it off. I am aware that I have 2 input methods for the index list - I was trying to spread the techniques.

Any thoughts on how to resolve this? Would be hugely appreciated