Grids in Revit help you to organize your design, with a coordinate in each grid bubble you can communicate with different project members about the locations of elements. When placing grids for multiple other buildings inside your project, it can be a tedious and time-consuming task to renumber grids in Revit.
Autodesk Revit doesn’t have a feature to renumber the grids automatically by itself. It does only continue from your last number or letter. Fortunately, we can automate this with the help of a Dynamo script, saving time and reducing mistakes.
In this article, we are going to take a look at how to Renumber Grids automatically with the help of Dynamo and a little part of Python scripting.
Dynamo – Renumber Grid Bubbles
Let’s take a look at how to automate the renumbering of grids with the help of Dynamo. The script below can be used to Renumber horizontal and vertical Grids automatically in Revit. In addition, I have added different input variables to make it more user-friendly, such as Reverse Grid order, and the possibility of adding a Prefix to the label.
Tip
Make sure that you also read the article about hiding multiple grid bubbles with Dynamo
Please note that this is just an example of a basic script that you can customize to your own requirements. Also, the script does not support the use of curved grids.
Dynamo – Script
Before we start make sure that you have the following two packages installed in Dynamo:
- Clockwork for Dynamo 2.x
- Data-Shapes
Below you will see the overview of a Dynamo script. I have split the script into five parts to explain what each part is doing. Besides that, there are two parts, parts 4 and 5, that are written in Python.

1. Input Variables
The first part of the script allows you to select the desired output of the script such as the reverse order for the horizontal and vertical grids or adding a Prefix label to the grids.
You can set the output with a Boolean (True or False) for the reverse order and/or prefix.

2. Grid Labels
Each grid in your model requires a unique label. In this part of the script, we are going to create a list of numbers and a list of characters. In the example, I have created a list of numbers from 1 to 100 and a list of characters. You can change the maximum numbers to your own requirements. From part 2, we can put the number as input to the IN[2] at part 5 Renumbering Grids, which will number all vertical grids in this case.

The Character.FromNumber node from the Clockwork package will convert numbers to letters, where 1 = A, 2 = B, 27 = AA, 28 = AB, etc. From part 2, we can put the characters as input to the IN[3] at part 5 Renumbering Grids, which will put a character for all horizontal grids in this case.
3. Select Grids
Part 3 of the script is pretty straightforward – you can only select grids as input. In Revit, you can select multiple elements by dragging, but only grids will be selected due to the use of Select Model Elements of Category node from Data-Shapes. Don’t forget to click on Finish after dragging.

4. Separate Grids Horizontally and Vertically
In part 4, all grids that are gathered in part 3 will go as input into IN[0] through a Python script, which will then separate them into a list of horizontal and vertical grids.

The script will loop through each grid and filter out all curved grids. The vector represents the direction of the curve by subtracting the second endpoint from the first. Then the angle will be calculated between the vector and the Y-axis. As the results are in Radians by default, we can convert this to degrees by using the formula: (180/π
).
The grid lines whose angle is between 45, and 135 degrees, or 225, and 315 degrees will be stored as Horizontal grids. All the other grid lines will be stored as Vertical grids.
# Load the Python Standard and DesignScript Libraries import clr #Import RevitAPI clr.AddReference("RevitAPI") import Autodesk.Revit.DB as DB import math # The inputs to this node will be stored as a list in the IN variables. grids = UnwrapElement(IN[0]) reverse_horizontal = IN[1] reverse_vertical = IN[2] # Separate gridlines by orientation def separate_by_orientation(grids): h_grids = [] v_grids = [] for grid in grids: if isinstance(grid, DB.Grid) and not grid.IsCurved: vector = grid.Curve.GetEndPoint(0) - grid.Curve.GetEndPoint(1) angle = vector.AngleTo(DB.XYZ.BasisY) * (180/math.pi) if (45 <= angle <= 135) or (225 <= angle <= 315): h_grids.append(grid) else: v_grids.append(grid) return { "horizontal_grids": sorted(h_grids, key=lambda x: x.Curve.GetEndPoint(0).Y, reverse=reverse_horizontal), "vertical_grids": sorted(v_grids, key=lambda x: x.Curve.GetEndPoint(0).X, reverse=reverse_vertical)} OUT = separate_by_orientation(grids)["vertical_grids"], separate_by_orientation(grids)["horizontal_grids"]
5. Renumber Grids
In the final part, we can insert all input gathered from the parts written above. We are going to map the vertical grids to IN[0], horizontal grids to IN[1], vertical grid labels to IN[2], horizontal grid labels to IN[3], Prefix label to IN[4], and Prefix label toggle (Yes/No) to IN[5].

