-
Notifications
You must be signed in to change notification settings - Fork 0
CodeExecute VsPyRevit
Two tools, two different audiences.
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
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
| 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 |
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
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 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.
IronPython (2.7/3.4):
- No dependencies needed (Revit API only)
- Can't use pandas, numpy, scikit-learn
CPython (3.12):
- Manual
pip installrequired - User manages virtual environments
- No automatic conflict resolution
- Pre-install before running scripts
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
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
Modern VSCode debugging:
- Set breakpoints in VSCode (click line margin)
- Press F5 β Attach to Revit
- Execute script β Pauses at breakpoints
- Inspect variables, step through code
- 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 | |
| Step debugging | β F10, F11 | |
| Conditional breakpoints | β Native | β Manual |
See: Python Debugging for complete guide
β 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
β 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
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)
Task: Analyze wall data with pandas, create visualizations
pyRevit:
# Can't use pandas in IronPython 2.7 β
# Must use manual data structures
# Limited analysis capabilitiesRevitDevTool:
# /// 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 WebView2Verdict: RevitDevTool better (modern data science stack)
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
- β 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
- β 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
- β pyRevit for end-user deployment
- β RevitDevTool for development and research
- β Different tools for different workflows
Minimal code changes:
# pyRevit
from pyrevit import revit
doc = revit.doc
# RevitDevTool
doc = __revit__.ActiveUIDocument.DocumentFile 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)
| 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.
- Python Ecosystems - All Python options for Revit
- Python Debugging - VSCode debugger guide
- Python Execution - How Python scripts work
- Examples - Real-world examples
External Resources: