Skip to content

CodeExecute VsPyRevit

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

RevitDevTool vs pyRevit

Two tools, two different audiences.


Target Audiences

pyRevit: End-User Automation Platform

Who it's for:

  • End users creating Revit automation tools
  • Building ribbon interfaces for teams
  • Creating reusable buttons and commands
  • Focus on pure automation tasks

Strengths:

  • Mature ribbon UI framework
  • Extensive community scripts library
  • Easy button creation and deployment
  • Large user base and documentation

RevitDevTool: Developer & Research Platform

Who it's for:

  • Developers building computational design tools
  • Researchers experimenting with Python algorithms
  • AI/ML integration with Revit
  • Data scientists analyzing building data
  • Prototyping and rapid development

Strengths:

  • Modern Python 3.13 with full ecosystem
  • VSCode debugger integration
  • Automatic dependency management
  • Research-friendly (pandas, numpy, scikit-learn)
  • Computational design workflows

Key Philosophical Differences

Aspect pyRevit RevitDevTool
Primary Goal Ribbon automation for end users Developer tools & research
UI Focus Ribbon buttons, menus, toolbars Code execution & debugging
Target User End users clicking buttons Developers writing code
Workflow Deploy β†’ Click β†’ Run Write β†’ Debug β†’ Iterate
Distribution Share buttons with teams Share scripts/libraries

Python Runtime Comparison

pyRevit: Multiple Python Options

pyRevit offers 3 Python runtime choices, each with trade-offs:

1. IronPython 2.7 (Default)

  • βœ… Direct .NET integration
  • βœ… No dependency management needed
  • ❌ Python 2.7 (obsolete since 2010)
  • ❌ No modern packages (pandas, numpy)
  • ❌ Limited ecosystem

2. IronPython 3.4

  • βœ… Newer Python syntax
  • ❌ Still incompatible with CPython packages
  • ❌ No dependency resolver
  • ❌ Small ecosystem

3. CPython 3.12 (Experimental)

  • βœ… Modern Python with full ecosystem
  • ❌ No automatic dependency resolver
  • ❌ Module reload bugs (state pollution)
  • ❌ Requires manual environment setup

RevitDevTool: CPython 3.13

Single, optimized choice:

  • βœ… Latest Python 3.13
  • βœ… Full CPython ecosystem (pandas, numpy, scikit-learn, etc.)
  • βœ… Automatic dependency resolution (UV + PEP 723)
  • βœ… Clean module reload (no state pollution)
  • βœ… VSCode debugger integration
  • ❌ Not designed for end-user ribbon deployment

IronPython vs CPython: Quick Overview

IronPython strengths:

  • Direct .NET interface implementation
  • No marshaling overhead for .NET objects
  • Simpler for pure Revit API automation

IronPython weaknesses:

  • Obsolete Python versions (2.7, 3.4)
  • Incompatible with modern Python packages
  • Limited ecosystem (no pandas, numpy, scikit-learn)

CPython strengths:

  • Modern Python (3.13)
  • Full ecosystem access
  • Better for data science, AI/ML, research
  • Standard Python tooling and debugging

CPython weaknesses:

  • Requires PythonNet for .NET interop
  • Slight marshaling overhead

Verdict: Use IronPython for simple Revit automation. Use CPython for research, data analysis, and modern development.


Dependency Management

pyRevit

IronPython (2.7/3.4):

  • No dependencies needed (Revit API only)
  • Can't use pandas, numpy, scikit-learn

CPython (3.12):

  • Manual pip install required
  • User manages virtual environments
  • No automatic conflict resolution
  • Pre-install before running scripts

RevitDevTool

CPython (3.13) with PEP 723:

# /// script
# dependencies = ["pandas==1.5.3", "numpy>=1.24"]
# ///

import pandas as pd  # Auto-installed on first run
  • Inline dependency declarations
  • Automatic installation via UV resolver
  • Per-script isolation
  • Zero manual setup

Debugging Experience

pyRevit

Traditional debugging:

# Option 1: pdb debugger
import pdb; pdb.set_trace()

# Option 2: Print debugging
print("Debug:", walls)
  • Command-line pdb interface
  • No IDE integration
  • Manual stepping through code

RevitDevTool

Modern VSCode debugging:

  1. Set breakpoints in VSCode (click line margin)
  2. Press F5 β†’ Attach to Revit
  3. Execute script β†’ Pauses at breakpoints
  4. Inspect variables, step through code
  5. Use Debug Console for expressions
Feature RevitDevTool pyRevit
VSCode debugger βœ… Full support ❌ Not available
Breakpoints βœ… Visual in IDE ❌ No IDE integration
Variable inspection βœ… VSCode panel ⚠️ pdb commands
Step debugging βœ… F10, F11 ⚠️ pdb only
Conditional breakpoints βœ… Native ❌ Manual

See: Python Debugging for complete guide


Use Cases Comparison

pyRevit Excels At:

βœ… End-user automation:

  • Creating ribbon buttons for teams
  • Deploying automation tools to non-programmers
  • Building reusable command libraries
  • Simple Revit API automation

βœ… Community sharing:

  • Large script library
  • Established patterns
  • Easy deployment