The script will loop through each grid and then renumber them by default with a prefix. The default renaming contains the text: N/A
(Not Available). The reason why this is done is that names must be unique. So it will “Refresh” each grid first before it will start renumbering.
When any of the grid names in your project is already taken, the script will stop and leave the grids with the prefix N/A
, to let you notice that there are grids in your project with the same name.

# Load the Python Standard and DesignScript Libraries import clr # Import DocumentManager clr.AddReference("RevitServices") import RevitServices from RevitServices.Persistence import DocumentManager #Import RevitAPI clr.AddReference("RevitAPI") from Autodesk.Revit.DB import * # The inputs to this node will be stored as a list in the IN variables. vertical_grids = UnwrapElement(IN[0]) horizontal_grids = UnwrapElement(IN[1]) vertical_grid_labels = IN[2] horizontal_grid_labels = IN[3] prefix = IN[4] prefix_toggle = IN[5] # Renumber grids def Renumber(vertical_grids, horizontal_grids, vertical_grid_labels, horizontal_grid_labels, prefix, prefix_toggle): doc = DocumentManager.Instance.CurrentDBDocument with Transaction(doc) as t: t.Start("Refresh Grid labels") for i, grid in enumerate(vertical_grids): if i < len(vertical_grid_labels): if prefix_toggle: grid.Name = "N/A-" + prefix + str(vertical_grid_labels[i]) else: grid.Name = "N/A-" + str(vertical_grid_labels[i]) for i, grid in enumerate(horizontal_grids): if i < len(horizontal_grid_labels): if prefix_toggle: grid.Name = "N/A-" + prefix + str(horizontal_grid_labels[i]) else: grid.Name = "N/A-" + str(horizontal_grid_labels[i]) t.Commit() with Transaction(doc) as t: t.Start("Renumbering Grids") for i, grid in enumerate(vertical_grids): if i < len(vertical_grid_labels): if prefix_toggle: grid.Name = prefix + str(vertical_grid_labels[i]) else: grid.Name = str(vertical_grid_labels[i]) for i, grid in enumerate(horizontal_grids): if i < len(horizontal_grid_labels): if prefix_toggle: grid.Name = prefix + str(horizontal_grid_labels[i]) else: grid.Name = str(horizontal_grid_labels[i]) t.Commit() return { "vertical grids": vertical_grids, "horizontal grids" : horizontal_grids} OUT = Renumber(vertical_grids, horizontal_grids, vertical_grid_labels, horizontal_grid_labels, prefix, prefix_toggle)
Wrapping Up
Grids can help you organize your design in Revit. With a coordinate in each grid bubble, it is easier to communicate about element locations. After placing grids in Revit, it can be possible that you have to revise your numbering. This can be a tedious and time-consuming task that can’t be fixed automatically in Revit self.
Fortunately, scripting with Dynamo makes it possible to renumber grids. This method is an efficient and effective solution for anyone who works with Autodesk Revit. The script automates the process, saves a lot of time, and reduces mistakes in renumbering.
I hope this article helped you to understand how to renumber grids automatically with the help of a Dynamo script. If you have any questions, just drop a comment below.