Run Python lets you run a Python script from BIMO inside the active Revit session. Use it for quick checks, small automation tasks, and repeatable workflows that you want to keep as a BIMO preset.
Warning: A Python script can change the Revit model. Test model-changing scripts on a copy or a safe test file first.
Before You Run
Open the Revit project or family you want to work with.
Check that the script is intended for the active document.
If the script changes the model, make sure it opens and commits its own Revit transaction.
Command Settings
Setting | What It Does |
|---|---|
| Chooses how the script is run: |
| Optional path to a |
| Python code entered directly in the command settings. If this field is not empty, BIMO runs it instead of |
| A list of text input values passed to the script. |
Choosing an Engine
Use IronPython when the script needs direct access to the active Revit document through BIMO variables such as __doc__, __uidoc__, or __uiapp__.
Use Dynamo_CPython3 for scripts written in the style of a Dynamo Python node, using IN for input and OUT for output.
Warning:
Dynamo_CPython3does not provide__doc__,__uidoc__,__revit__, or__uiapp__. If the Dynamo UI is already open, BIMO may ask you to close it before running the script.
Values Available in the Script
Value | Available In | Meaning |
|---|---|---|
|
| Text input values from the command settings. |
|
| Result value to show after the script finishes. For predictable display, return text. |
|
| Active Revit |
|
| Active Revit |
|
| Active Revit application context. |
|
| Current Revit selection object. |
Returning Output
The recommended way to show a result is to assign text to OUT.
In IronPython, print() output can also be shown when OUT is not set.
Example: Show the Active Document Name
Engine: IronPython
This example reads information only. It does not change the model.
Example: Use Input Values
Add one value to IN, for example a note or prefix, then run:
IN values are text strings.
Example: Change the Model Safely
Warning: This example starts a Revit transaction and can modify the active model. Use the same pattern only when you understand what the script changes.
BIMO does not automatically wrap your script in a transaction.
Where Scripts Are Stored
You can keep code directly in the Script setting, or store it in any .py file and select it in Script file.
BIMO does not copy .py files into a separate script library. If you use Script file, keep the file in a stable location that Revit can access.
Presets, Variants, and Keyboard Shortcuts
Run Python supports BIMO presets. A separate preset can store its own command settings:
Execution Engine;ScriptorScript file;INvalues.
This is useful when you want to keep several Python workflows ready to run. For example:
Preset | What It Stores | Variant |
|---|---|---|
| A script that checks the active view. |
|
| A parameter-filling script and the required |
|
| A path to a |
|
After you assign a preset to Variant #1, Variant #2, or Variant #3, that variant appears in the dropdown under the Run Python button. Each variant is a separate Ribbon command item, so you can assign a shortcut to it in Revit Keyboard Shortcuts.
Recommended workflow:
Create a separate preset for each Python workflow.
Name the preset by action, for example
Check Active VieworExport Rooms.Assign frequently used presets to
Variant #1..#3.Assign keyboard shortcuts to the required variant items in Revit.
Warning: a shortcut launches the selected variant immediately. If the script changes the model, first check the preset, the active document, and the script on a copy of the project.
For variant setup details, see Presets and Variants.
Errors and Troubleshooting
Problem | What To Check |
|---|---|
The file cannot be read | Check the |
The result does not appear | Return text through |
The script fails | BIMO shows error details and lets you copy them. Review the script and try again. |
| Close the Dynamo UI if it is open, or use |
Known Limitations
Scripthas priority overScript file.INvalues are passed as text strings.BIMO does not create a transaction around your Python code.
Revit variables such as
__doc__and__uidoc__are available only inIronPython.For predictable result display, return text through
OUT.For fast keyboard access, use variants assigned to presets.