Set Element Types
0:00 / 0:00
1-4 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
- Click the “Revit” category in the node library then click “Selection”.
- Click the “Categories” node to add it to your script.
- Click the dropdown on the “Categories” node then scroll down and select the “Curtain Panels” category.
- Back in the node library, click the “All Elements of Category” node to add it to your script.
- Connect the output from the “Categories” node to the “Category” input of the All Elements of Category node.
- 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
- 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.
- Click the List category in the node library then click the “Inspect” sub-category. Click the Count node to add it to your script.
- Connect the output from the All Elements of Category node to the “list” input of the List.Count node.
- 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
- Click the Revit category in the node library. Click the Elements sub-category then click Element.
- Click the SetParameterByName node to add it to your script.
- Connect the “Elements” output from the All Elements of Category node to the “element” input of the Element.SetParameterByName node.
- 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:
- Connect the output from the Code Block to the “parameterName” input on the Element.SetParameterByName node.
- 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.
- Switch to Revit to see the new curtain panels.
- Change the value of the Number Slider to generate a new random pattern.