lisa-marie mueller

lisa-marie mueller

bullet pont

randomize curtain wall panel types link

July 24, 2020

typewriter, Cuckoo Clock, marbles in red Now that we have all the panel types that we gathered last week, we’ll want to randomize the panel types. For this plug-in, I limited the input to a maximum of five different panel types which will each be a different material. The five panel types are a user input in our UI and the user will also be able determine the mix of each material.

goals and considerations

  • create the grids by entering width and height information
  • randomly delete curtain wall grids but allow for user configurations
  • randomize curtain wall panel materials
  • option to remove mullions

gather and unpin panels

We are going to create a new method called RandomizePanelMaterial that does not return anything. The parameters we need for our method are the Document, UIDocument, and the Curtainwall we are randomizing. We also need the percentage of each material (mtl#Max) and the curtain wall panel type (mtl#) both of which the user selected. To start, we need to get all the ElementIds of the panels on our curtain wall and add them to a list. Then we can use the GetElement method with the ElementIds as a parameter to return the element object. This way, we can iterate on each panel. Before we can change the type, we will need to unpin each panel.

randomize types

In addition to getting our curtain wall panel at the beginning of our foreach loop, we will also need to get a random number. Based on the user selected material mix, each panel has a percentage represented by an integer between 1 and 100. We have a maximum of five panel types but if the user has fewer than five panel types, the values for the unused types will simply be zero. In our execute method, we calculate our mtlMax variable. All we do is add the previous materials’ percentages to the current material. For example if we have material A, B, and C with the mix 10, 30, 60, mtlMax1 would be 10, mtlMax2 would be 40, and mtlMax3 would be 100. Our random number will be between 0 and 99. In order to assign the material, we will see in what range the random number if. If it is between 0 and 10, we will assign material A. If it is between 11 and 30, we will assign material B. If it is between 31 and 100, we will assign material C.


Now that we have randomized the panel materials, we have one last step before looking at a few things in the UI. Next week, we’ll incorporate the option to delete the mullions.


If you want to learn to code and don’t know where to start check out my posts about Steps to Learn to Code [for architects and designers] Part 1 and Part 2.

Revit API Docs

bullet pont

recommended next