pi-revit 0.3.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/AGENTS.md +167 -0
  2. package/CHANGELOG.md +114 -42
  3. package/README.md +598 -138
  4. package/bin/pi-revit.js +9 -9
  5. package/docs/architecture.md +271 -0
  6. package/docs/evaluation.md +434 -0
  7. package/docs/invariants.json +147 -0
  8. package/extensions/pi-revit/completion-monitor.ts +55 -0
  9. package/extensions/pi-revit/contracts.ts +146 -0
  10. package/extensions/pi-revit/discovery.ts +93 -0
  11. package/extensions/pi-revit/index.ts +231 -85
  12. package/extensions/pi-revit/instance-router.ts +86 -0
  13. package/extensions/pi-revit/platform-prompt.ts +40 -0
  14. package/extensions/pi-revit/scope-monitor.ts +114 -0
  15. package/extensions/pi-revit/script-library.ts +146 -0
  16. package/extensions/pi-revit/tool-catalog.ts +166 -0
  17. package/extensions/pi-revit/tool-documentation.ts +72 -0
  18. package/extensions/pi-revit/tool-schema.ts +8 -0
  19. package/package.json +65 -59
  20. package/scripts/build.ps1 +9 -9
  21. package/scripts/check-sdk.ps1 +66 -66
  22. package/scripts/check-tool-documentation.mjs +287 -0
  23. package/scripts/deploy.ps1 +16 -16
  24. package/scripts/generate-contracts.mjs +80 -0
  25. package/scripts/lib/platform.mjs +226 -0
  26. package/scripts/test-extension.mjs +15 -0
  27. package/skills/pi-revit/SKILL.md +39 -63
  28. package/skills/pi-revit/contracts.generated.json +3524 -0
  29. package/skills/pi-revit/references/execution-rules.md +41 -0
  30. package/skills/pi-revit/references/model-audit-export.md +40 -0
  31. package/skills/pi-revit/references/operation-recovery.md +33 -0
  32. package/skills/pi-revit/references/room-documentation.md +39 -0
  33. package/skills/pi-revit/references/tool-index.md +89 -0
  34. package/skills/pi-revit/references/tools/capture_view.md +62 -0
  35. package/skills/pi-revit/references/tools/change_element_types.md +65 -0
  36. package/skills/pi-revit/references/tools/create_tags.md +85 -0
  37. package/skills/pi-revit/references/tools/delete_elements.md +66 -0
  38. package/skills/pi-revit/references/tools/execute_csharp.md +81 -0
  39. package/skills/pi-revit/references/tools/export_documents.md +75 -0
  40. package/skills/pi-revit/references/tools/find_revit_tools.md +96 -0
  41. package/skills/pi-revit/references/tools/get_element_details.md +66 -0
  42. package/skills/pi-revit/references/tools/get_element_relationships.md +61 -0
  43. package/skills/pi-revit/references/tools/get_element_types.md +67 -0
  44. package/skills/pi-revit/references/tools/get_elements.md +87 -0
  45. package/skills/pi-revit/references/tools/get_linked_elements.md +79 -0
  46. package/skills/pi-revit/references/tools/get_linked_models.md +57 -0
  47. package/skills/pi-revit/references/tools/get_model_coordinates.md +64 -0
  48. package/skills/pi-revit/references/tools/get_model_health.md +53 -0
  49. package/skills/pi-revit/references/tools/get_model_overview.md +57 -0
  50. package/skills/pi-revit/references/tools/get_revit_operation.md +54 -0
  51. package/skills/pi-revit/references/tools/get_schedule_fields.md +62 -0
  52. package/skills/pi-revit/references/tools/get_schedules.md +71 -0
  53. package/skills/pi-revit/references/tools/manage_element_sets.md +92 -0
  54. package/skills/pi-revit/references/tools/manage_revit_instances.md +63 -0
  55. package/skills/pi-revit/references/tools/manage_revit_scripts.md +109 -0
  56. package/skills/pi-revit/references/tools/manage_schedules.md +90 -0
  57. package/skills/pi-revit/references/tools/manage_selection.md +66 -0
  58. package/skills/pi-revit/references/tools/manage_sheet_placements.md +82 -0
  59. package/skills/pi-revit/references/tools/manage_sheets.md +71 -0
  60. package/skills/pi-revit/references/tools/manage_views.md +95 -0
  61. package/skills/pi-revit/references/tools/measure_geometry.md +71 -0
  62. package/skills/pi-revit/references/tools/open_view.md +59 -0
  63. package/skills/pi-revit/references/tools/ping.md +41 -0
  64. package/skills/pi-revit/references/tools/query_spatial_elements.md +74 -0
  65. package/skills/pi-revit/references/tools/read_revit_result.md +53 -0
  66. package/skills/pi-revit/references/tools/search_api_docs.md +65 -0
  67. package/skills/pi-revit/references/tools/set_parameters.md +75 -0
  68. package/skills/pi-revit/references/tools/summarize_elements.md +64 -0
  69. package/skills/pi-revit/references/tools/transform_elements.md +79 -0
  70. package/skills/pi-revit/references/visual-verification.md +36 -0
  71. package/skills/pi-revit/tool-manifest.json +338 -0
  72. package/src/Revit/BridgeServer.cs +75 -19
  73. package/src/Revit/OperationStore.cs +178 -0
  74. package/src/Revit/ToolRegistry.cs +61 -8
  75. package/src/Revit/Tools/CaptureView.cs +9 -0
  76. package/src/Revit/Tools/ChangeElementTypes.cs +74 -0
  77. package/src/Revit/Tools/ChangeSet.cs +39 -0
  78. package/src/Revit/Tools/CreateTags.cs +107 -0
  79. package/src/Revit/Tools/DeleteElements.cs +53 -0
  80. package/src/Revit/Tools/DocumentGuard.cs +12 -2
  81. package/src/Revit/Tools/ElementNames.cs +103 -0
  82. package/src/Revit/Tools/ElementQueryScope.cs +27 -0
  83. package/src/Revit/Tools/ElementTraits.cs +53 -0
  84. package/src/Revit/Tools/ExecuteCsharp.cs +26 -7
  85. package/src/Revit/Tools/ExportDocuments.cs +9 -0
  86. package/src/Revit/Tools/FailureGuard.cs +26 -26
  87. package/src/Revit/Tools/GetElementDetails.cs +28 -2
  88. package/src/Revit/Tools/GetElementRelationships.cs +82 -0
  89. package/src/Revit/Tools/GetElementTypes.cs +8 -0
  90. package/src/Revit/Tools/GetElements.cs +58 -55
  91. package/src/Revit/Tools/GetLinkedElements.cs +89 -0
  92. package/src/Revit/Tools/GetLinkedModels.cs +73 -0
  93. package/src/Revit/Tools/GetModelCoordinates.cs +56 -0
  94. package/src/Revit/Tools/GetModelHealth.cs +7 -0
  95. package/src/Revit/Tools/GetModelOverview.cs +187 -160
  96. package/src/Revit/Tools/GetScheduleFields.cs +44 -0
  97. package/src/Revit/Tools/GetSchedules.cs +96 -0
  98. package/src/Revit/Tools/InheritedState.Summary.cs +57 -0
  99. package/src/Revit/Tools/InheritedState.cs +144 -0
  100. package/src/Revit/Tools/ManageElementSets.cs +114 -0
  101. package/src/Revit/Tools/ManageSchedules.cs +174 -0
  102. package/src/Revit/Tools/ManageSelection.cs +9 -0
  103. package/src/Revit/Tools/ManageSheetPlacements.cs +113 -0
  104. package/src/Revit/Tools/ManageSheets.cs +72 -0
  105. package/src/Revit/Tools/ManageViews.cs +115 -0
  106. package/src/Revit/Tools/MeasureGeometry.cs +60 -0
  107. package/src/Revit/Tools/ModelChanges.cs +154 -0
  108. package/src/Revit/Tools/ModelEditBatch.cs +105 -0
  109. package/src/Revit/Tools/ModelEditInputs.cs +49 -0
  110. package/src/Revit/Tools/OpenView.cs +8 -0
  111. package/src/Revit/Tools/ParameterResolver.cs +94 -0
  112. package/src/Revit/Tools/QuerySpatialElements.cs +70 -0
  113. package/src/Revit/Tools/SearchApiDocs.cs +72 -4
  114. package/src/Revit/Tools/SetParameters.cs +50 -119
  115. package/src/Revit/Tools/SpatialBounds.cs +30 -0
  116. package/src/Revit/Tools/SummarizeElements.cs +94 -0
  117. package/src/Revit/Tools/ToolContract.cs +48 -0
  118. package/src/Revit/Tools/ToolSupport.cs +4 -0
  119. package/src/Revit/Tools/TransformElements.cs +73 -0
  120. package/workspace/AGENTS.md +54 -48
