revit_execute_python
Run Python code inside Autodesk Revit on the UI thread to automate model tasks, query documents, and store results. Wrap modifications in a Transaction.
Instructions
Executes arbitrary Python code inside Autodesk Revit on the main UI thread.
Provides:
doc: Active Revit Document
uidoc: Active UIDocument
uiapp: UIApplication
app: Application
response_data: Dict to store return values (e.g. response_data['my_key'] = ...)
Always wrap model modifications in a Transaction: t = Transaction(doc, 'Action Name') t.Start() ... t.Commit()
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"code": "<code>"
},
"name": "revit_execute_python"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| port | No | ||
| doc_name | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |