Skip to content

CodeExecute Overview

Truong Giang Vu edited this page Feb 17, 2026 · 4 revisions

CodeExecute Module

Multi-language code execution framework for Revit development.

Execute Python scripts and C# assemblies directly within Revit, with automatic dependency management, debugging support, and file watching.

Python Demo


What It Does

CodeExecute provides a unified framework for running code inside Revit:

  • 🐍 Python Scripts - CPython 3.13 with full ecosystem access
  • πŸ”§ C# Assemblies - IExternalCommand discovery and execution

Core capabilities:

  • Automatic folder scanning and hierarchical organization
  • File watching for instant reload on changes
  • Unified tree model for consistent UI
  • Output capture to Trace panel

Python Execution

Modern Python with zero-friction dependency management.

Key Features

  • CPython 3.13 - Latest Python with full ecosystem
  • PEP 723 inline dependencies - No separate requirements.txt
  • UV resolver - Automatic package installation (10-15x faster than pip)
  • VSCode debugger - Full IDE debugging with breakpoints
  • Module isolation - Clean cache between runs

Quick Example

# /// script
# dependencies = ["pandas==1.5.3"]
# ///

import pandas as pd
from Autodesk.Revit import DB

doc = __revit__.ActiveUIDocument.Document
walls = DB.FilteredElementCollector(doc).OfClass(DB.Wall).ToElements()

data = [{"Name": w.Name, "Level": w.LevelName} for w in walls]
df = pd.DataFrame(data)
print(df.groupby("Level").size())

What happens: System auto-installs pandas β†’ executes script β†’ outputs to Trace panel.

Learn more:


.NET Execution

C# assembly execution inspired by RevitAddinManager.

Key Features

  • IExternalCommand discovery - Automatic command detection
  • FileWatcher - Auto-reload on assembly changes
  • Dependency loading - All referenced DLLs loaded automatically
  • No temp folder - Direct execution for Revit 2024- (.NET 4.8)

Improvements Over RevitAddinManager

Feature RevitDevTool RevitAddinManager
FileWatcher βœ… Automatic detection ❌ Manual reload
Dependencies βœ… Auto-loaded ⚠️ Manual setup
Temp folder (2024-) βœ… No copy ❌ Copies to temp
Unnecessary features βœ… Removed ⚠️ Many extras

Learn more: .NET Execution


Comparison with Other Tools

vs pyRevit

Different target audiences:

Aspect RevitDevTool pyRevit
Target User Developers & researchers End users
Primary Use Code development & research Ribbon automation
Python CPython 3.13 IronPython 2.7 (default)
Packages Full ecosystem (pandas, numpy, AI/ML) Limited (Revit API only)
Debugging VSCode (full IDE) pdb (command-line)
Dependencies Automatic (PEP 723 + UV) Manual pip install
Best For Computational design, data science, AI Automation buttons for teams

Learn more: vs pyRevit

Python Ecosystem Options

Tool Python Auto-dependencies VSCode Debugger Best For
pyRevit IronPython 2.7 ❌ ❌ End-user automation
Dynamo CPython 3.9 ❌ ❌ Visual programming
RevitDevTool CPython 3.13 βœ… UV βœ… debugpy Development & research

Learn more: Python Ecosystems


Common Workflows

1. Python Script with Packages

Scenario: Analyze building data with pandas

# /// script
# dependencies = ["pandas==1.5.3"]
# ///

import pandas as pd
# ... your code
  1. Declare dependencies inline
  2. Click execute
  3. System auto-installs packages
  4. Script runs with full pandas support

2. VSCode Debugging

Scenario: Debug complex algorithm

  1. Set breakpoints in VSCode
  2. Press F5 β†’ Attach to Revit
  3. Execute script
  4. Debugger pauses at breakpoints
  5. Inspect variables, step through code

3. C# Assembly Execution

Scenario: Run custom IExternalCommand

  1. Build your C# project
  2. Load DLL in RevitDevTool
  3. FileWatcher detects commands
  4. Click command β†’ Execute

Architecture

For developers contributing to RevitDevTool or building custom providers, see architecture documentation in the repository:

Location: docs/CodeExecute/architecture/

  • System design and patterns
  • Provider and strategy patterns
  • Tree model implementation
  • Python.NET integration details

See Also

Execution Guides

Comparisons

Examples

Clone this wiki locally