Set Family Types by Number
0:00 / 0:00
Set Family Types by Number – Practice Exercise
In this exercise, we will assign family types to the random numbers in Dynamo.
Task 1: Add Switch node and define cases
- Navigate to Clockwork in the node library then click the “Script” category.
- In the “Script” category, click “Control Flow” then click the Switch node to add it to your script.
- To setup the Switch node, you need to provide a list of cases, a list of values, and a default value.
- Double-click on an empty part of screen to add a code block. Enter the following in the code block: 1 . . 5 followed by a semicolon as show below. This will create a list of numbers from 1 to 5.
- Hover over the lower right-hand corner of the Code Block to see the preview from the node.
- Connect the output from the code block to the “Cases” input of the Switch node.
Task 3: Create a list of family types
- Next, click the List category in the node library. Click the “Generate” heading and click the List Create node to add it to your script.
- Click the “+” button four times to add four additional inputs.
- In the node library, click the Revit category then click the “Selection” heading. Click the “Family Types” node five times to add three instances of the node to your script.
- Select a different System Panel type in each of the Family Types node. The sample file contains System Panel Types from “Type 1” through “Type 5”. These will be the families define the curtain panel in Revit.
- Connect the outputs from the Family Type nodes to the List Create inputs. The first node will correspond to number 1 in the random number list. The second to number 2 in the list and so on.
- Connect the output of the List Create node to the “Values” input of the Switch node.
Task 4: Finishing up
- Connect the output from the first Family Types node to the “Default” input of the Switch node. This is the value that will be used if a value does not match 1, 2, 3, 4 or 5.
- Connect the output from the RandomList.AsIntegers node to the “Check” input of the Switch node.
- Type “watch” in the node library search bar and click to add a Watch node to the script.
- Connect the Watch node to the output of the Switch node.
- Verify that the family types match the number pattern.
- Your script should look like this:
Task 5: Group the Nodes
- Pick a spot in the upper left of the Dynamo workspace and click and hold the left mouse button.
- Drag the selection window to the lower right-hand corner to select all the nodes.
- Right-click and click the “Create Group” option.
- Double click the group title and type “Set Families”.
- Right-click the group and select a new color.
- In the menu bar, click Save to save your Dynamo script file.