• Return to module overview

Set Element Types

0:00 / 0:00

Change Family Types – Practice Exercise

In this exercise, we will change the curtain panel types based on the list of random numbers.

Task 1: Select all curtain panels in Revit

  1. Click the “Revit” category in the node library then click “Selection”.
  2. Click the “Categories” node to add it to your script.
  3. Click the dropdown on the “Categories” node then scroll down and select the “Curtain Panels” category. 
  4. Back in the node library, click the “All Elements of Category” node to add it to your script.
  5. Connect the output from the “Categories” node to the “Category” input of the All Elements of Category node.
  6. Hover over the lower right-hand corner of the All Elements of Category node to see a preview of all the selected curtain panels.

Task 2: Set number of random numbers to generate

  1. In an earlier lesson, we used a fixed value to 100 to determine how many random numbers to generate. Now that you have selected all the curtain panels, you can use the count of the curtain panels to set the number of random numbers.
  2. Click the List category in the node library then click the “Inspect” sub-category. Click the Count node to add it to your script.
  3. Connect the output from the All Elements of Category node to the “list” input of the List.Count node. 
  4. Connect the “count” output from List.Count to the “amount” input on the RandomList.AsIntegers node you added in lesson 2. This will generate enough random numbers for all the curtain panels in the model.

Task 3: Change curtain panel types

  1. Click the Revit category in the node library. Click the Elements sub-category then click Element.
  2. Click the SetParameterByName node to add it to your script.
  3. Connect the “Elements” output from the All Elements of Category node to the “element” input of the Element.SetParameterByName node.
  4. Double click on empty space to create a Code Block. Type a quotation mark followed by the word Type and another quotation mark. End the line with a semi-colon. Your code block should look as follows:



  5. Connect the output from the Code Block to the “parameterName” input on the Element.SetParameterByName node.
  6. Connect the output from the Switch node to the “value” input of the Element.SetParameterByName node. Dynamo will take a few moments to switch all the curtain panels.
  7. Switch to Revit to see the new curtain panels.
  8. Change the value of the Number Slider to generate a new random pattern.

  • Return to module overview