Dynamo Script Library 25 Revit Automation Scripts with Python Snippets
Showing 25 of 25 scripts
Batch Rename Views
Data Management Intermediate
Renames all Revit views matching a pattern — apply prefix and format string to enforce BIM naming standards across the entire project at once.
Inputs
  • prefix — string prepended to each view name
  • namingFormat — template e.g. \${prefix}_\${level}_\${discipline}
  • matchPattern — filter string to select target views
Outputs
  • renamedViews — list of View elements updated
  • newNames — list of new name strings
  • errorLog — views that could not be renamed
Standardize all floor-plan view names to 'AR_L01_FloorPlan' in one click before issuing drawings.
🐍 Python Script Node
# Batch Rename Views — Dynamo Python Script
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
prefix     = IN[0]
nameFormat = IN[1]

views = FilteredElementCollector(doc)\
        .OfClass(View).ToElements()

renamed, errors = [], []
TransactionManager.Instance.EnsureInTransaction(doc)
for v in views:
    if v.IsTemplate: continue
    newName = nameFormat.replace("{prefix}", prefix)
    try:
        v.Name = newName; renamed.append(v)
    except Exception as e:
        errors.append(str(e))
TransactionManager.Instance.ForceCloseTransaction()
OUT = [renamed, [v.Name for v in renamed], errors]
Export Room Data to Excel
Data Management Beginner
Collects all placed rooms and exports name, number, area, and department to CSV. Handles multiple levels, converts area units from imperial to metric.
Inputs
  • outputPath — full file path for CSV
  • areaUnit — 'sqft' or 'sqm' (default sqm)
Generate room data spreadsheet for MEP consultant showing every room with area in m² by department.
🐍 Python Script Node
# Export Room Data to CSV
import clr, csv
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument
out_path = IN[0]
SQFT_TO_SQM = 0.092903

rooms = FilteredElementCollector(doc)\
        .OfCategory(BuiltInCategory.OST_Rooms).ToElements()

rows = []
for r in rooms:
    if r.Area == 0: continue
    dept = r.LookupParameter("Department")
    rows.append([r.Number, r.Name,
        round(r.Area * SQFT_TO_SQM, 2),
        dept.AsString() if dept else ""])

with open(out_path, "w", newline="") as f:
    csv.writer(f).writerows(rows)
OUT = [out_path, len(rows)]
Place Furniture from Grid
Geometry & Placement Intermediate
Places family instances on a regular rectangular grid defined by origin, X/Y spacing, and count. Supports rotation alignment.
Inputs
  • originPoint — XYZ origin of the grid in project units
  • spacingX / spacingY — horizontal and vertical spacing in mm
  • countX / countY — grid dimensions
  • familyName + typeName — loadable family to place
Populate an open-plan office with 120 workstation families in a 6×20 grid at 1800×2400mm spacing.
🐍 Python Script Node
# Place Furniture on a Regular Grid
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
sx, sy = IN[1] / 304.8, IN[2] / 304.8
cx, cy = int(IN[3]), int(IN[4])

sym = next((fs for fs in
      FilteredElementCollector(doc).OfClass(FamilySymbol)
      if fs.Family.Name == IN[5] and fs.Name == IN[6]),None)
level = FilteredElementCollector(doc)\
        .OfClass(Level).FirstElement()

placed = []
TransactionManager.Instance.EnsureInTransaction(doc)
if not sym.IsActive: sym.Activate()
for row in range(cy):
    for col in range(cx):
        pt = XYZ(col * sx, row * sy, 0)
        placed.append(doc.Create.NewFamilyInstance(
            pt, sym, level, Structure.StructuralType.NonStructural))
TransactionManager.Instance.ForceCloseTransaction()
OUT = [placed, len(placed)]
Batch Update Parameters
Data Management Intermediate
Find all elements where a parameter matches a value and replace it with a new value. Supports instance and type parameters for bulk data corrections.
Use Case
Rename all elements with Fire Rating '60 min' to '60 MIN REV2' after the fire consultant issues a revised schedule.
Browse by Category
All Scripts 25
Data Management 6
Geometry & Placement 5
Annotations & Tags 4
Views & Sheets 4
MEP & Coordination 3
Automation & Utilities 3
Recommended Packages
Data-Shapes
BimorphNodes
Rhythm
Clockwork
archi-lab
Genius Loci
Dynamo BIM Info
Dynamo is an open-source visual programming environment extending Autodesk Revit with algorithmic design and BIM automation. Scripts run in IronPython 2.7 (Dynamo 2.x) or CPython 3 (Dynamo 3.x / Revit 2024+). See AEC Hackathon community for advanced patterns.
Dynamo Script Library — 20-step walkthrough