by Dennis Collin
Dynamo scripting in Revit can be used to perform many different tasks. I am frequently asked if elements can be numbered in a more controlled way, including elements like Doors, Windows, Curtain Panels, Foundations etc, having them numbered according to level and position rather than the normal creation order, or a blank value depending upon the category.
Fig 1. Accessing Dynamo’s Editor and Script Player
My answer to the question is often, yes, but we need to look at programming or Dynamo scripting. Dynamo is an attractive solution because it’s easier to learn than C and many complex tasks can be achieved with basic scripting knowledge.
Fig 2. Dynamo scripting is visual, with the complete script as shown.
This script is designed to be flexible and can renumber component elements from most disciplines, Architecture, Structures and MEP, and anything in-between. The Dynamo Script editor is graphical in nature and can be accessed from the Manage tab on the Ribbon menu.
The first task is to create a node that enables users to select a category and include all elements of that category in a selection. In the graphic, door categories are selected, but valid options would also include elements such as Windows, Rooms or Mechanical Equipment.
Fig 3. The first step is to tell Dynamo what to count and to sort the list by Level!
Next, we need to sort the elements by a particular parameter. This is achieved by feeding in a string value, in this case the Level reference to the very useful GetParameterByName Node. This will also sort the elements into a logical list to process. It is good practice to group the various nodes and colour code them, to make fault tracing and using the script easier.
Fig 4. Collecting level information and generating an element prefix list.
Many elements in projects need to be numbered by floor or as Revit likes to think by Level. The categories node is used to select all the levels and allocate a number to each level floor along with a separator. This is then fed into a Dictionary node so that elements on the Ground Floor are prefaced with a “1-“, the First Floor with a “2-“ etc. The values for the prefaces are entered via a Code Block node. These values are combined with a simple combinator. A count node ensures that this script will support projects containing any number of floors.
Fig 5. Elements on levels harvested and allocated a list of prefaces according to floor.
A second group harvests the Level name and maps them to the numeric prefix list.
Each element requires a unique identifying number. This is done by generating a range of numbers starting from 1, finishing with the number of items on that floor, and then padding this number with some leading zeroes so that a consistent tidy number can be assigned to each element such as a door, i.e. 001, 002, 003 etc.
Fig 6. Generating a range of numbers that can be allocated to each element.
The final step is to combine each sequence of numbers from their respective floors to their corresponding prefix, so that a ground floor element reads 1-001, 1-002 etc. rather than 001 etc.
Fig 7. A Boolean Node permits the user to decide whether a prefix letter is added to the Mark or not.
A Boolean node enables users to choose whether their sorted numbered elements require a prefix. This is defined with two string inputs connected to the true and false ports of a conditional if node. The result is then fed to the SetParameterByName node which writes the final value to the Mark parameter name.
Running the script shows that it works and applies the selected options to the parameters as expected! In this example Door elements are shown, but the same script could be applied to other categories as needed.
Dynamo Scripting is a useful tool which performs tedious and repetitive tasks in Revit and other software like FormIt and Civil 3D, which also have Dynamo scripting capabilities.
Fig 8. Door Schedule with new mark values for doors!
I will post separately about other applications of Dynamo Scripting in Revit, such as automated tag placement, but in the meantime some example tasks and capabilities of what Dynamo can do, can be found Dynamo too!
Hozzászólások (0 hozzászólás)