# Revit Dynamo Bridge

> A desktop app that exports a Revit project and applies bulk edits by generating Dynamo CPython3 scripts you paste and run. It needs no add-in and no API setup.

Source: https://ebrahimsameh.com/projects/revit-dynamo-bridge/

## The problem

Bulk-editing a Revit model usually means one of two things: clicking through elements by hand, or writing a Revit add-in, which needs the API, a build and an install. Dynamo already runs inside Revit and can execute Python. What's missing is an easy way to see a project's elements outside Revit, choose what to change, and get a script that does exactly that.

## What I built

A small PySide6 desktop app that round-trips a Revit project through two generated Dynamo scripts and a JSON file. The app never talks to Revit directly. The only bridge between them is code you copy into Dynamo and a file on disk.

1. You pick categories (walls, doors and so on) and the app generates an export script.
2. In Revit you open Dynamo, add a Python Script node set to the CPython3 engine, paste the script and run it. It writes every element and parameter in those categories to `export.json` under `%LOCALAPPDATA%\RevitDynamoBridge\`.
3. The app loads that file into a filterable table.
4. You select rows, pick an operation and fill in the form. The app generates a second script with exactly those changes.
5. You paste that into the same kind of Dynamo node and run it. The node's output reports `{uniqueId, ok, msg}` for each element.

The operations are setting parameter values, find and replace in text parameters, delete, change type and duplicate.

## Decisions and trade-offs

Elements are matched on `UniqueId`, Revit's stable GUID, not on `ElementId`, so the export and the edit line up across separate Dynamo runs. If elements are deleted and recreated in Revit, you re-export.

Number parameters are written with `SetValueString`, so you type values in the project's display units, for example `3000` for 3000 mm, and the app does no unit conversion of its own.

Any change set that includes delete or change type starts with `DRY_RUN = True`. A dry run reports what would change and commits nothing. You read the report in Dynamo, set it to `False` and run again. All edits happen inside one Dynamo transaction, and a failure on one element is reported for that element instead of stopping the rest.

The target is Revit 2024 and later, because the scripts use the 64-bit `ElementId.Value` API. Older versions would need the deprecated integer API.

Copy and paste is clumsier than an add-in. In exchange there's nothing to install in Revit, and you can read every line of the script before it touches the model.

## How it's tested

The code generators are pure functions with no Qt dependency. The tests compile the generated Dynamo code with Python's `compile()` and check that the embedded data round-trips, so they run without Revit. There are 20 pytest tests plus a headless UI smoke test, all passing on Python 3.14 with PySide6 6.11 on Windows 11. A Dev menu loads sample data, so you can try the whole app without Revit.

## Status

I haven't run the generated scripts inside Revit yet, because I don't have Revit in my environment. The end-to-end in-Revit test is written down in the README, and until it passes this stays an experiment. The code isn't published yet.