@@ -0,0 +1,41 @@
1
+ # Shared execution rules
2
+
3
+ Read for tasks that interact with a Revit model. For tool-specific inputs and limits, use the [tool index](tool-index.md). These instructions explain existing behavior; identity checks, transaction handling, and retry protections are enforced in executable code.
4
+
5
+ ## Scope and targeting
6
+
7
+ Classify the request as explanation/planning, inspection, or modification/delivery. Use only the required path. Read-only findings do not authorize repairs. Follow the user's established scope and model-saving instructions without adding an approval ceremony to already-authorized work. If the requested target or consequential action is unclear, resolve that ambiguity before the dependent action.
8
+
9
+ The first sole Revit instance can bind automatically. For multiple sessions, choose with [manage_revit_instances](tools/manage_revit_instances.md). Once selected, calls never silently fall back to another session. <!-- inv:no-session-fallback --> Selecting a bridge does not activate a document. Most bridge tools require an open document; `ping` and `search_api_docs` do not. A document-free API search still needs the bridge.
10
+
11
+ Read `get_model_overview` for the intended model before changing it. Copy `project.documentId` unchanged into `expected_document_id`. It identifies one open document in one bridge session, not a stable project ID, export-directory key, or title. Refresh after closing/reopening, restart, or switching instances. On rejection, establish that the intended model is active before obtaining its ID; never blindly replace the ID with that of another active model. <!-- inv:identity-refresh-intent -->
12
+
13
+ `get_model_overview` reports `project.documentKind`: `project` or `family`, and for a family its category, types and parameters. Each tool declares the document kinds it works in, and the bridge refuses a tool in any other kind before it runs, naming the route to use instead. In a family, types, parameters and formulas are edited through `FamilyManager` with `execute_csharp`. <!-- inv:document-kind-declared -->
14
+
15
+ The exact guard is required for all model writes and previews, `execute_csharp`, `export_documents`, `open_view`, and selection/zoom changes. <!-- inv:document-identity-guard --> `manage_sheet_placements` requires it even for `list`, because its metadata classifies the whole tool as write-capable. `manage_selection` requires it for `isolate_in_view: true`, including with action `get`. Pure reads can omit it unless their public schema requires it; supply it when an inspection must remain bound to one model. A supplied identity is checked. Legacy `expected_document` titles alone do not satisfy the guard.
16
+
17
+ ## Discover before using
18
+
19
+ Use [find_revit_tools](tools/find_revit_tools.md) to activate relevant specialist tools. Read their current public schemas and focused manuals. Tool activation does not run a model operation or automatically read arbitrary Markdown. Prefer a dedicated tool over custom C# when it covers the requested operation.
20
+
21
+ Discover element, type, view, sheet, link, and field identities from results; examples do not provide usable project IDs. Linked identities remain in their linked document and must not be passed to host write or selection tools. <!-- inv:linked-ids-stay-linked --> The common selection sequence is `get_elements` → returned IDs → `manage_selection` with action `set`; selection has no inline query filter.
22
+
23
+ ## Parameters and units
24
+
25
+ Display parameter names are localized. For missing display-name lookups or non-English documents, use discovered language-independent `BuiltInParameter` names, such as `ALL_MODEL_MARK` or `ALL_MODEL_INSTANCE_COMMENTS`, where supported. Parameter detail results expose `builtInParameter` for discovery. Shared parameters can use `guid:<GUID>` where the tool supports it. Distinguish missing values from empty values and ambiguous matches; never silently choose one duplicate display name. <!-- inv:parameter-ambiguity -->
26
+
27
+ Raw measurable parameter values and most returned coordinates use internal Revit units, with lengths in feet. `displayValue` is separately formatted for the document. Numeric query-filter and write inputs can instead use their explicit `unit` or document display units. Read the individual contract; do not apply one conversion rule indiscriminately. Sheet placement uses paper-space coordinates without multiplication by view scale; shared/model/view coordinates are distinct.
28
+
29
+ ## Transactions and retained effects
30
+
31
+ Use preview to examine consequential or uncertain edits when supported. `preview` and `atomic` are independent: preview rolls back; atomic rejects the whole batch on a failed step. Default batches can retain partial success. A preview may exercise commit checks then roll back an enclosing group; check `commit_validation_performed` before claiming commit validation happened.
32
+
33
+ Read `committed`, `succeeded`, `proposed`, `failed`, `commitWarnings`, and tool-specific counts. `succeeded` represents committed steps, while `proposed` represents accepted steps rolled back by preview or atomic failure. Temporary IDs in proposals cannot be reused. Committed type changes can replace elements; follow the returned replacement identity. Per-step before/after values are not necessarily a final-model snapshot when the same parameter is written repeatedly or constraints affect other elements. Reread what matters.
34
+
35
+ Every call of a tool that can change the model reports `model_changes`: the objects it added, modified and deleted (`observed: false` means no document change was seen), and for new views their visibility state. <!-- inv:model-changes-reported --> Use it to state what a call changed, including custom scripts. An object made from an existing one inherits its state: duplicates, copies and retyped elements report `inherited_state` (hidden categories and elements, filters, overrides, template, carried Mark or Comments). Compare it with the request and say what the result derives from. <!-- inv:derived-state-reported -->
36
+
37
+ Objects that existed before the request are not yours. When the request asks you to create an object and one with that name already exists, or a creation fails with `name_collision`, do not edit, reuse, replace or delete the existing object; ask the user, or create under a distinct name and report the collision. <!-- inv:existing-objects-not-reused --> A PI-Revit scope note on a result means a call changed an object the request names that predates the request.
38
+
39
+ A commit is not a file save. <!-- inv:no-tool-saves-model --> Model rollback does not reverse prior UI actions, files, or external effects; custom scripts can have all of those. Export and model saving must be within the user's scope. Use returned export paths as authoritative rather than constructing paths from the document title or opaque ID.
40
+
41
+ For uncertain outcomes read [operation recovery](operation-recovery.md); for visible results read [visual verification](visual-verification.md). For oversized responses read [read_revit_result](tools/read_revit_result.md), while continuing to honor the original query's independent pagination and limits.
@@ -0,0 +1,40 @@
1
+ # Model audit and export
2
+
3
+ Use this workflow to establish model counts and data quality, inspect findings, and produce requested exports with a record of the model and scope used. An audit does not imply permission to repair the model or save its Revit file.
4
+
5
+ For an explanation of auditing, describe the approach without connecting to a model. For an inspection request, perform only the relevant read steps. The correction and export sections apply only when those outcomes are within the user's scope; an audit alone does not require an export.
6
+
7
+ Read [execution rules](execution-rules.md), then discover/activate only the required capabilities with [find_revit_tools](tools/find_revit_tools.md). Read the relevant focused manuals and current public schemas before calling them:
8
+
9
+ | Stage | Focused manuals |
10
+ | --- | --- |
11
+ | Scope and counts | [Instances](tools/manage_revit_instances.md), [overview](tools/get_model_overview.md), [elements](tools/get_elements.md), [summaries](tools/summarize_elements.md) |
12
+ | Review and retained findings | [Health](tools/get_model_health.md), [element sets](tools/manage_element_sets.md), [details](tools/get_element_details.md), [relationships](tools/get_element_relationships.md), [coordinates](tools/get_model_coordinates.md), [spatial queries](tools/query_spatial_elements.md), [measurement](tools/measure_geometry.md) |
13
+ | Large results and requested corrections | [Saved results](tools/read_revit_result.md), [parameters](tools/set_parameters.md) |
14
+ | Requested delivery | [Exports](tools/export_documents.md), [visual verification](visual-verification.md) |
15
+
16
+ ## Establish an auditable scope
17
+
18
+ 1. Select the intended Revit session with `manage_revit_instances` when needed, then call `get_model_overview`. Record the returned model identity, title, available persistent path/identity, Revit/add-in versions, and the inspection time. The opaque document ID identifies this open session; it is not a permanent project identifier or an export-folder key.
19
+ 2. Activate only tools needed for this audit with `find_revit_tools`: `get_model_health` for warnings, `summarize_elements` for grouped counts, and `manage_element_sets` only for retained query membership. Discover export tools only for a requested export. State the categories, levels, views, and parameter rules being audited. Pass `expected_document_id` on reads as well when keeping the audit tied to one model matters.
20
+ 3. Use `get_elements` for raw counts and parameter projections. Up to 20 `parameter_names` can be requested per row, with optional type parameters. Report missing and ambiguous matches separately from empty or null values. Prefer built-in identities or shared GUIDs for stable parameter targeting. Raw measurable values use internal units; retain `displayValue` and unit context for human-readable findings.
21
+ 4. Use `summarize_elements` for counts by category, type, level, or exact parameter value. The query covers all matches and rejects query-level paging. Narrow scopes above 10,000 candidates; outer pages contain groups, not partial element counts. Record each query and avoid adding overlapping scopes as though they were disjoint.
22
+
23
+ ## Review health and retain findings
24
+
25
+ 5. Call `get_model_health` for warning groups and model structure. Inspect truncation flags: it returns at most 100 warning groups and 20 element examples per group. A truncated example list is not the complete affected set, and a successful health read does not certify every model-quality rule.
26
+ 6. For a reusable filtered scope, create a set with `manage_element_sets`. Record its query, `set_id`, count, and expiry. Sets retain at most 10,000 members, expire 30 minutes after creation, and belong to the exact open document/bridge session. They store membership, not frozen parameter values. Repeated reads show current values and report deleted or identity-changed members in `missing`; follow `next_offset` using visited membership, not only returned rows.
27
+ 7. Inspect specific findings with `get_element_details` and `get_element_relationships`. For coordinate checks, use `get_model_coordinates` with explicit units and record the active project location; its shared mapping does not identify a GIS reference system. Spatial tools may narrow review candidates, but axis-aligned boxes do not prove clashes or clearance failures. Preserve each tool's method, units, limits, warnings, and approximation status in the findings.
28
+ 8. Retrieve oversized payloads with `read_revit_result` and follow every continuation. This recovers the current tool payload; it does not expand the original query page or remove warning/projection limits.
29
+
30
+ ## Apply only requested corrections
31
+
32
+ 9. If corrections are authorized, use `set_parameters` with exact document identity, explicit numeric input units, and `preview: true` to inspect proposed before/after values. Use `atomic: true` where the batch must succeed together. Check `commit_validation_performed`, failures, and warnings before applying the intended edit as a new operation. Only committed `succeeded` entries represent retained changes; proposed entries were rolled back.
33
+ 10. Reread the affected members and repeat relevant counts/health checks after changes. Distinguish a changed query membership from changed values within the original set. Preserve before/after evidence when reporting the correction; no call should save the Revit file unless the user requested that separately.
34
+
35
+ ## Export and record what was produced
36
+
37
+ 11. Discover and inspect the intended sheet/view IDs before `export_documents`. PDF/DWG/PNG require 1–100 explicit IDs. IFC exports the whole model by default or can use one supplied view; record that distinction. PDF combines outputs by default. Export has file effects, and IFC can also write model metadata inside its transaction; it is not a rollback-only preview.
38
+ 12. Omit `output_dir` to use the identity-derived model destination unless the user requests another location. Treat returned `outputDir` and `files[].path` as authoritative. Do not reconstruct a folder from model title or session ID. Use the verified model folder for accompanying audit notes according to workspace rules; never trigger an unnecessary export just to discover a folder.
39
+ 13. Record export time, format, requested IDs/scope, model identity evidence, operation ID, returned paths and sizes, and commit warnings. These identify what the export call reported. Directory-change detection can be confused by unrelated simultaneous writers, so avoid sharing the output folder with concurrent work.
40
+ 14. Open or inspect the produced artifact as appropriate to the deliverable. Existence and file size do not establish drawing quality or IFC schema/geometry validity. If export fails, report observed partial files; rollback does not remove them. For a timeout, follow [operation recovery](operation-recovery.md): inspect its original receipt before retrying with the same `_operation_id` and identical arguments. State remaining uncertainty explicitly rather than claiming an unverified export succeeded, and stop dependent modifications while a consequential earlier outcome remains unknown.
@@ -0,0 +1,33 @@
1
+ # Operation recovery
2
+
3
+ Read after a timeout, cancellation, uncertain result, or a failure that may have left effects. [get_revit_operation](tools/get_revit_operation.md) documents receipt inputs and outputs. The bridge's deduplication and session routing enforce retry behavior; Markdown does not supply these guarantees.
4
+
5
+ ## Resolve the original outcome
6
+
7
+ 1. Retain the exact original tool, arguments, intended document identity, operation ID, and bridge identity. Supporting bridges assign IDs automatically; the extension includes them in responses or request errors.
8
+ 2. Read the original receipt with `get_revit_operation`. This bypasses the model thread and does not queue another model action. Receipt reads and identical retries route to the original bridge regardless of the selected target for new calls; they do not change selection.
9
+ 3. Interpret state and result together. `queued` or `running` is unfinished. `expired_before_start` confirms no tool action began. `succeeded` means the call completed, not that a change committed: a successful preview can report `committed: false`. `failed` and `result_unavailable` do not establish rollback. `unknown`, an unavailable original bridge, or a restarted session does not prove the action never ran. <!-- inv:uncertain-outcome -->
10
+ 4. If a retry is needed, add the exact `_operation_id` to the original tool call and preserve every other argument. <!-- inv:receipt-routing --> The bridge waits for or returns that operation's result without repeating it. A tool/argument mismatch is rejected. Omitting `_operation_id` creates a new operation. Applying a preview is a new operation because the arguments change, but do that only after the preview outcome is known.
11
+ 5. If the receipt cannot establish the outcome, inspect the original model and other effects before issuing a new modification. Stop dependent edits when the outcome remains consequentially uncertain; report what is known and what access or evidence is missing. Do not change instances or manufacture a new ID to bypass uncertainty.
12
+
13
+ ## Retention and restart limits
14
+
15
+ The bridge keeps at most 128 full completed results totaling 32 MiB. Eviction leaves the ID and outcome reserved for the remainder of that bridge session, with `result_available: false`; an identical retry neither reconstructs the result nor executes again. At 10,000 records, new tracked calls are rejected while retained receipts remain queryable. Restart clears receipts and changes bridge identity. An old operation ID cannot be replayed against the new session. Older bridges without tracking have no receipt guarantee.
16
+
17
+ Client cancellation does not cancel bridge execution. A queued operation may still begin before its deadline, and started work cannot be interrupted. Standard bridge calls have a 30-second client budget; `execute_csharp`, `capture_view`, and `export_documents` have 120 seconds. A timeout can leave already-started work running. Wait or inspect the existing receipt according to the task; do not flood the queue with fresh calls.
18
+
19
+ ## Failure triage
20
+
21
+ | Symptom | Interpretation and next action |
22
+ | --- | --- |
23
+ | Exact document identity rejected | No tool action was performed. Activate the intended model, read its overview, and pass the refreshed identity unchanged. |
24
+ | Several instances or selected session unavailable | [List/select the intended instance](tools/manage_revit_instances.md) and refresh the overview for new work. Choosing another instance does not resolve an old operation. |
25
+ | Bridge unavailable | Revit is closed, still starting, or the add-in did not load. Use [ping](tools/ping.md); when user action is needed, explain that Revit/add-in must be running. |
26
+ | HTTP 409, `hasActiveDocument: false` | Revit is running without an open project. Open the intended project before document calls; blindly waiting/retrying cannot fix this. |
27
+ | Timeout or modal dialog | Work may be queued or running. Inspect its receipt and any actual effects before a new action. |
28
+ | Large-result local save failed | Revit may already have finished. The error carries the operation ID on tracked bridges; recover the retained result through the receipt. Do not rerun a write to recover its display. |
29
+ | Partial selection/isolation/export failure | Earlier UI changes or incomplete files may remain. Inspect reported paths/effects; rollback cannot undo files or earlier UI actions. IFC commit warnings also need inspection. |
30
+ | Script `returnValueError` | Result projection can fail after the model committed. Read commit status and inspect effects; do not infer rollback from missing output. |
31
+ | Installed/loaded version mismatch | Use [ping](tools/ping.md) and the package's installation/upgrade guidance. Updating the Pi package alone does not deploy a matching Revit add-in. |
32
+
33
+ Large recovered receipts may themselves use [saved-result continuation](tools/read_revit_result.md). Keep receipt status, transaction status, artifact existence, and visual correctness separate in the final report.
@@ -0,0 +1,39 @@
1
+ # Room documentation
2
+
3
+ Use this workflow to prepare a room plan or section, tags, a schedule, and a drawing sheet. Match the user's requested deliverables and model-saving instructions. Creation and placement calls change the open document; a tool commit does not save the Revit file.
4
+
5
+ For an explanation or plan, describe the procedure without executing it. For inspection of an existing room sheet, use only discovery/read steps and the requested verification. Creating documentation follows the modification path. An illustrative full workflow does not expand a narrower request.
6
+
7
+ Read [execution rules](execution-rules.md) first and [visual verification](visual-verification.md) before checking visible results. Discover/activate only the tools needed through [find_revit_tools](tools/find_revit_tools.md); read each relevant manual and its public schema before use:
8
+
9
+ | Stage | Focused manuals |
10
+ | --- | --- |
11
+ | Identity and resources | [Instances](tools/manage_revit_instances.md), [overview](tools/get_model_overview.md), [elements](tools/get_elements.md), [details](tools/get_element_details.md), [types](tools/get_element_types.md) |
12
+ | Views and tags | [Views](tools/manage_views.md), [tags](tools/create_tags.md) |
13
+ | Schedule and sheet | [Read schedules](tools/get_schedules.md), [eligible fields](tools/get_schedule_fields.md), [edit schedules](tools/manage_schedules.md), [sheets](tools/manage_sheets.md), [placements](tools/manage_sheet_placements.md) |
14
+ | Verification and requested delivery | [Open view](tools/open_view.md), [capture](tools/capture_view.md), [export](tools/export_documents.md) |
15
+
16
+ ## Establish the room and drawing resources
17
+
18
+ 1. If needed, use `manage_revit_instances` to select the intended bridge. Call `get_model_overview` and retain its exact `project.documentId`. Pass it as `expected_document_id` throughout, including previews and placement listing. After a bridge restart or document reopen, select the intended session and refresh the overview.
19
+ 2. Activate the required tools with `find_revit_tools`. Query rooms using `get_elements` with category `OST_Rooms`. Project room number/name parameters using built-in identities discovered through `get_element_details`. Follow query pages and distinguish missing values from empty ones. Select the intended room by its identity, not a name alone.
20
+ 3. Read the room's level, location, bounds, and relevant parameters with `get_element_details`. Check that it is placed and suitable for documentation. Record units: detail coordinates are internal feet. A box is only an enclosure and does not establish the room's exact boundary or a valid tag location.
21
+ 4. Discover existing views/levels with `get_elements`, view-family types using `get_element_types` with `of_class: "ViewFamilyType"`, and compatible room-tag/titleblock symbols with `get_element_types`. Reuse suitable loaded resources; do not invent type IDs.
22
+
23
+ ## Build and check the views
24
+
25
+ 5. Use `manage_views` to duplicate an appropriate plan, or create a plan with the room's `level_id` and a compatible `view_family_type_id`. Choose a clear name and supported scale/template. A new floor plan is not automatically cropped to the room. Confirm the actual view extent before describing it as a room drawing.
26
+ 6. If a section is requested, use `manage_views` with action `create_section`, an explicit internal-coordinate origin, orthogonal view/up vectors, dimensions, and length unit. Derive the extent from the intended room and drawing requirements; do not assume its bounding-box faces are finished wall faces. Use preview when assessing the proposed change, inspect failures and `commit_validation_performed`, then apply the intended edit with a new operation ID. Preview-created IDs are temporary.
27
+ 7. Read the committed view ID, then use `create_tags` with `kind: "room"`, a compatible plan view and loaded room-tag type. Place `head_position` at the room's level in internal coordinates using the specified unit. It always refers to the tag head, including when a leader is enabled. Omit `orientation` for room tags. Preview, then create the intended tags; check all per-target results. Use `atomic: true` when the requested tag batch must succeed together.
28
+
29
+ ## Add the schedule and sheet
30
+
31
+ 8. Reuse a suitable existing schedule or create a regular `OST_Rooms` schedule with `manage_schedules`. On the committed schedule, call `get_schedule_fields` to discover eligible `parameter_id`/`field_type` pairs for room number, name, area, and any requested data. Add those fields, then read `get_schedules` for actual schedule-local `field_id` values.
32
+ 9. Configure headings, explicit-unit widths, itemization, sorting, and any room-number filter with `manage_schedules`. Supplied filter/sort arrays replace their entire lists. Use measured numeric filter units explicitly. Verify all row and column pages; grouped rows and totals are not element IDs. Do not reuse field IDs created only in a preview.
33
+ 10. Create or update the sheet with `manage_sheets`, using the requested name/number and an optional loaded titleblock type. Preview first when assessing the proposed layout changes, then retain the committed sheet ID.
34
+ 11. Place committed views and the schedule with `manage_sheet_placements`. Specify paper-space `[x,y,0]` coordinates and units; never multiply by view scale. A viewport position is its box center excluding its label, while a schedule position is its insertion point. Omit schedule rotation. Use `list` to inspect placements and `move` to refine them; previews produce no reusable placement IDs.
35
+
36
+ ## Verify and deliver
37
+
38
+ 12. Activate the sheet with `open_view`, capture it with `capture_view`, and open the returned PNG using Pi's image-capable read tool. Check tag legibility, view extent, scale, schedule contents, titleblock data, and overlaps. Numeric placement alone does not confirm visual layout quality.
39
+ 13. If export is requested, export the committed sheet ID through `export_documents` and report the returned paths. Respect the user's file-saving instruction separately from export. Summarize committed views, tags, schedules, and sheets, along with remaining failures or warnings. For timeouts or uncertainty, follow [operation recovery](operation-recovery.md): check the original receipt before an identical retry, preserve the original `_operation_id`, and stop dependent edits if the original outcome cannot be established.
@@ -0,0 +1,89 @@
1
+ # PI-Revit tool index
2
+
3
+ Use this index to choose a capability, then read only the relevant manual. The tables below are generated from the tool contracts and the documentation manifest. They list every public tool in this package, but that inventory is not a limit on future tools. The current public schema determines accepted inputs; a manual is explanatory guidance.
4
+
5
+ Use [find_revit_tools](tools/find_revit_tools.md) to search with English task words; translate a request written in another language first. With its default `scope: "available"`, it finds registered capabilities and activates returned tools. `scope: "documentation"` returns packaged manuals without contacting Revit or activating tools. Results carry each tool's declared **limits with alternatives**, its **verification** method and its **contract compatibility** with the selected bridge. A manual's presence does not establish that a selected bridge advertises the tool.
6
+
7
+ A tool that does not cover a request is not evidence that the request is impossible. <!-- inv:capability-claims-checked --> Follow its declared alternative. When nothing dedicated fits, check [search_api_docs](tools/search_api_docs.md), then use [execute_csharp](tools/execute_csharp.md) within the requested scope.
8
+
9
+ Read [execution rules](execution-rules.md) for model work, [operation recovery](operation-recovery.md) for uncertain outcomes, and [visual verification](visual-verification.md) for visible changes. Bridge tools include the transport-added `_operation_id`. Document guards and action requirements can be added beyond the tool class's own declared inputs. Use the final registered schema and manual together.
10
+
11
+ <!-- generated:tool-index:start (npm run generate:contracts; do not edit this block) -->
12
+
13
+ ## Connection, discovery, and local utilities
14
+
15
+ | Manual | Use | Tier | Verify |
16
+ | --- | --- | --- | --- |
17
+ | [find_revit_tools](tools/find_revit_tools.md) | Discover tools, activate capabilities, or find packaged documentation. | native | none |
18
+ | [get_revit_operation](tools/get_revit_operation.md) | Inspect an original operation receipt after uncertain results. | native | |
19
+ | [manage_revit_instances](tools/manage_revit_instances.md) | List and select local Revit bridge sessions. | native | reread |
20
+ | [manage_revit_scripts](tools/manage_revit_scripts.md) | Save, inspect and run exact versions of reusable scripts. | native | reread |
21
+ | [ping](tools/ping.md) | Check Revit bridge availability and versions. | native | |
22
+ | [read_revit_result](tools/read_revit_result.md) | Read saved large results in bounded fragments. | native | |
23
+
24
+ ## Model inspection and review
25
+
26
+ | Manual | Use | Tier | Verify |
27
+ | --- | --- | --- | --- |
28
+ | [get_element_details](tools/get_element_details.md) | Inspect element parameters, geometry bounds and identity. | core | |
29
+ | [get_element_relationships](tools/get_element_relationships.md) | Inspect hosts, joined elements, members and dependents. | advanced | |
30
+ | [get_element_types](tools/get_element_types.md) | Discover available element types and family symbols. | core | |
31
+ | [get_elements](tools/get_elements.md) | Query, count and filter elements and project parameter values. | core | |
32
+ | [get_model_health](tools/get_model_health.md) | Inspect model warnings and health information. | advanced | |
33
+ | [get_model_overview](tools/get_model_overview.md) | Inspect project identity, units, levels and category counts. | core | |
34
+ | [manage_element_sets](tools/manage_element_sets.md) | Retain query membership and reread current member values. | advanced | none |
35
+ | [summarize_elements](tools/summarize_elements.md) | Count a whole element query grouped by type, category, level or parameter. | advanced | |
36
+
37
+ ## Links, coordinates, and spatial analysis
38
+
39
+ | Manual | Use | Tier | Verify |
40
+ | --- | --- | --- | --- |
41
+ | [get_linked_elements](tools/get_linked_elements.md) | Query elements inside a selected linked document. | advanced | |
42
+ | [get_linked_models](tools/get_linked_models.md) | Discover loaded and unloaded Revit link instances. | advanced | |
43
+ | [get_model_coordinates](tools/get_model_coordinates.md) | Read base points, project locations and shared-coordinate mappings. | advanced | |
44
+ | [measure_geometry](tools/measure_geometry.md) | Measure point distance or approximate element bounding-box gaps. | advanced | |
45
+ | [query_spatial_elements](tools/query_spatial_elements.md) | Query elements by bounding-box intersection or containment. | advanced | |
46
+
47
+ ## Selection and editing
48
+
49
+ | Manual | Use | Tier | Verify |
50
+ | --- | --- | --- | --- |
51
+ | [change_element_types](tools/change_element_types.md) | Change element types with partial or atomic outcomes. | advanced | reread |
52
+ | [delete_elements](tools/delete_elements.md) | Preview or perform deletion including dependent elements. | advanced | reread |
53
+ | [manage_selection](tools/manage_selection.md) | Read or change selection, zoom and temporary isolation. | core | reread |
54
+ | [open_view](tools/open_view.md) | Activate a Revit view or sheet. | core | none |
55
+ | [set_parameters](tools/set_parameters.md) | Edit or preview parameter values with optional atomic rollback. | core | reread |
56
+ | [transform_elements](tools/transform_elements.md) | Move, copy or rotate elements with preview rollback. | advanced | reread |
57
+
58
+ ## Drawings, schedules, and delivery
59
+
60
+ | Manual | Use | Tier | Verify |
61
+ | --- | --- | --- | --- |
62
+ | [capture_view](tools/capture_view.md) | Capture a view as an image for visual verification. | advanced | inspect_output |
63
+ | [create_tags](tools/create_tags.md) | Create host element, room, space and area tags. | advanced | capture |
64
+ | [export_documents](tools/export_documents.md) | Export sheets, views or the model to PDF, DWG, PNG or IFC. | advanced | inspect_output |
65
+ | [get_schedule_fields](tools/get_schedule_fields.md) | Discover eligible parameter and field-type pairs. | advanced | |
66
+ | [get_schedules](tools/get_schedules.md) | Inspect schedule fields, sorting, filters and table cells. | advanced | |
67
+ | [manage_schedules](tools/manage_schedules.md) | Create and configure schedules, fields, filters and sorting. | advanced | reread |
68
+ | [manage_sheet_placements](tools/manage_sheet_placements.md) | List, place and move viewports and schedules on sheets. | advanced | capture |
69
+ | [manage_sheets](tools/manage_sheets.md) | Create, rename and renumber sheets. | advanced | reread |
70
+ | [manage_views](tools/manage_views.md) | Create, duplicate and update plans, sections and 3D views. | advanced | capture |
71
+
72
+ ## API and custom execution
73
+
74
+ | Manual | Use | Tier | Verify |
75
+ | --- | --- | --- | --- |
76
+ | [execute_csharp](tools/execute_csharp.md) | Execute custom synchronous C# in Revit. | core | reread |
77
+ | [search_api_docs](tools/search_api_docs.md) | Search installed Revit API classes, methods, signatures and enums. | core | |
78
+
79
+ ## Workflows and shared guidance
80
+
81
+ | Guide | Kind | Use |
82
+ | --- | --- | --- |
83
+ | [execution-rules](execution-rules.md) | reference | Shared rules for model targeting, document identity, parameters, units and transactions. |
84
+ | [operation-recovery](operation-recovery.md) | reference | Recover after timeouts, cancellations and uncertain outcomes using operation receipts. |
85
+ | [visual-verification](visual-verification.md) | reference | Capture and inspect visible results and exported deliverables, then stop when the request is verified. |
86
+ | [tool-index](tool-index.md) | reference | Every public tool grouped by task, with manual links. |
87
+ | [room-documentation](room-documentation.md) | workflow | Room plans, sections, tags, schedules and sheets as one documentation workflow. |
88
+ | [model-audit-export](model-audit-export.md) | workflow | Multi-step model audit, data review and requested exports. |
89
+ <!-- generated:tool-index:end -->
@@ -0,0 +1,62 @@
1
+ # capture_view
2
+
3
+ ## Purpose and boundaries
4
+
5
+ Export a temporary PNG of a graphical Revit view or sheet for visual inspection. The response contains a file path and metadata, never image data. Open the returned `filePath` with Pi's image-capable read tool to see the result. Capturing alone does not perform visual verification.
6
+
7
+ Contract: PI-Revit 0.5.0 source, [CaptureView.cs](../../../../src/Revit/Tools/CaptureView.cs). Activate this advanced tool through `find_revit_tools`. The public schema is authoritative; this page documents source behavior, not a live-model test.
8
+
9
+ <!-- generated:contract:start (npm run generate:contracts; do not edit this block) -->
10
+ ## Contract (generated)
11
+
12
+ - **Source:** bridge tool, advanced tier: activate it with `find_revit_tools`.
13
+ - **Writes model:** no. **Effects:** files. **Requires an open document:** yes.
14
+ - **Works in:** project and family documents.
15
+ - **Verify the outcome:** `inspect_output`: open and inspect the produced file.
16
+ - **Contract hash:** `f8989e7bb68815d2`. `find_revit_tools` compares it with the selected bridge's live contract.
17
+
18
+ | Input | Type | Required | Default | Allowed values |
19
+ | --- | --- | --- | --- | --- |
20
+ | `view_id` | integer | no | | |
21
+ | `expected_document_id` | string | no | | |
22
+
23
+ Bridge calls also accept `_operation_id`, only to retry an identical earlier request (see [operation recovery](../operation-recovery.md)).
24
+
25
+ | Not covered by this tool | Use instead |
26
+ | --- | --- |
27
+ | Image contents or visual judgement (returns a file path only) | Tool: read (open the returned PNG) |
28
+ | Deliverable PDF, DWG or IFC files | Tool: export_documents |
29
+ <!-- generated:contract:end -->
30
+
31
+ ## Inputs and preconditions
32
+
33
+ | Input | Meaning |
34
+ | --- | --- |
35
+ | `view_id` | Optional existing graphical view/sheet ID; defaults to the active view. Use an explicit committed ID for reproducible evidence. |
36
+ | `expected_document_id` | Optional exact current overview identity; always checked if supplied. Supplying it binds the capture to the intended model. |
37
+ | `_operation_id` | Optional extension argument only for an identical retry. Omit for a new operation. |
38
+
39
+ Revit must have an open document. Explicit view templates and schedules are rejected; use `get_schedules` for schedule data or capture a sheet hosting the schedule when its layout matters. Discovery uses `get_elements`; an ID from a rolled-back preview is invalid.
40
+
41
+ Follow [execution rules](../execution-rules.md) and [visual verification](../visual-verification.md). Frame the actual view so the requested content is readable. An `open_view` activation is queued; a same-batch capture based on active view can show the previous view. Use the explicit target ID in a subsequent call.
42
+
43
+ ## Example
44
+
45
+ ID `23456` is illustrative; replace it with the intended committed view/sheet ID.
46
+
47
+ ```json
48
+ {
49
+ "view_id": 23456,
50
+ "expected_document_id": "<project.documentId>"
51
+ }
52
+ ```
53
+
54
+ ## Results, effects and verification
55
+
56
+ The result contains `filePath`, `viewId`, `viewName`, `width`, `height`, and `fileSizeBytes`. Images are fitted to a maximum 1568-pixel long edge; a later export/readable close-up may be needed to inspect dense sheets. This is Revit's image export, not a screenshot of UI chrome or a proof of selection highlighting.
57
+
58
+ The tool writes files and performs no model transaction or model save. Captures normally live in `%LOCALAPPDATA%\pi-revit\captures` with a temporary-directory fallback. Later captures best-effort prune owned PNGs older than 24 hours. Retain required evidence in the task's evidence location before relying on long-term availability.
59
+
60
+ Open the image and inspect visibility, positioning, readability, clipping, and overlaps. A blank or tiny drawing is insufficient proof. Retain before/after images when useful, and report verification as incomplete if inspection is unavailable. Do not infer appearance from dimensions or filenames.
61
+
62
+ The call budget is 120 seconds. Follow [operation recovery](../operation-recovery.md) for uncertain outcomes; an identical retry may return the original capture result, not a fresh image of later model changes. Capturing evidence does not authorize saving the Revit model.
@@ -0,0 +1,65 @@
1
+ # change_element_types
2
+
3
+ ## Purpose and boundaries
4
+
5
+ Assign discovered element types to explicit host elements. Use `get_element_types` to find types and inspect target compatibility. This does not edit a type definition; use `set_parameters` on a type ID when that is the intended change. Revit constraints may affect connected or hosted elements beyond the returned target snapshots.
6
+
7
+ Contract: PI-Revit 0.5.0 source, [ChangeElementTypes.cs](../../../../src/Revit/Tools/ChangeElementTypes.cs). Activate this advanced tool through `find_revit_tools`. The public schema is authoritative; this page documents source behavior, not a live-model test.
8
+
9
+ <!-- generated:contract:start (npm run generate:contracts; do not edit this block) -->
10
+ ## Contract (generated)
11
+
12
+ - **Source:** bridge tool, advanced tier: activate it with `find_revit_tools`.
13
+ - **Writes model:** yes. **Effects:** model. **Requires an open document:** yes.
14
+ - **Works in:** project and family documents.
15
+ - **Verify the outcome:** `reread`: query the changed state again with a read tool.
16
+ - **Contract hash:** `810351ef8bac44ab`. `find_revit_tools` compares it with the selected bridge's live contract.
17
+
18
+ | Input | Type | Required | Default | Allowed values |
19
+ | --- | --- | --- | --- | --- |
20
+ | `updates` | array of object | yes | | |
21
+ | `preview` | boolean | no | | |
22
+ | `atomic` | boolean | no | | |
23
+ | `expected_document_id` | string | yes | | |
24
+
25
+ Bridge calls also accept `_operation_id`, only to retry an identical earlier request (see [operation recovery](../operation-recovery.md)).
26
+
27
+ | Not covered by this tool | Use instead |
28
+ | --- | --- |
29
+ | Editing a type definition's parameters | Tool: set_parameters |
30
+ | Creating a new type | Revit API: ElementType.Duplicate. Check all its members in one call: `search_api_docs` with query `ElementType.Duplicate`, then use `execute_csharp` within the requested scope. |
31
+ | Loading a family | Revit API: Document.LoadFamily. Check all its members in one call: `search_api_docs` with query `Document.LoadFamily`, then use `execute_csharp` within the requested scope. |
32
+ <!-- generated:contract:end -->
33
+
34
+ ## Inputs and preconditions
35
+
36
+ | Input | Meaning |
37
+ | --- | --- |
38
+ | `updates` | Required: 1–200 objects with positive `element_id` and `type_id`. Each target element may appear only once. |
39
+ | `preview` | Default `false`; commit-validates accepted changes then rolls them back. |
40
+ | `atomic` | Default `false`: valid targets can commit independently of failures. `true` rolls the entire batch back if any target fails. |
41
+ | `expected_document_id` | Required for every call, including previews. Use the intended model's exact current overview identity. |
42
+ | `_operation_id` | Optional extension argument only for an identical retry. Omit for a new operation. |
43
+
44
+ Follow [execution rules](../execution-rules.md). Revit validates that each type is an existing `ElementType` acceptable to the target. Missing, pinned, or incompatible targets fail per update. The tool does not unpin them.
45
+
46
+ ## Example
47
+
48
+ IDs are illustrative; replace them with an inspected host target and a compatible discovered type.
49
+
50
+ ```json
51
+ {
52
+ "updates": [{ "element_id": 12345, "type_id": 34567 }],
53
+ "preview": true,
54
+ "atomic": true,
55
+ "expected_document_id": "<project.documentId>"
56
+ }
57
+ ```
58
+
59
+ ## Results, recovery and verification
60
+
61
+ Read `committed`, `succeeded`, `proposed`, `failed`, `commitWarnings`, and `commit_validation_performed`. Entries include `before`, `after`, `resulting_id`, `unique_id`, `replaced`, `resulting_id_is_temporary` and `inherited_state`. Snapshot locations are internal feet. `inherited_state` lists what the retyped element keeps: its traits, Mark and Comments and, for the first 20 updates, how many views hide or override it. A replaced element (new ID) loses per-view hiding and overrides.
62
+
63
+ Revit can replace an element during a type change. After commit, use `resulting_id` and `unique_id`, not an assumed unchanged ID. Any replacement ID in `proposed` is temporary after either preview or atomic rollback; it must not be reused. An atomic rejection can lack commit validation.
64
+
65
+ Reread committed results, confirm assigned types, inspect affected dependents, and follow [visual verification](../visual-verification.md) for visible changes. Follow [operation recovery](../operation-recovery.md) for timeouts or uncertain outcomes. A write following a preview is a new operation. This does not save the model.
@@ -0,0 +1,85 @@
1
+ # create_tags
2
+
3
+ ## Purpose and boundaries
4
+
5
+ Create element, room, space, or area tags for host-document targets in one explicit view using a loaded tag family type. Linked targets and face/subelement references are unsupported. This tool creates tags, not tag families or target elements.
6
+
7
+ Contract: PI-Revit 0.5.0 source, [CreateTags.cs](../../../../src/Revit/Tools/CreateTags.cs). Activate this advanced tool through `find_revit_tools`. The public schema is authoritative; this page documents source behavior, not a live-model test.
8
+
9
+ <!-- generated:contract:start (npm run generate:contracts; do not edit this block) -->
10
+ ## Contract (generated)
11
+
12
+ - **Source:** bridge tool, advanced tier: activate it with `find_revit_tools`.
13
+ - **Writes model:** yes. **Effects:** model. **Requires an open document:** yes.
14
+ - **Works in:** project documents only; the bridge refuses other documents before running, with the route to use instead.
15
+ - **Verify the outcome:** `capture`: capture the visible result and inspect the image.
16
+ - **Contract hash:** `61b4ced397d41d57`. `find_revit_tools` compares it with the selected bridge's live contract.
17
+
18
+ | Input | Type | Required | Default | Allowed values |
19
+ | --- | --- | --- | --- | --- |
20
+ | `kind` | string | yes | | `element`, `room`, `space`, `area` |
21
+ | `view_id` | integer | yes | | |
22
+ | `tag_type_id` | integer | yes | | |
23
+ | `unit` | string | yes | | `millimeters`, `centimeters`, `meters`, `feet`, `inches` |
24
+ | `targets` | array of object | yes | | |
25
+ | `leader` | boolean | no | | |
26
+ | `orientation` | string | no | | `horizontal`, `vertical` |
27
+ | `preview` | boolean | no | | |
28
+ | `atomic` | boolean | no | | |
29
+ | `expected_document_id` | string | yes | | |
30
+
31
+ Bridge calls also accept `_operation_id`, only to retry an identical earlier request (see [operation recovery](../operation-recovery.md)).
32
+
33
+ | Not covered by this tool | Use instead |
34
+ | --- | --- |
35
+ | Tagging elements inside linked models | Revit API: Reference.CreateLinkReference; IndependentTag.Create. Check all its members in one call: `search_api_docs` with query `Reference.CreateLinkReference; IndependentTag.Create`, then use `execute_csharp` within the requested scope. |
36
+ | Tagging faces or subelements | Revit API: IndependentTag.Create with a face Reference. Check all its members in one call: `search_api_docs` with query `IndependentTag.Create`, then use `execute_csharp` within the requested scope. |
37
+ | Creating or loading tag families | Revit API: Document.LoadFamily. Check all its members in one call: `search_api_docs` with query `Document.LoadFamily`, then use `execute_csharp` within the requested scope. |
38
+ | Text notes, dimensions and other annotation | Revit API: TextNote.Create; Creation.ItemFactoryBase.NewDimension. Check all its members in one call: `search_api_docs` with query `TextNote.Create; Creation.ItemFactoryBase.NewDimension`, then use `execute_csharp` within the requested scope. |
39
+ <!-- generated:contract:end -->
40
+
41
+ ## Inputs and preconditions
42
+
43
+ Follow [execution rules](../execution-rules.md). Discover a compatible loaded `FamilySymbol`, the intended view, and host targets before requesting placement.
44
+
45
+ | Input | Meaning |
46
+ | --- | --- |
47
+ | `kind` | Required: `element`, `room`, `space`, or `area`. |
48
+ | `view_id` | Required existing view ID. Templates, perspective views, and unlocked 3D views are rejected. Spatial tags require a compatible plan view. |
49
+ | `tag_type_id` | Required loaded tag `FamilySymbol` ID; Revit validates tag compatibility. The tool activates an inactive symbol within the edit. |
50
+ | `unit` | Required length unit: `millimeters`, `centimeters`, `meters`, `feet`, or `inches`. |
51
+ | `targets` | Required array of 1–100 objects containing positive `element_id` and finite `head_position: [x,y,z]`. |
52
+ | `leader` | Optional boolean, default false. Position still means the tag head when a leader is enabled. |
53
+ | `orientation` | Element tags only: `horizontal` (default) or `vertical`. Omit entirely for room/space/area tags. |
54
+ | `preview` | Default `false`; commit-validates accepted tags then rolls back model changes. |
55
+ | `atomic` | Default false: valid target tags may commit despite others failing. True rolls back all tags if any target fails. |
56
+ | `expected_document_id` | Required for all calls, including preview; exact current overview identity. |
57
+ | `_operation_id` | Optional extension argument only for an identical retry. Omit for a new operation. |
58
+
59
+ Positions use the document's internal coordinates, not sheet coordinates. For room/space/area tags, the target must have a point location on the plan view's level; supply the head at that spatial level. The tool creates the spatial tag at the target location before applying the requested head and leader.
60
+
61
+ ## Example
62
+
63
+ IDs and positions are illustrative. Replace them with an inspected compatible plan, loaded room-tag type, room, and head position on its level.
64
+
65
+ ```json
66
+ {
67
+ "kind": "room",
68
+ "view_id": 23456,
69
+ "tag_type_id": 34567,
70
+ "unit": "meters",
71
+ "targets": [{ "element_id": 12345, "head_position": [4, 6, 0] }],
72
+ "leader": false,
73
+ "preview": true,
74
+ "atomic": true,
75
+ "expected_document_id": "<project.documentId>"
76
+ }
77
+ ```
78
+
79
+ ## Results, recovery and verification
80
+
81
+ Inspect `committed`, `succeeded`, `proposed`, `failed`, `commitWarnings`, and `commit_validation_performed`. Per-target entries include `tag_id`, `unique_id`, actual `tag_type_id`, owner `view_id`, `kind`, actual `head_position` in feet, `leader`, and `id_is_temporary`.
82
+
83
+ Every tag in `proposed` is temporary, including atomic rollback results. Only reuse IDs from committed `succeeded` entries. Preview validates model acceptance but cannot establish final visual readability after rollback.
84
+
85
+ Read committed tags and follow [visual verification](../visual-verification.md) to inspect text, head positions, leader paths, overlaps, and clipping in the actual view. Follow [operation recovery](../operation-recovery.md) before repeating an uncertain call to avoid duplicate tags. A real call after preview is a new operation. This tool does not save the model.
@@ -0,0 +1,66 @@
1
+ # delete_elements
2
+
3
+ ## Purpose and boundaries
4
+
5
+ Delete explicitly selected host elements and report the full deletion set returned by Revit, including deleted dependents. This is a single model-edit step. `get_element_relationships` dependents alone do not predict the complete deletion cascade, and the returned deleted IDs do not audit surviving elements modified by constraints.
6
+
7
+ Contract: PI-Revit 0.5.0 source, [DeleteElements.cs](../../../../src/Revit/Tools/DeleteElements.cs). Activate this advanced tool through `find_revit_tools`. The public schema is authoritative; this page documents source behavior, not a live-model test.
8
+
9
+ <!-- generated:contract:start (npm run generate:contracts; do not edit this block) -->
10
+ ## Contract (generated)
11
+
12
+ - **Source:** bridge tool, advanced tier: activate it with `find_revit_tools`.
13
+ - **Writes model:** yes. **Effects:** model. **Requires an open document:** yes.
14
+ - **Works in:** project and family documents.
15
+ - **Verify the outcome:** `reread`: query the changed state again with a read tool.
16
+ - **Contract hash:** `7c3880c989b85bb0`. `find_revit_tools` compares it with the selected bridge's live contract.
17
+
18
+ | Input | Type | Required | Default | Allowed values |
19
+ | --- | --- | --- | --- | --- |
20
+ | `element_ids` | array of integer | yes | | |
21
+ | `preview` | boolean | no | | |
22
+ | `expected_deleted_ids` | array of integer | no | | |
23
+ | `expected_document_id` | string | yes | | |
24
+
25
+ Bridge calls also accept `_operation_id`, only to retry an identical earlier request (see [operation recovery](../operation-recovery.md)).
26
+
27
+ | Not covered by this tool | Use instead |
28
+ | --- | --- |
29
+ | Pinned elements (rejected, never unpinned automatically) | User action: Confirm unpinning (Element.Pinned) first |
30
+ | Elements inside linked models | User action: Edit the linked model itself |
31
+ | One-step purge of unused types | Tool: get_element_types with include_instance_count, then delete_elements |
32
+ <!-- generated:contract:end -->
33
+
34
+ ## Inputs and preconditions
35
+
36
+ Follow [execution rules](../execution-rules.md), identify the exact requested removal, and inspect a preview before committing a deletion with dependencies.
37
+
38
+ | Input | Meaning |
39
+ | --- | --- |
40
+ | `element_ids` | Required: 1–200 distinct positive host IDs. Every requested element must exist and must not be pinned. |
41
+ | `preview` | Default `false`; validate through commit then roll back the enclosing group. |
42
+ | `expected_deleted_ids` | Optional exact full set of 1–10,000 distinct positive IDs from a prior preview. A different deletion set causes rollback. |
43
+ | `expected_document_id` | Required for preview and real deletion; copy the intended open model's exact current identity. |
44
+ | `_operation_id` | Optional extension argument only for an identical retry. Omit for a new operation. |
45
+
46
+ The selection succeeds or rolls back together. Cascades above 10,000 deleted IDs are rejected and rolled back. The tool never unpins requested elements. `expected_deleted_ids` protects the deletion set, not every property, constraint, or surviving dependent effect since preview.
47
+
48
+ ## Example
49
+
50
+ ID `12345` is illustrative. Discover the intended host target and use the actual overview identity.
51
+
52
+ ```json
53
+ {
54
+ "element_ids": [12345],
55
+ "preview": true,
56
+ "expected_document_id": "<project.documentId>"
57
+ }
58
+ ```
59
+
60
+ For an authorized real deletion, use the complete returned preview `deleted_ids` as `expected_deleted_ids` and set `preview: false`. That changed request is a new operation; do not reuse the preview's `_operation_id`. If the set changes, inspect a fresh preview rather than dropping the check.
61
+
62
+ ## Results, recovery and verification
63
+
64
+ Read `committed`, `succeeded`, `proposed`, `failed`, `commitWarnings`, and `commit_validation_performed`. The successful/proposed step contains `deleted_ids`, `deleted_count`, and `dependent_ids`. A preview reports proposed removals; it does not remove the live targets after rollback.
65
+
66
+ After commit, verify the requested removals and inspect consequential model/visible changes. Follow [visual verification](../visual-verification.md) where appearance or documentation changes. Follow [operation recovery](../operation-recovery.md) before repeating a timed-out deletion; an absent client response does not mean nothing was deleted. This tool does not save the model.