Execute C# Code
revit_execute_codeCompile and run C# code against the live Revit API to automate model queries and edits with dry-run and confirmation.
Instructions
Compile and run C# against the live Revit API on the Revit thread.
Use a method body or a public static Script class with Execute(ScriptContext ctx). Auto mode owns one transaction and undo entry. transaction="none" is refused by default; use auto. Every call except dry_run first returns needsConfirmation, confirmationText (code hash, length, mode, document) and confirmToken without running the code. Show it and retry with identical arguments plus confirm_token only after explicit chat approval. dry_run needs no token.
Long actions may return status=running and jobId. Call revit_jobs(job_id=jobId) until the original action result is returned. The action may already have changed the model; do not resubmit it.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| dry_run | No | ||
| document | No | Case-insensitive substring of the target open document's title or file name. Required to disambiguate when the Revit process has more than one document open; omit only when a single document is open (the active document is used). An unknown or ambiguous reference is rejected before any change. | |
| transaction | No | auto | |
| confirm_token | No | ||
| response_timeout_s | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||