Python
Use Python File to execute a prepared .py file, or Python Text to review and edit code before running. Start with a read-only script; scripts that modify the model must manage their own Revit transactions and be checked on an RVT copy.
Verification limits are stated for each tool. Dialog captures establish visible controls; created or edited elements require separate checks in the model, Properties and saved RVT.
Logo, Feedback and YouTube actions are explained in the common dialog footer.
Python File
Choose a .py file. Cancel returns cancellation; selecting a file reads and executes it with IronPython. The scope provides doc, uidoc, uiapp, __revit__, with RevitAPI/RevitAPIUI loaded. CPython/numpy or the machine's pip environment is not implied.
Start with a read-only script showing the document title via TaskDialog. Model-writing scripts must manage a suitable Transaction; save a model copy first. Python Error reports execution failures. Review script contents before running arbitrary code. No Revit script run is verified in this supplement.
Python Text
The manager provides File Path, … to open, 💾 to save, a code editor, AI guidance and Run Python Script. Opening/saving does not execute code; Run executes the current editor contents. Check the path after Save.
Start with read-only code and verify actual output before testing a Transaction on a model copy. AI guidance is help text rather than code or design validation. Runtime window/Run remain pending.
Start with a read-only exercise
Download the read-only Python example. It counts Rebar sets across the project and currently selected elements. These scopes differ; neither is the physical-bar total. The example opens no transaction, writes no file and uses no network.
- Open an RVT copy containing Rebar. Select one or more elements and note the selected count.
- Open BimSpeed.GEN → Python → Python Text, click … and open the example. Check File Path and review the loaded code.
- Click Chạy Script Python (Run Python Script). Read-only model check reports whole-project Rebar sets and selected elements. Close the message and verify that no geometry or model data was created.
- Change the selection and run the example again. Selected count should follow the new selection; Rebar-set count should remain unchanged without model edits.
- To retain edited code, use 💾 and choose a new .py name. Saving Python code does not save the RVT; use Revit Save separately for deliberate model changes.
This is an exercise based on the variables supplied by the tool; an entry-command result is reported separately when verified. The current Text window uses fixed Vietnamese labels even when EN is selected.
Every control
| Control | Input / enabling condition | Scope, effect and verification |
|---|---|---|
| Python File Open | One .py file; Cancel aborts | Reads and executes the file after confirmation. Review it first: the File route has no separate code preview step. |
| Python Text File Path | Read-only; changed by Open/Save | Identifies the loaded/saved code file. It is not a directly editable path input. |
| … | .py picker | Loads code into the editor and updates File Path. Loading does not execute it. |
| 💾 | Non-whitespace editor content and a chosen .py destination | Saves current code and updates File Path. Empty code produces an input message. |
| Code editor | Python text; Enter/Tab and horizontal/vertical scrolling | Run uses its current content. Long lines do not wrap; scroll to review them. Loaded code may be edited before saving/running. |
| Hướng dẫn cho AI | Opens local help | Guidance for writing code, not execution or result verification. Review scrollable sections and close to return. |
| Chạy Script Python | Nonempty code | Executes current code with doc, uidoc, uiapp and __revit__. The code defines read/write scope. Empty code is not run. |
| Success/error message | Execution result | Success means no exception escaped the engine, not that the intended model result is correct. Inspect output, IDs and Properties. Python errors display the exception message. |
| Window ✕ | Close | Does not replace saving the script or RVT. Save useful code before closing. |
For a writing script, record target IDs and values first and manage the required Revit transaction in code. Inspect the same IDs afterward, verify Undo and save the result copy. Missing modules require an engine-compatible environment or available assemblies; installing a CPython package does not automatically make it available to IronPython. A success message alone does not establish that every intended element was processed.