This file provides guidance for AI assistants working with the pyRevit codebase.
pyRevit is a Rapid Application Development (RAD) environment for Autodesk Revit. It allows users to create automation tools and add-ins using Python (IronPython 2.7.12 default, CPython 3.12.3, or IronPython 3.4.0), C#, or VB.NET. The project includes a CLI utility for deployment and a telemetry server for usage tracking.
bin/- Pre-built binaries (DLLs) and Python engines (IPY2712PR, IPY342, CPY3123)dev/- C# source code, build scripts, and solution filesdocs/- Documentation source for the website (mkdocs)extensions/- pyRevit extensions (tools visible in Revit ribbon)extras/- Additional resources (icons, dark mode generator)licenses/- Third-party library licensespyrevitlib/- Python libraries for Revit API developmentrelease/- Build artifacts and installer configurationssite-packages/- Third-party Python packages (must be IronPython 2.7.12 compatible)
- Python: IronPython 2.7.12 (default), CPython 3.12.3, IronPython 3.4.0
- C#: .NET Framework 4.8 (Revit 2017-2024), .NET 8.0 (Revit 2025+)
- Go: Telemetry server (
dev/pyRevitTelemetryServer/) - Build Tools: Visual Studio 2022, pipenv, MSBuild, Inno Setup
All build commands use pipenv. Run from the repository root:
# Setup environment
pipenv install
pipenv run pyrevit check # Verify build environment
# Build commands
pipenv run pyrevit build products # Build all C# DLLs (Release mode)
pipenv run pyrevit build products Debug # Build in Debug mode
pipenv run pyrevit build labs # Build main project only
pipenv run pyrevit build engines # Build Python engines
pipenv run pyrevit build installers # Create Inno Setup installers
pipenv run pyrevit build telem # Build telemetry server
# Cleaning
pipenv run pyrevit clean labs # Clean build artifacts
# Version management
pipenv run pyrevit set version <ver> # Set version number
pipenv run pyrevit set build wip # Set as work-in-progress
pipenv run pyrevit set build release # Set as release build- Main website: https://pyrevitlabs.io/
- Technical docs: https://docs.pyrevitlabs.io/ (mkdocs, built from
docs/folder)
pipenv run docs # Build documentation (mkdocs)
pipenv run check-docstrings # Lint docstrings with ruff# Test telemetry server (requires Docker)
pipenv run pyrevit test telem
# Python unit tests are in pyrevitlib/pyrevit/unittests/
# C# unit tests are in dev/pyRevitLabs/pyRevitLabs.UnitTests/To test in Revit:
pyrevit clones add dev <path-to-repo>
pyrevit attach dev default --installed- Fork and clone the repository
- Checkout
developbranch (active development) - Initialize submodules:
git submodule update --init --recursive - Install dependencies:
pipenv install - Build:
pipenv run pyrevit build products Debug - Test in Revit by attaching the clone
For debugging C# code:
- Build in Debug mode
- Open the appropriate
.slnfile in Visual Studio - Attach debugger to
revit.exeprocess
- Revit reads
.addinmanifest from Addins folder - Manifest points to
pyRevitLoader.dll(C#) - Loader launches
pyrevitloader.pyin IronPython - Python script calls
pyrevit.loader.sessionmgr.load_session() - Extensions are discovered and UI is built
- pyRevitLoader (
dev/pyRevitLoader/): Revit add-in entry point - PyRevit.Runtime (
dev/pyRevitLabs/pyRevitLabs.PyRevit.Runtime/): Command execution - pyrevitlib (
pyrevitlib/pyrevit/): Python API for scripts - CLI (
dev/pyRevitLabs/pyRevitLabs.PyRevit/): Command-line management
Located in dev/pyRevitLabs/pyRevitLabs.PyRevit.Runtime/:
IronPythonEngine.cs- Default Python engineCPythonEngine.cs- Modern Python (3.12)CLREngine.cs- C#/VB.NET executionDynamoBIMEngine.cs- Dynamo graphsGrasshopperEngine.cs- Grasshopper definitions
Extensions follow this hierarchy:
MyExtension.extension/
MyTab.tab/
MyPanel.panel/
MyButton.pushbutton/
bundle.yaml # Button configuration
script.py # Python script
icon.png # Button icon
Supported bundle types: pushbutton, smartbutton, pulldown, splitbutton, panelbutton
Pipfile- Python dependencies (requires Python 3.10)pyRevitfile- Engine definitions and deployment profilespyproject.toml- Ruff linting config (Google docstring convention)mkdocs.yml- Documentation generation.gitmodules- Git submodules for dependencies
- Python: Google docstring convention, formatted with black, linted with ruff
- C#: Standard .NET conventions
2017-2027, with separate builds per version:
- Revit 2017-2024: .NET Framework 4.7.2/4.8
- Revit 2025-2026: .NET 8.0
- Revit 202ù: .NET 10.0
developbranch: Active development (always start here)masterbranch: Release material onlydocsbranch: Documentation website- Feature branches from
develop, PRs back todevelop - Run
git submodule updateafter switching branches