Skip to main content
v0.1.0 - Open Source

RevitPy

A modern Python framework that brings async/await, LINQ-style queries, and comprehensive testing to Autodesk Revit development.

pip install revitpy

Feature Highlights

Q

Query Builder

LINQ-style fluent queries with filtering, sorting, pagination, and lazy evaluation for Revit elements.

O

ORM Layer

Object-relational mapping with change tracking, caching, relationships, and Pydantic-based validation models.

E

Event System

Decorator-based event handlers with priority levels, filtering, throttling, and async dispatch.

X

Extensions

Plugin architecture with lifecycle management, dependency injection, and decorator-based registration of commands, services, and tools.

A

Async Support

Native async/await for Revit operations with task queues, progress reporting, and cancellation tokens.

T

Testing

Mock Revit environment with MockDocument, MockElement, and MockApplication for testing without a Revit installation.

Q

Quantity Extraction

Quantity takeoff engine with material aggregation, cost estimation, and multi-format data export for BIM workflows.

I

IFC Interop

IFC export/import with element mapping, IDS validation, BCF issue tracking, and model diff capabilities.

M

AI & MCP

Model Context Protocol server with tool registration, safety guardrails, and prompt templates for AI-assisted workflows.

S

Sustainability

Embodied carbon calculations, EPD database integration, compliance checking, and sustainability reporting.

P

Speckle Interop

Speckle connector with type mapping, diff, merge, and real-time subscriptions for collaborative BIM data exchange.

C

Cloud Automation

APS Design Automation integration with batch processing, cloud job orchestration, and CI/CD pipeline helpers.

Code Example

Query Revit elements and modify them inside a transaction:

from revitpy import RevitAPI

# Connect to Revit
api = RevitAPI()
api.connect()

# Query walls using the fluent query builder
walls = (api.query("Wall")
         .where("Height", "greater_than", 10.0)
         .order_by("Name")
         .take(50)
         .execute())

# Modify elements inside a transaction
with api.transaction("Update Wall Comments") as txn:
    for wall in walls:
        wall.set_parameter_value("Comments", "Reviewed")

Async Operations

from revitpy import AsyncRevit

async def process_elements():
    revit = AsyncRevit()
    await revit.initialize()

    # Query elements asynchronously
    elements = await revit.query_elements_async(
        element_type="Window"
    )

    # Batch process with progress tracking
    async with revit.progress_scope(len(elements), "Updating windows"):
        await revit.update_elements_async(elements)

Mock Testing

from revitpy import MockRevit

# Create a mock Revit environment -- no Revit installation needed
mock = MockRevit()
doc = mock.create_document("TestProject.rvt")

# Create test elements with parameters
wall = mock.create_element(
    name="Wall-01",
    category="Walls",
    element_type="Wall",
    parameters={"Height": 12.0, "Comments": ""}
)

assert wall.HasParameter("Height")
assert doc.GetElementCount() == 1

Documentation Tiers

Component Overview

Component Module Purpose
Core API revitpy.api RevitAPI wrapper, Element, Transaction, QueryBuilder, exceptions
ORM revitpy.orm RevitContext, change tracking, caching, relationships, validation models
Events revitpy.events EventManager, event types, decorator-based handlers
Extensions revitpy.extensions Extension lifecycle, ExtensionManager, decorator registration
Async revitpy.async_support AsyncRevit, TaskQueue, ProgressReporter, CancellationToken
Testing revitpy.testing MockRevit, MockDocument, MockElement, MockApplication
Performance revitpy.performance PerformanceOptimizer, BenchmarkSuite, MemoryManager
Config revitpy.config Config, ConfigManager
Extract revitpy.extract Quantity takeoff, material aggregation, cost estimation, data export
IFC revitpy.ifc IFC export/import, element mapping, IDS validation, BCF, diff
AI revitpy.ai MCP server, tool registration, safety guardrails, prompt templates
Sustainability revitpy.sustainability Carbon calculations, EPD database, compliance checking, reports
Interop revitpy.interop Speckle sync, type mapping, diff, merge, real-time subscriptions
Cloud revitpy.cloud APS Design Automation, batch processing, CI/CD helpers

Community and Support

License

RevitPy is released under the MIT License.


Ready to Get Started?

Install RevitPy and start building modern Revit extensions with Python.

Install RevitPy