RevitPy unlocks the full Python ecosystem for advanced Revit development capabilities that are impossible with IronPython. While PyRevit excels at UI tools and basic automation, RevitPy enables data science, machine learning, and modern cloud integration to complement your existing workflow.
RevitPy bridges the gap between PyRevit's IronPython limitations and the modern Python ecosystem:
- NumPy & Pandas: Advanced data analysis of building information
- SciPy & Matplotlib: Statistical modeling and visualization
- Time Series Analysis: Building performance forecasting
- Scientific Computing: Complex engineering calculations
- TensorFlow & PyTorch: AI-powered design optimization
- scikit-learn: Predictive maintenance models
- Computer Vision: Construction monitoring and quality control
- Space Planning AI: Intelligent layout optimization
- Async/Await Support: Real-time data synchronization with cloud services
- OAuth2 & SAML: Enterprise authentication with cloud platforms
- IoT Sensor Integration: Live building performance monitoring
- Modern REST APIs: Integration with contemporary web services
- WebSocket Connections: Real-time collaboration and updates
- Complementary Workflow: PyRevit handles UI, RevitPy handles analytics
- Data Exchange: Seamless data flow between PyRevit and RevitPy scripts
- Existing Tool Enhancement: Add advanced capabilities to current PyRevit tools
- Gradual Adoption: Integrate RevitPy incrementally with existing workflows
| Capability | PyRevit | RevitPy | Recommended Use |
|---|---|---|---|
| UI Panels & Tools | β Excellent | Use PyRevit | |
| Basic Scripting | β Perfect | Use PyRevit | |
| Productivity Commands | β 200+ built-in | Use PyRevit | |
| Data Science | β Impossible | β Full ecosystem | Use RevitPy |
| Machine Learning | β No TensorFlow/PyTorch | β All frameworks | Use RevitPy |
| Cloud APIs | β Limited async support | β Modern patterns | Use RevitPy |
| Advanced Analytics | β No NumPy/Pandas | β Scientific computing | Use RevitPy |
Problem: Need advanced statistical analysis of building energy data
PyRevit Limitation: Cannot run NumPy/Pandas/SciPy for complex calculations
RevitPy Solution: Full data science stack for energy modeling and optimization
ROI: Replace $50,000+ specialized energy modeling software
import pandas as pd
import numpy as np
from revitpy import RevitContext
# Extract building data for analysis (impossible in PyRevit)
with RevitContext() as context:
elements = context.elements.of_category('Walls')
# Create DataFrame for analysis
df = pd.DataFrame([{
'area': wall.area,
'u_value': wall.thermal_properties.u_value,
'orientation': wall.orientation
} for wall in elements])
# Advanced statistical analysis
thermal_performance = df.groupby('orientation')['u_value'].agg(['mean', 'std'])
energy_loss = np.sum(df['area'] * df['u_value'] * 24 * 365) # Annual heat loss
print(f"Total annual heat loss: {energy_loss:,.0f} BTU/year")Problem: Need AI algorithms for intelligent space planning
PyRevit Limitation: Cannot run TensorFlow/PyTorch for machine learning
RevitPy Solution: Full ML framework access for optimization algorithms
ROI: 30-50% improvement in space utilization efficiency
import tensorflow as tf
from revitpy import RevitContext
# AI-powered space planning (impossible in PyRevit)
def optimize_space_layout(rooms, constraints):
# Load pre-trained space optimization model
model = tf.keras.models.load_model('space_optimizer.h5')
# Extract room features for ML model
features = extract_room_features(rooms)
# Generate optimized layout
optimal_layout = model.predict(features)
return optimal_layoutProblem: Need async cloud data synchronization with building sensors
PyRevit Limitation: No async/await support for real-time operations
RevitPy Solution: Modern async patterns with cloud SDKs
ROI: $100,000+ in facility management automation
import asyncio
import aiohttp
from revitpy import AsyncRevitContext
async def sync_building_sensors():
"""Sync real-time sensor data with Revit model (impossible in PyRevit)"""
async with AsyncRevitContext() as context:
while True:
# Fetch live sensor data from cloud
async with aiohttp.ClientSession() as session:
async with session.get('https://api.buildingsensors.com/data') as resp:
sensor_data = await resp.json()
# Update Revit parameters with live data
for sensor in sensor_data:
element = await context.elements.find_by_id(sensor['element_id'])
await element.set_parameter('Temperature', sensor['temperature'])
await element.set_parameter('Humidity', sensor['humidity'])
await asyncio.sleep(300) # Update every 5 minutes
# Run continuously in background
asyncio.create_task(sync_building_sensors())# PyRevit script (handles UI)
import pyrevit
from pyrevit import forms, UI
import revitpy_bridge
@pyrevit.command
def analyze_energy_performance():
"""PyRevit command that uses RevitPy for analysis"""
# PyRevit handles element selection
selection = pyrevit.ui.get_selected_elements()
if not selection:
forms.alert("Please select walls to analyze")
return
# RevitPy performs advanced analysis
analysis_results = revitpy_bridge.analyze_thermal_performance(selection)
# PyRevit displays results
output = pyrevit.script.get_output()
output.print_md("# Energy Performance Analysis")
for result in analysis_results:
output.print_md(f"**{result['name']}**: {result['u_value']:.3f} BTU/hrΒ·ftΒ²Β·Β°F")
output.chart([result['monthly_data']], title=result['name'])# RevitPy bridge (handles advanced computation)
import pandas as pd
import numpy as np
from revitpy import RevitContext
def analyze_thermal_performance(elements):
"""Advanced thermal analysis using RevitPy data science capabilities"""
with RevitContext() as context:
# Convert PyRevit selection to RevitPy elements
revitpy_elements = [context.elements.get_by_id(elem.Id) for elem in elements]
# Advanced analysis using pandas/numpy
df = pd.DataFrame([{
'id': elem.id,
'name': elem.name,
'area': elem.area,
'u_value': elem.thermal_properties.u_value,
'orientation': elem.orientation
} for elem in revitpy_elements])
# Complex calculations impossible in PyRevit
results = []
for _, row in df.iterrows():
monthly_data = calculate_monthly_heat_loss(row)
annual_cost = estimate_energy_cost(row, monthly_data)
results.append({
'id': row['id'],
'name': row['name'],
'u_value': row['u_value'],
'annual_cost': annual_cost,
'monthly_data': monthly_data
})
return results
def calculate_monthly_heat_loss(wall_data):
"""Complex thermal calculation using scientific libraries"""
# Use NumPy for advanced calculations
monthly_temps = np.array([-5, 0, 8, 18, 24, 30, 33, 31, 25, 15, 5, -2]) # Β°C
indoor_temp = 22
heat_loss = wall_data['area'] * wall_data['u_value'] * (indoor_temp - monthly_temps) * 24 * 30
return heat_loss.tolist()# RevitPy background service
import asyncio
from revitpy import AsyncRevitContext, ConfigManager
class BuildingMonitoringService:
"""Continuous monitoring service using RevitPy async capabilities"""
def __init__(self):
self.config = ConfigManager.load('monitoring_config.yaml')
self.running = False
async def start_monitoring(self):
"""Start continuous building performance monitoring"""
self.running = True
async with AsyncRevitContext() as context:
while self.running:
try:
# Collect real-time data from multiple sources
tasks = [
self.fetch_sensor_data(),
self.fetch_weather_data(),
self.fetch_energy_usage()
]
sensor_data, weather_data, energy_data = await asyncio.gather(*tasks)
# Advanced analysis combining all data sources
analysis = await self.perform_complex_analysis(
sensor_data, weather_data, energy_data
)
# Update Revit model with insights
await self.update_model_parameters(context, analysis)
# Store historical data for trend analysis
await self.store_historical_data(analysis)
except Exception as e:
print(f"Monitoring error: {e}")
await asyncio.sleep(self.config.update_interval)
# Start background monitoring
service = BuildingMonitoringService()
asyncio.create_task(service.start_monitoring())RevitPy's architecture is specifically designed to enable advanced Python capabilities:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PyRevit Integration Layer β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β UI Panels β β Commands β βData Bridge β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β RevitPy Advanced Analytics Layer β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β Data Sci β β ML/AI β β Cloud APIs β β
β β (Pandas, β β(TensorFlow, β β (Async/IoT) β β
β β NumPy) β β PyTorch) β β β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Core Runtime Layer (Python 3.11+) β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β CPython β β Package β β Async β β
β β Ecosystem β β Management β β Runtime β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Python: 3.11 or later (for advanced ecosystem access)
- Revit: 2021-2025 (Windows)
- .NET: 6.0 or later
- OS: Windows 10/11 (64-bit)
- PyRevit: Optional but recommended for UI components
# Install RevitPy (PyRevit can remain installed)
pip install revitpy
# Create analytics project
revitpy new building-analytics --template=data-science
# Install scientific computing packages
cd building-analytics
pip install pandas numpy scipy matplotlib tensorflow
# Start development server
revitpy dev --integrate-pyrevit# building_analysis.py - Advanced analytics with RevitPy
import pandas as pd
import numpy as np
from revitpy import RevitContext
def analyze_building_performance():
"""Advanced analysis impossible with PyRevit's IronPython"""
with RevitContext() as context:
# Extract all building elements into pandas DataFrame
rooms = context.elements.of_category('Rooms')
df = pd.DataFrame([{
'id': room.id,
'name': room.name,
'area': room.area,
'volume': room.volume,
'occupancy': room.get_parameter('Occupancy'),
'lighting_load': room.get_parameter('Lighting Load Density')
} for room in rooms])
# Advanced statistical analysis
stats = {
'total_area': df['area'].sum(),
'avg_occupancy': df['occupancy'].mean(),
'area_per_person': df['area'].sum() / df['occupancy'].sum(),
'lighting_efficiency': df['lighting_load'].mean()
}
# Identify optimization opportunities
underutilized = df[df['occupancy'] < df['area'] * 0.1] # Low occupancy density
overlighted = df[df['lighting_load'] > 1.2] # High lighting load
return {
'summary': stats,
'optimization': {
'underutilized_rooms': underutilized.to_dict('records'),
'overlighted_rooms': overlighted.to_dict('records')
}
}
if __name__ == "__main__":
results = analyze_building_performance()
print(f"Building Analysis Complete:")
print(f"Total Area: {results['summary']['total_area']:,.0f} sq ft")
print(f"Area per Person: {results['summary']['area_per_person']:.0f} sq ft/person")
print(f"Optimization opportunities found: {len(results['optimization']['underutilized_rooms'])} rooms")# PyRevit script that calls RevitPy for advanced analytics
from pyrevit import forms
import building_analysis # RevitPy module
__doc__ = "Advanced Building Analytics (powered by RevitPy)"
def main():
# PyRevit handles the UI
result = forms.alert(
"Run advanced building performance analysis?",
"This tool uses RevitPy for advanced analytics not possible with PyRevit.",
ok=True, cancel=True
)
if result:
# RevitPy handles the complex analysis
analysis = building_analysis.analyze_building_performance()
# PyRevit displays the results
output = script.get_output()
output.print_md("# Advanced Building Analysis Results")
output.print_md(f"**Total Area**: {analysis['summary']['total_area']:,.0f} sq ft")
output.print_md(f"**Utilization Efficiency**: {analysis['summary']['area_per_person']:.0f} sq ft/person")
if analysis['optimization']['underutilized_rooms']:
output.print_md("## Optimization Opportunities")
for room in analysis['optimization']['underutilized_rooms']:
output.print_md(f"- **{room['name']}**: Consider alternative use or consolidation")
if __name__ == "__main__":
main()# revitpy_config.yaml
integration:
pyrevit:
enabled: true
data_bridge: true
shared_context: true
analytics:
packages:
- pandas>=1.5.0
- numpy>=1.21.0
- scipy>=1.9.0
- matplotlib>=3.5.0
- tensorflow>=2.10.0 # Optional: for ML workloads
- scikit-learn>=1.1.0 # Optional: for ML workloads
compute:
max_workers: 4
memory_limit: "8GB"
enable_gpu: false # Set true for ML workloads# test_analytics.py
import pytest
import pandas as pd
from revitpy.testing import mock_revit, create_mock_room
from building_analysis import analyze_building_performance
@mock_revit
def test_building_analysis():
"""Test advanced analytics with mock data"""
# Create test building data
rooms = [
create_mock_room('Conference Room A', area=300, occupancy=20),
create_mock_room('Open Office', area=2000, occupancy=80),
create_mock_room('Storage', area=150, occupancy=1) # Underutilized
]
# Test analysis
results = analyze_building_performance()
assert results['summary']['total_area'] == 2450
assert len(results['optimization']['underutilized_rooms']) == 1
assert results['optimization']['underutilized_rooms'][0]['name'] == 'Storage'
@mock_revit
def test_performance_benchmarks():
"""Test that advanced analytics meet performance requirements"""
import time
start_time = time.time()
results = analyze_building_performance()
duration = time.time() - start_time
# Analysis should complete in reasonable time even with pandas/numpy
assert duration < 2.0 # Less than 2 seconds
assert 'summary' in results
assert 'optimization' in results- UI Development: Panels, commands, and user interfaces
- Basic Automation: Simple scripts and productivity tools
- Existing Workflows: Mature ecosystem with 200+ built-in tools
- Team Onboarding: Easier learning curve for basic scripting
- Quick Wins: Fast deployment of simple automation
- Data Science: When you need pandas, NumPy, SciPy for analysis
- Machine Learning: AI/ML applications requiring TensorFlow, PyTorch
- Cloud Integration: Modern APIs requiring async/await patterns
- Complex Analytics: Statistical modeling and advanced computations
- IoT Integration: Real-time sensor data and building automation
- Scientific Computing: Engineering calculations beyond basic math
- Comprehensive Solutions: PyRevit for UI, RevitPy for analytics
- Gradual Migration: Start with PyRevit, add RevitPy capabilities incrementally
- Team Flexibility: Different team members can use appropriate tools
- Maximum Capability: Best of both worlds - established UI tools + modern analytics
- Keep PyRevit: No need to remove existing PyRevit installation
- Install RevitPy:
pip install revitpy- works alongside PyRevit - Try Analytics: Run first data science example with your models
- Explore Integration: See how PyRevit and RevitPy work together
- Identify Analytics Opportunities: Where do you need advanced capabilities?
- Create Hybrid Scripts: PyRevit UI + RevitPy analytics
- Install Scientific Packages: pandas, NumPy for your specific use cases
- Test Integration: Verify smooth data flow between tools
- Team Training: Train team on when to use each tool
- Advanced Use Cases: Implement ML or cloud integration features
- Workflow Integration: Establish patterns for PyRevit + RevitPy development
- Continuous Improvement: Identify additional opportunities for advanced analytics
- GitHub Issues: Technical issues and feature requests
- Documentation: Complete integration guide
- Showcase Projects: Share your PyRevit + RevitPy integrations
- Best Practices: Contribute integration patterns and examples
- Community Packages: Publish analytics tools for others to use
RevitPy is open source software licensed under the MIT License. Works seamlessly with PyRevit's existing license terms.
Need help integrating RevitPy with your existing PyRevit workflows?
- Integration Consulting: Custom PyRevit + RevitPy integration services
- Team Training: Specialized training for hybrid development approaches
- Custom Analytics: Bespoke data science solutions for your organization
- Enterprise Deployment: Secure deployment alongside existing PyRevit infrastructure
Contact: [email protected]
Made with β€οΈ by AJ Geddes
Extending PyRevit's capabilities with the full Python ecosystem
| Task | PyRevit β | RevitPy π¬ | Why? |
|---|---|---|---|
| Create UI panels | Perfect | Complex | PyRevit's mature UI framework |
| Basic element queries | Excellent | Overkill | PyRevit's simple approach is ideal |
| Productivity commands | 200+ built-in | Build your own | PyRevit's established ecosystem |
| Data science analysis | Impossible | Native | Need pandas/NumPy ecosystem |
| Machine learning | Impossible | Full support | Need TensorFlow/PyTorch |
| Real-time cloud APIs | Limited | Modern async | Need async/await patterns |
| Statistical modeling | Basic math only | Scientific computing | Need SciPy/statsmodels |
| IoT sensor integration | Not supported | Full support | Need modern protocols |
Recommendation: Use both tools together for maximum capability! π