-
Notifications
You must be signed in to change notification settings - Fork 0
Execution Python
Use Python 3.13 scripting when you want fast automation, data extraction, computational geometry, reporting, debugger support, or package-heavy workflows inside the host.
This page covers the modern CPython path: Python 3.13 plus PythonNet. It is one part of the broader Execution scripting support, alongside IronPython, F# scripts, and C# scripts.
Python 3.13 script folders are discovered through files ending with:
*script.py
Example:
Samples/PythonDemo/commands/data_analysis_script.py
Dependencies are declared with PEP 723 metadata:
# /// script
# dependencies = ["polars", "numpy"]
# ///The runtime parses metadata before execution and prepares the environment.
The current runtime is Pixi-first:
%APPDATA%\RevitDevTool\pixi-env
If Pixi cannot run, the runtime can fall back to a pip-based pyRevit CPython provider. That fallback is intended for constrained enterprise machines and depends on pyrevit.exe being discoverable on PATH.
This is a v3.0 change from older UV-centric docs.
In Revit, scripts can access the active Revit application/document context provided by RevitDevTool. In other hosts, use the matching host context. For modeless UI or background work, route host API calls through the supported host execution path.
Python debugging uses debugpy and the debugger bridge.
Typical flow:
- Configure VSCode attach to the RevitDevTool debug port.
- Start the debugger.
- Run the script from RevitDevTool.
- Breakpoints hit when
debugpyis active and attached.
If debugging fails, check the active Python environment, debugpy installation, configured port, and local firewall/security rules.
For the full workflow, see Python Debugging.
Current Python samples live under:
Samples/PythonDemo/commands/
Notable examples:
data_analysis_script.pydashboard_script.pydebugpy_script.pyselectionfilter_script.pyvisualization_curve_script.pyvisualization_solid_script.pyvisualization_xyz_script.pylogging_format_script.pymodeless_script.py
- Package installation can be blocked by local policy or network access.
- Revit API calls still require valid Revit context.
- PythonNet behavior can differ from IronPython behavior, especially around .NET interop.
- Current automated tests do not fully cover real host execution.
- Run Code Overview
- Modern Python Scripting
- Python Debugging
- Python Ecosystems
- RevitDevTool And pyRevit
- Python Stub Generation
- Run .NET Add-ins
- Scripting Runtimes