On a theatre model I need to randomize the seat family instances with its types so that they don’t look all the same. There are four types (each one with a different person on the seat). Initially the instances can be equally divided a quarter of each type and then shuffled in dynamo.
Using Vikram Subbaiah’s ‘All Elements of Family Name’ and ‘Manage.RandomizeOrder’ I was able to randomize the list of seats but could not apply the list result back to Revit.
FamilyInstance.SetType expects a single family type and doesn’t seem to help.
Thanks for your help erfajo This is quite a sophisticated definition!
It feels like the FamilyInstance.SetType node is where my problem is.
The familyInstance input is finding all instances of the family - if the input in familyType is a type picked using ‘Family Types’ it replaces all instances with this type. However I’m not being able to define the random familyType from the randomized list (probably because the indices change but the association with the element ID remain the same?).
List.Shuffle to change the order. You can use a code block and a number slider to trigger new values.
Count the seats.
Create a List of the four family types.
Use a List.OfRepeatedItems node to make each of the four family types about 3/8 of the total seat count (this will enable a better randomization by allowing an uneven count - you can set it to 1/4 if you want even counts though)
Flatten the repeated items in number 4.
Ensure the count of seats matches the count of family types by adding/dropping types as needed.
FamilyInstance.SetType node with @L1 on each input - this will force the node to evaluate matching depth lists individually.
Thanks for your solution Jacob, I reached a passable definition late on Friday which was doing the trick using Element.SetParameterByName, also without working with the correct number of seats and then cropping the list to the amount desired. It felt like it wouldn’t do a good job for hundreds of seats, worked fine for the test with 16 though. See below:
When I need to create a random list of specified objects I usually go with one of two methods. The first is similar to what @JacobSmall mentioned, and the second creates a random list of indices that I use to select my specified objects.