An open API service indexing awesome lists of open source software.

https://github.com/sey56/rscripting

Instant C# scripting in Revit via Roslyn and VS Code โ€” built for speed and simplicity.
https://github.com/sey56/rscripting

automation bim csharp revit revit-addins revit-api roslyn scripting

Last synced: 11 months ago
JSON representation

Instant C# scripting in Revit via Roslyn and VS Code โ€” built for speed and simplicity.

Awesome Lists containing this project

README

          


RScript Logo

---

# ๐Ÿ—๏ธ RScripting

**Streamlined C# scripting for Revit โ€” built on Roslyn, the Revit API, and VS Code**

RScripting (short for Revit Scripting) is a minimal developer environment for writing and running Revit automation scripts โ€” directly from **VS Code**.
It executes top-level C# scripts instantly inside Revit using Roslyn โ€” no builds, no packaging, no Visual Studio required.

At its core is `RScript`, the native Revit add-in that acts as the runtime engine. In Revit, it appears as a toggle button labeled **"RScriptServer"**, controlling the script execution server.
Scripts are written in plain `.cs` files using standard C# syntax and powered by the Revit API. To simplify access, RScripting injects a few global variables such as `Doc`, `UIApp`, and `Transact`, making it fast to prototype without boilerplate.

The engine works with:

- `rscript-bridge` โ€” a lightweight .NET console tool that forwards scripts from VS Code to Revit
- `rscript-extension` โ€” a VS Code extension that scaffolds a scripting workspace with IntelliSense, diagnostics, and command palette integration

Together, these form the RScripting stack โ€” a fast, readable, and build-free automation pipeline for developers working with Revit.

---

## ๐Ÿš€ Highlights

- โšก **Instant execution** via Roslyn scripting
- ๐Ÿง  **Full IntelliSense** + Revit API access (through VS Code)
- ๐Ÿ”„ **Live feedback** in VS Code's output panel
- ๐Ÿ”ง **Minimal setup** โ€” no DLL clutter or builds
- ๐Ÿ“‚ **Portable `.cs` workspace** โ€” easy to version & share
- ๐Ÿ–ฅ๏ธ **Lightweight in-Revit toggle** โ€” no embedded UI, just `RScriptServer` control

---

## โš™๏ธ Getting Started

> **Close both Revit and VS Code before installation**

### 1๏ธโƒฃ Clone & Build

Use Git Bash (comes with [Git for Windows](https://git-scm.com)):

```bash
git clone https://github.com/Sey56/RScripting.git
cd RScripting
./build.sh
```

Sets up:
- โœ… Revit Add-In
- โœ… IPC Bridge
- โœ… VS Code Extension

---

### 2๏ธโƒฃ Create Your Scripting Workspace

Create a folder anywhere with any name:

```bash
mkdir TestWorkspace
cd TestWorkspace
code .
```

---

### 3๏ธโƒฃ Initialize Workspace in VS Code

Run:

```
Ctrl + Shift + P โ†’ RScript: Initialize Workspace
```

Click **Restore** in the toaster notification.

Adds:
- `Scripts/` folder with starter scripts
- IntelliSense stubs (`Doc`, `UIDoc`, `UIApp`, `Print`, `Transact`)
- Preconfigured `.csproj`
- `.vscode/tasks.json` for automation

---

### 4๏ธโƒฃ Launch Revit & Start the Server

- Open your Revit project
- Go to **Add-Ins โ†’ RScript Server**
- Toggle the server ON

---

### 5๏ธโƒฃ Send Script to Revit

Back in VS Code, run:

```
Ctrl + Shift + P โ†’ RScript: Send To Revit
```

Or press:

```
Ctrl + Alt + R
```

---

### โœ… See Results

- **VS Code Output Tab** โ†’ Channel: `RScript`
```
[PRINT 14:30:05] Creating wall centered at origin...
[PRINT 14:30:05] Wall created.
```

![Revit view with wall centered at origin](assets/wall-origin-grid.png)
**Figure**: Wall placed along the X-axis at the origin, with crossing grids for spatial reference.

- **Local Logs** for diagnostics in local user's home directory:
- `CodeEditorError.txt`
- `RScriptBridgeLog.txt`
- `CodeRunnerDebug.txt`

---

## ๐Ÿ› ๏ธ Build Options

RScripting uses a single, streamlined build method:

### ๐Ÿง Build with Git Bash (Required)

```bash
./build.sh
```

- Runs in **Git Bash** (comes with [Git for Windows](https://git-scm.com))
- Installs:
- โœ… Revit Add-In
- โœ… IPC Bridge
- โœ… VS Code Extension
- Fast and reliable โ€” no need for Visual Studio or manual copying

---

### ๐Ÿ‘จโ€๐Ÿ’ป Development Mode (Preserve bin & obj)

```bash
./build.sh --dev
```

- Keeps `bin` and `obj` folders after build (useful for debugging in Visual Studio)
- Skips cleanup step to support incremental development
- Ideal for contributors maintaining RScripting locally

> ๐Ÿ’ก `build.sh` must be run in Git Bash. Other terminals like Command Prompt or PowerShell are not supported.

---

## ๐Ÿ’ป Requirements

| Component | Version |
|----------------------|--------------|
| Windows | 10 or 11 |
| Revit | 2025 |
| .NET SDK | 8.0+ |
| Node.js + npm | Latest LTS |
| Visual Studio Code | Latest |
| Git + Git Bash | Required |

---

## ๐Ÿ“˜ Tutorials

- [Getting Started โ†’](docs/getting-started.md)
- [Hello Revit โ†’](docs/hello-revit.md)

---

## ๐Ÿ“„ License

MIT โ€” free for personal and commercial use

---

## ๐Ÿ‘ค Author

**Seyoum Hagos** โ€” Architect ยท Developer ยท Workflow Designer
_Built in collaboration with Copilot and DeepSeek_