RevitDevTool Excels At:

βœ… Developer workflows:

  • Rapid prototyping with modern Python
  • Debugging complex algorithms
  • Iterative development

βœ… Computational design:

  • Generative design algorithms
  • Optimization problems
  • Custom geometry generation

βœ… Data science & research:

  • Building data analysis with pandas
  • Machine learning integration
  • Statistical analysis of BIM data
  • Export to data science formats

βœ… AI/ML integration:

  • Using modern Python AI libraries
  • LLM-assisted development (Copilot works well)
  • Computer vision with OpenCV
  • Deep learning with PyTorch/TensorFlow

Real-World Scenarios

Scenario 1: Simple Automation (Both Work)

Task: Create button to count walls

pyRevit approach:

# button.pushbutton/script.py
from pyrevit import revit
from Autodesk.Revit import DB

doc = revit.doc
walls = DB.FilteredElementCollector(doc).OfClass(DB.Wall).ToElements()
print(f"Found {len(walls)} walls")

RevitDevTool approach:

# count_walls.script.py
# /// script
# dependencies = []
# ///

from Autodesk.Revit import DB

doc = __revit__.ActiveUIDocument.Document
walls = DB.FilteredElementCollector(doc).OfClass(DB.Wall).ToElements()
print(f"Found {len(walls)} walls")

Verdict: pyRevit better (ribbon button for end users)


Scenario 2: Data Analysis (RevitDevTool Better)

Task: Analyze wall data with pandas, create visualizations

pyRevit:

# Can't use pandas in IronPython 2.7 ❌
# Must use manual data structures
# Limited analysis capabilities

RevitDevTool:

# /// script
# dependencies = ["pandas==1.5.3", "plotly==5.18.0"]
# ///

import pandas as pd
import plotly.express as px
from Autodesk.Revit import DB

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

# Use pandas for analysis
data = [{"Name": w.Name, "Level": w.LevelName, "Area": w.Area} 
        for w in walls]
df = pd.DataFrame(data)

# Statistical analysis
summary = df.groupby("Level").agg({"Area": ["sum", "mean", "count"]})
print(summary)

# Create visualization
fig = px.bar(df, x="Level", y="Area", title="Wall Areas by Level")
fig.show()  # Opens in browser or WebView2

Verdict: RevitDevTool better (modern data science stack)


Scenario 3: Machine Learning (RevitDevTool Only)

Task: Predict element categories using ML

pyRevit:

# scikit-learn not available in IronPython ❌

RevitDevTool:

# /// script
# dependencies = ["scikit-learn==1.3.0", "pandas==1.5.3"]
# ///

from sklearn.ensemble import RandomForestClassifier
import pandas as pd
from Autodesk.Revit import DB

# Collect training data from Revit
doc = __revit__.ActiveUIDocument.Document
elements = DB.FilteredElementCollector(doc).WhereElementIsNotElementType().ToElements()

# Extract features
data = extract_features(elements)
df = pd.DataFrame(data)

# Train model
model = RandomForestClassifier()
model.fit(df[features], df["category"])

# Predict on new elements
predictions = model.predict(new_data)

Verdict: RevitDevTool only option


When to Use What

Use pyRevit if:

  • βœ… Building automation tools for end users
  • βœ… Need ribbon buttons and menus
  • βœ… Deploying to non-programmers
  • βœ… Simple Revit API automation
  • βœ… Maintaining existing pyRevit scripts
  • βœ… Sharing with large pyRevit community

Use RevitDevTool if:

  • βœ… Developer/researcher workflow
  • βœ… Need modern Python ecosystem (pandas, numpy, scikit-learn)
  • βœ… VSCode debugging required
  • βœ… Computational design projects
  • βœ… Data science & analytics
  • βœ… AI/ML integration
  • βœ… Rapid prototyping and iteration
  • βœ… Research and experimentation

Use Both if:

  • βœ… pyRevit for end-user deployment
  • βœ… RevitDevTool for development and research
  • βœ… Different tools for different workflows

Migration Guide

From pyRevit to RevitDevTool

Minimal code changes:

# pyRevit
from pyrevit import revit
doc = revit.doc

# RevitDevTool
doc = __revit__.ActiveUIDocument.Document

File naming:

pyrevit_script.py       β†’ script_name.script.py
requirements.txt        β†’ # /// script ... dependencies = [...] ///

What stays the same:

  • Revit API usage (DB.Wall, FilteredElementCollector, etc.)
  • Script logic and structure
  • External package imports (if using CPython)

Summary

Aspect pyRevit RevitDevTool
Target User End users Developers & researchers
Primary Use Automation buttons Code development
Python IronPython 2.7 (default) CPython 3.13
Packages Limited (Revit API only) Full ecosystem
Debugging pdb (command-line) VSCode (full IDE)
Dependencies Manual pip Automatic (PEP 723)
Best For Ribbon automation Research & development

Both are excellent tools for different purposes.

  • pyRevit: Best automation platform for end users
  • RevitDevTool: Best development platform for researchers and developers

Choose based on your audience and workflow.


See Also


External Resources:

Clone this wiki locally