pi-revit 0.4.0 → 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.
- package/AGENTS.md +167 -0
- package/CHANGELOG.md +465 -430
- package/README.md +604 -548
- package/bin/pi-revit.js +9 -9
- package/docs/architecture.md +271 -0
- package/docs/evaluation.md +434 -0
- package/docs/invariants.json +147 -0
- package/extensions/pi-revit/completion-monitor.ts +55 -0
- package/extensions/pi-revit/contracts.ts +146 -0
- package/extensions/pi-revit/discovery.ts +93 -0
- package/extensions/pi-revit/index.ts +342 -255
- package/extensions/pi-revit/instance-router.ts +86 -86
- package/extensions/pi-revit/platform-prompt.ts +40 -0
- package/extensions/pi-revit/scope-monitor.ts +114 -0
- package/extensions/pi-revit/script-library.ts +144 -144
- package/extensions/pi-revit/tool-catalog.ts +113 -14
- package/extensions/pi-revit/tool-documentation.ts +72 -0
- package/extensions/pi-revit/tool-schema.ts +8 -0
- package/package.json +8 -2
- package/scripts/build.ps1 +9 -9
- package/scripts/check-sdk.ps1 +66 -66
- package/scripts/check-tool-documentation.mjs +287 -0
- package/scripts/deploy.ps1 +16 -16
- package/scripts/generate-contracts.mjs +80 -0
- package/scripts/lib/platform.mjs +226 -0
- package/scripts/test-extension.mjs +15 -0
- package/skills/pi-revit/SKILL.md +30 -218
- package/skills/pi-revit/contracts.generated.json +3524 -0
- package/skills/pi-revit/references/execution-rules.md +41 -0
- package/skills/pi-revit/references/model-audit-export.md +38 -27
- package/skills/pi-revit/references/operation-recovery.md +33 -0
- package/skills/pi-revit/references/room-documentation.md +37 -26
- package/skills/pi-revit/references/tool-index.md +89 -0
- package/skills/pi-revit/references/tools/capture_view.md +62 -0
- package/skills/pi-revit/references/tools/change_element_types.md +65 -0
- package/skills/pi-revit/references/tools/create_tags.md +85 -0
- package/skills/pi-revit/references/tools/delete_elements.md +66 -0
- package/skills/pi-revit/references/tools/execute_csharp.md +81 -0
- package/skills/pi-revit/references/tools/export_documents.md +75 -0
- package/skills/pi-revit/references/tools/find_revit_tools.md +96 -0
- package/skills/pi-revit/references/tools/get_element_details.md +66 -0
- package/skills/pi-revit/references/tools/get_element_relationships.md +61 -0
- package/skills/pi-revit/references/tools/get_element_types.md +67 -0
- package/skills/pi-revit/references/tools/get_elements.md +87 -0
- package/skills/pi-revit/references/tools/get_linked_elements.md +79 -0
- package/skills/pi-revit/references/tools/get_linked_models.md +57 -0
- package/skills/pi-revit/references/tools/get_model_coordinates.md +64 -0
- package/skills/pi-revit/references/tools/get_model_health.md +53 -0
- package/skills/pi-revit/references/tools/get_model_overview.md +57 -0
- package/skills/pi-revit/references/tools/get_revit_operation.md +54 -0
- package/skills/pi-revit/references/tools/get_schedule_fields.md +62 -0
- package/skills/pi-revit/references/tools/get_schedules.md +71 -0
- package/skills/pi-revit/references/tools/manage_element_sets.md +92 -0
- package/skills/pi-revit/references/tools/manage_revit_instances.md +63 -0
- package/skills/pi-revit/references/tools/manage_revit_scripts.md +109 -0
- package/skills/pi-revit/references/tools/manage_schedules.md +90 -0
- package/skills/pi-revit/references/tools/manage_selection.md +66 -0
- package/skills/pi-revit/references/tools/manage_sheet_placements.md +82 -0
- package/skills/pi-revit/references/tools/manage_sheets.md +71 -0
- package/skills/pi-revit/references/tools/manage_views.md +95 -0
- package/skills/pi-revit/references/tools/measure_geometry.md +71 -0
- package/skills/pi-revit/references/tools/open_view.md +59 -0
- package/skills/pi-revit/references/tools/ping.md +41 -0
- package/skills/pi-revit/references/tools/query_spatial_elements.md +74 -0
- package/skills/pi-revit/references/tools/read_revit_result.md +53 -0
- package/skills/pi-revit/references/tools/search_api_docs.md +65 -0
- package/skills/pi-revit/references/tools/set_parameters.md +75 -0
- package/skills/pi-revit/references/tools/summarize_elements.md +64 -0
- package/skills/pi-revit/references/tools/transform_elements.md +79 -0
- package/skills/pi-revit/references/visual-verification.md +36 -0
- package/skills/pi-revit/tool-manifest.json +338 -0
- package/src/Revit/BridgeServer.cs +93 -87
- package/src/Revit/OperationStore.cs +178 -178
- package/src/Revit/ToolRegistry.cs +88 -57
- package/src/Revit/Tools/CaptureView.cs +10 -2
- package/src/Revit/Tools/ChangeElementTypes.cs +74 -60
- package/src/Revit/Tools/ChangeSet.cs +39 -0
- package/src/Revit/Tools/CreateTags.cs +107 -95
- package/src/Revit/Tools/DeleteElements.cs +53 -44
- package/src/Revit/Tools/DocumentGuard.cs +74 -64
- package/src/Revit/Tools/ElementNames.cs +103 -0
- package/src/Revit/Tools/ElementQueryScope.cs +27 -27
- package/src/Revit/Tools/ElementTraits.cs +53 -0
- package/src/Revit/Tools/ExecuteCsharp.cs +54 -45
- package/src/Revit/Tools/ExportDocuments.cs +129 -121
- package/src/Revit/Tools/GetElementDetails.cs +37 -41
- package/src/Revit/Tools/GetElementRelationships.cs +82 -76
- package/src/Revit/Tools/GetElementTypes.cs +8 -0
- package/src/Revit/Tools/GetElements.cs +75 -86
- package/src/Revit/Tools/GetLinkedElements.cs +89 -82
- package/src/Revit/Tools/GetLinkedModels.cs +73 -66
- package/src/Revit/Tools/GetModelCoordinates.cs +56 -49
- package/src/Revit/Tools/GetModelHealth.cs +7 -0
- package/src/Revit/Tools/GetModelOverview.cs +185 -158
- package/src/Revit/Tools/GetScheduleFields.cs +44 -37
- package/src/Revit/Tools/GetSchedules.cs +96 -89
- package/src/Revit/Tools/InheritedState.Summary.cs +57 -0
- package/src/Revit/Tools/InheritedState.cs +144 -0
- package/src/Revit/Tools/ManageElementSets.cs +114 -106
- package/src/Revit/Tools/ManageSchedules.cs +174 -164
- package/src/Revit/Tools/ManageSelection.cs +45 -37
- package/src/Revit/Tools/ManageSheetPlacements.cs +113 -97
- package/src/Revit/Tools/ManageSheets.cs +72 -63
- package/src/Revit/Tools/ManageViews.cs +115 -100
- package/src/Revit/Tools/MeasureGeometry.cs +60 -54
- package/src/Revit/Tools/ModelChanges.cs +154 -0
- package/src/Revit/Tools/ModelEditBatch.cs +105 -102
- package/src/Revit/Tools/ModelEditInputs.cs +49 -49
- package/src/Revit/Tools/OpenView.cs +9 -2
- package/src/Revit/Tools/ParameterResolver.cs +94 -0
- package/src/Revit/Tools/QuerySpatialElements.cs +70 -63
- package/src/Revit/Tools/SearchApiDocs.cs +72 -4
- package/src/Revit/Tools/SetParameters.cs +60 -79
- package/src/Revit/Tools/SpatialBounds.cs +30 -30
- package/src/Revit/Tools/SummarizeElements.cs +94 -87
- package/src/Revit/Tools/ToolContract.cs +48 -0
- package/src/Revit/Tools/ToolSupport.cs +5 -1
- package/src/Revit/Tools/TransformElements.cs +72 -57
- package/workspace/AGENTS.md +26 -20
|
@@ -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.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# execute_csharp
|
|
2
|
+
|
|
3
|
+
## Purpose and boundaries
|
|
4
|
+
|
|
5
|
+
Compile and execute synchronous C# on Revit's API thread for a task that available dedicated tools do not cover. Prefer dedicated query/edit tools when they support the operation. This is unrestricted code with possible model, UI, filesystem, and external effects; the transaction covers model edits only.
|
|
6
|
+
|
|
7
|
+
Contract: PI-Revit 0.5.0 source, [ExecuteCsharp.cs](../../../../src/Revit/Tools/ExecuteCsharp.cs). The current 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, core tier: active by default.
|
|
13
|
+
- **Writes model:** yes. **Effects:** model, ui, files, external. **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:** `2fa53a38ab9692cf`. `find_revit_tools` compares it with the selected bridge's live contract.
|
|
17
|
+
|
|
18
|
+
| Input | Type | Required | Default | Allowed values |
|
|
19
|
+
| --- | --- | --- | --- | --- |
|
|
20
|
+
| `code` | string | yes | | |
|
|
21
|
+
| `inputs` | object | no | | |
|
|
22
|
+
| `expected_document` | string | 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
|
+
| Automatic preview or rollback of custom code | Tool: dedicated tools with preview (set_parameters, transform_elements, delete_elements, manage_views, ...) |
|
|
30
|
+
| Undoing file, UI or external effects on rollback | User action: Inspect and clean up those effects explicitly |
|
|
31
|
+
| Saving the model | User action: Save only when the user asks |
|
|
32
|
+
<!-- generated:contract:end -->
|
|
33
|
+
|
|
34
|
+
## Inputs and preconditions
|
|
35
|
+
|
|
36
|
+
Read [execution rules](../execution-rules.md). Verify unfamiliar classes, methods, enum names, and overloads using `search_api_docs` against the installed API before writing code. Its top match includes detailed documentation; narrow a query to promote the required match. Use `manage_revit_scripts` to store and inspect an exact reusable version when appropriate; saving a script does not execute it or save a model.
|
|
37
|
+
|
|
38
|
+
| Input | Meaning |
|
|
39
|
+
| --- | --- |
|
|
40
|
+
| `code` | Required nonempty C# top-level script. Additional `using` directives are allowed at the top. |
|
|
41
|
+
| `inputs` | Optional JSON object, default `{}`, available separately as the `inputs` global. At most 100,000 JSON characters. Values are never interpolated into code. Validate types, nested values, ranges, units, and target identities inside the script. |
|
|
42
|
+
| `expected_document_id` | Required even for code intended only to inspect: copy the intended model's exact current overview identity. |
|
|
43
|
+
| `expected_document` | Optional additional document-title check; never replaces identity. |
|
|
44
|
+
| `_operation_id` | Optional extension argument only for an identical retry of the original request. Omit for a new operation. |
|
|
45
|
+
|
|
46
|
+
There is no `preview` argument and no automatic preview mode. Do not imply that a script execution will roll back merely because the user asked to preview. Use a dedicated tool with a preview contract or prepare an explicit non-editing inspection when that satisfies the request. Model saving, exports, UI actions, and external access must be within the requested scope.
|
|
47
|
+
|
|
48
|
+
## Script execution rules
|
|
49
|
+
|
|
50
|
+
- Available globals are `doc` (`Document`), `uidoc` (`UIDocument`), `uiapp` (`UIApplication`), `inputs` (`System.Text.Json.JsonElement`), and `Dump(value)` for intermediate result values.
|
|
51
|
+
- Default imports are `System`, `System.Linq`, `System.Collections.Generic`, `Autodesk.Revit.DB`, and `Autodesk.Revit.UI`. Add other namespaces explicitly, such as `Autodesk.Revit.DB.Architecture`.
|
|
52
|
+
- The backend owns one transaction named `execute_csharp`. Do not start another `Transaction` on `doc`; subtransactions are allowed. Compilation occurs before opening it. Normal completion commits; failure attempts rollback and reports confirmed cleanup status.
|
|
53
|
+
- Code must be fully synchronous. `async` and `await` are rejected at compilation checks. Never block on `Task.Result` or `.Wait()`; they can freeze the Revit thread.
|
|
54
|
+
- Lengths use internal decimal feet. Convert deliberately with `UnitUtils.ConvertToInternalUnits`/`ConvertFromInternalUnits`. Discover exact API signatures and document units rather than assuming meters.
|
|
55
|
+
- Filter at collector level (`OfCategory`, `OfClass`, `WhereElementIsNotElementType`) and keep loops bounded. Activate a required `FamilySymbol` before `NewFamilyInstance`.
|
|
56
|
+
- The call budget is 120 seconds, not a force-stop guarantee. Running Revit work cannot be interrupted mid-script. A client timeout or cancellation does not cancel backend work.
|
|
57
|
+
- The dialog guard attempts dismissive responses and returns `suppressedDialogs`. It can cancel a confirmation-dependent action and cannot guarantee handling every modal dialog. Inspect its report rather than assuming the requested action completed.
|
|
58
|
+
|
|
59
|
+
## Example
|
|
60
|
+
|
|
61
|
+
This script performs no model edit or save, but still uses the normal script transaction and required document guard. Replace the identity placeholder with the exact current overview identity.
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
65
|
+
"code": "var value = inputs.GetProperty(\"value\").GetDouble(); if (!double.IsFinite(value)) throw new ArgumentException(\"value must be finite\"); return new { value, nonnegative = value >= 0 };",
|
|
66
|
+
"inputs": { "value": 12.5 },
|
|
67
|
+
"expected_document_id": "<project.documentId>"
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Results, recovery and verification
|
|
72
|
+
|
|
73
|
+
The final expression/return becomes `returnValue`; `Dump` values appear in `dumps`; `durationMs` reports execution duration. Return primitives, strings, or anonymous objects/lists. Projection converts elements to compact identity objects, `ElementId` to an integer, `XYZ` to `{x,y,z}`, and parameters to value summaries. Other raw Revit objects do not round-trip.
|
|
74
|
+
|
|
75
|
+
Ordinary CLR value projection is bounded: 200 dumps, depth 6, 100 sequence/dictionary items, 40 properties, and 4,000 characters per string. Special projections, including copied `JsonElement` values, follow their own paths. These intrinsic caps differ from large-result retrieval through `read_revit_result`; paging the saved response cannot recover values never serialized. Explicitly bound and summarize returned data, and make completeness clear.
|
|
76
|
+
|
|
77
|
+
The bridge adds `model_changes` to every committed script result: the elements the script added, modified and deleted (counts plus up to 20 items with name and category), and `new_views` with the visibility state of up to three new views. A script that changed nothing reports only `{ "observed": false }`. In a family document, `model_changes.family` lists family types and parameters added, removed or changed; they are not elements and never appear in `added` or `modified`. `modified` also lists elements Revit updated as a side effect of regeneration (`modified_note` says so): report as changed only what the script targeted. A view duplicated in a script inherits its source's hidden categories, hidden elements and overrides; `new_views` shows them, so compare that state with the request instead of relying on a capture. `modified` lists existing objects the script changed; a PI-Revit scope note marks one that predates the request and that the request names.
|
|
78
|
+
|
|
79
|
+
A `returnValueError` can accompany a successfully committed script whose return value failed projection. Do not rerun the script merely to recover that value. Report `commitWarnings` and `suppressedDialogs`; inspect errors for whether rollback was actually confirmed. Files, UI, and external effects are not undone by model rollback.
|
|
80
|
+
|
|
81
|
+
Follow [operation recovery](../operation-recovery.md) after a timeout, cancellation, failed result save, or uncertain response. Reuse an operation ID only with identical code, inputs, identity, and all other arguments. Reread the affected model state; follow [visual verification](../visual-verification.md) for visible results. No automatic model save is performed by the tool, but arbitrary code can request one, so inspect intended code effects before executing it.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# export_documents
|
|
2
|
+
|
|
3
|
+
## Purpose and boundaries
|
|
4
|
+
|
|
5
|
+
Export explicit sheets/views to PDF, DWG, or PNG, or export the model/one view's content to IFC. This tool writes files; IFC also commits model-side IFC GUID changes in a backend-owned transaction. There is no preview mode, no general file rollback, and no automatic Revit model save.
|
|
6
|
+
|
|
7
|
+
Contract: PI-Revit 0.5.0 source, [ExportDocuments.cs](../../../../src/Revit/Tools/ExportDocuments.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, 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:** `09e7464757ff2e48`. `find_revit_tools` compares it with the selected bridge's live contract.
|
|
17
|
+
|
|
18
|
+
| Input | Type | Required | Default | Allowed values |
|
|
19
|
+
| --- | --- | --- | --- | --- |
|
|
20
|
+
| `format` | string | yes | | `pdf`, `dwg`, `png`, `ifc` |
|
|
21
|
+
| `ids` | array of integer | no | | |
|
|
22
|
+
| `output_dir` | string | no | | |
|
|
23
|
+
| `file_name_prefix` | string | no | | |
|
|
24
|
+
| `combine` | boolean | no | | |
|
|
25
|
+
| `expected_document_id` | string | yes | | |
|
|
26
|
+
|
|
27
|
+
Bridge calls also accept `_operation_id`, only to retry an identical earlier request (see [operation recovery](../operation-recovery.md)).
|
|
28
|
+
|
|
29
|
+
| Not covered by this tool | Use instead |
|
|
30
|
+
| --- | --- |
|
|
31
|
+
| Formats other than PDF, DWG, PNG and IFC | Revit API: Document.Export overloads (e.g. DXFExportOptions, NavisworksExportOptions); verify the installed exporter. Check all its members in one call: `search_api_docs` with query `Document.Export; NavisworksExportOptions`, then use `execute_csharp` within the requested scope. |
|
|
32
|
+
| Printing to a physical printer | Revit API: PrintManager. Check all its members in one call: `search_api_docs` with query `PrintManager`, then use `execute_csharp` within the requested scope. |
|
|
33
|
+
<!-- generated:contract:end -->
|
|
34
|
+
|
|
35
|
+
## Inputs and preconditions
|
|
36
|
+
|
|
37
|
+
Exports and destinations must be within the user's requested scope. Read [execution rules](../execution-rules.md), discover target IDs with `get_elements`, and verify the intended model and view/sheet contents before delivery.
|
|
38
|
+
|
|
39
|
+
| Input | Meaning |
|
|
40
|
+
| --- | --- |
|
|
41
|
+
| `format` | Required: `pdf`, `dwg`, `png`, or `ifc`. |
|
|
42
|
+
| `ids` | PDF/DWG/PNG require 1–100 view/sheet IDs. IFC accepts at most one view ID; omission exports the whole model. Templates are rejected; PNG also rejects schedules. |
|
|
43
|
+
| `output_dir` | Optional explicit destination, created if absent. Omit for the model-specific default described below. |
|
|
44
|
+
| `file_name_prefix` | Optional base name, default document title; invalid filename characters are sanitized. Revit appends view/sheet suffixes for multi-file exports. |
|
|
45
|
+
| `combine` | PDF only: default true combines sheets/views into one PDF. False uses Revit's per-view naming rules. |
|
|
46
|
+
| `expected_document_id` | Required for every format, including PDF/PNG; use the intended model's exact current overview identity. |
|
|
47
|
+
| `_operation_id` | Optional extension argument only for an identical retry. Omit for a new operation. |
|
|
48
|
+
|
|
49
|
+
PNG uses a 2048-pixel horizontal fit; this differs from `capture_view`'s 1568-pixel long-edge cap. DWG availability depends on the Revit installation. Remaining export eligibility and format behavior are validated by Revit.
|
|
50
|
+
|
|
51
|
+
The default folder is `Documents\pi-revit\Models\<model title>--<identity hash>\exports`. Saved file paths or cloud/server identity determine the model folder; unsaved/unavailable identities use a session fallback. Save As can change the folder. The hash is not `project.documentId`. Use returned `outputDir` and file paths as authoritative; never reconstruct them from the title or opaque document ID. Existing title-only folders remain untouched.
|
|
52
|
+
|
|
53
|
+
## Example
|
|
54
|
+
|
|
55
|
+
Export only when requested. IDs `23456` and `23457` are illustrative committed sheet IDs; replace them with verified targets.
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"format": "pdf",
|
|
60
|
+
"ids": [23456, 23457],
|
|
61
|
+
"combine": true,
|
|
62
|
+
"file_name_prefix": "Room documentation",
|
|
63
|
+
"expected_document_id": "<project.documentId>"
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Results, recovery and verification
|
|
68
|
+
|
|
69
|
+
The result contains `format`, `outputDir`, `fileCount`, `files` with `path`/`fileSizeBytes`, and `commitWarnings`. New/changed files are detected by comparing output-directory timestamps; inspect actual returned paths and expected artifacts, especially in a shared destination. Existing filenames may be overwritten.
|
|
70
|
+
|
|
71
|
+
A failed export may leave partial files; errors identify observed changed files where possible. IFC model rollback does not remove already-written files. Report IFC warnings and inspect actual effects. No files are automatically removed on export failure.
|
|
72
|
+
|
|
73
|
+
Follow [operation recovery](../operation-recovery.md) after timeout/cancellation; the 120-second call budget does not prove export stopped. Do not retry with a new ID until the original outcome and output files are understood.
|
|
74
|
+
|
|
75
|
+
Verify that each expected file exists, is usable, and represents the requested scope. For drawings, open/render the actual exported artifact and follow [visual verification](../visual-verification.md), including readability and page completeness. A path or nonzero file size is not sufficient visual proof. Exporting evidence does not authorize saving the model.
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# find_revit_tools
|
|
2
|
+
|
|
3
|
+
## Purpose and preconditions
|
|
4
|
+
|
|
5
|
+
Find PI-Revit capabilities by task wording, see what each tool does **not** cover and what to use instead, and activate relevant registered tools before calling them. Registration, activation, and reading guidance are separate steps; this tool does not run the discovered Revit operation or read the manual for you.
|
|
6
|
+
|
|
7
|
+
Use default `scope: "available"` for native utilities and the selected bridge's last-discovered tools. A tool registered earlier in this Pi session can remain registered after switching bridges while no longer appearing in that available catalogue. Use `scope: "documentation"` to find packaged guidance without contacting Revit or activating tools, including while Revit is closed. A documentation entry is not proof that the selected bridge supports a capability.
|
|
8
|
+
|
|
9
|
+
<!-- generated:contract:start (npm run generate:contracts; do not edit this block) -->
|
|
10
|
+
## Contract (generated)
|
|
11
|
+
|
|
12
|
+
- **Source:** Pi extension utility, always active.
|
|
13
|
+
- **Writes model:** no. **Effects:** session. **Requires an open document:** no.
|
|
14
|
+
- **Verify the outcome:** `none`: no durable outcome to check; report what was done.
|
|
15
|
+
- **Contract hash:** `25e8fc4224d36256`. `find_revit_tools` compares it with the selected bridge's live contract.
|
|
16
|
+
|
|
17
|
+
| Input | Type | Required | Default | Allowed values |
|
|
18
|
+
| --- | --- | --- | --- | --- |
|
|
19
|
+
| `scope` | string | no | | `available`, `documentation` |
|
|
20
|
+
| `query` | string | no | | |
|
|
21
|
+
| `names` | array of string | no | | |
|
|
22
|
+
| `activate` | boolean | no | | |
|
|
23
|
+
| `offset` | integer | no | | |
|
|
24
|
+
| `limit` | integer | no | | |
|
|
25
|
+
|
|
26
|
+
| Not covered by this tool | Use instead |
|
|
27
|
+
| --- | --- |
|
|
28
|
+
| Reading manual contents | Tool: read (open the returned path) |
|
|
29
|
+
<!-- generated:contract:end -->
|
|
30
|
+
|
|
31
|
+
## Public inputs and examples
|
|
32
|
+
|
|
33
|
+
`query` takes short English task words. Tool vocabulary is English; when the user writes in another language, translate the request into English search words first and still reply in the user's language. Matching ignores case, accents, simple plural and word forms, and numbers, which are call arguments. Words are matched against each tool's name, declared keywords, packaged summary, declared limits, input names and live description. Tools that match every word are returned first, followed by strong partial matches. If no tool matches every word, the response has `match: "partial"` or `"none"`. Use separate queries or `names` for different capabilities.
|
|
34
|
+
|
|
35
|
+
Find and activate a known specialist:
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"names": ["manage_schedules"],
|
|
40
|
+
"activate": true
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Search by task wording, translated into English if the user wrote in another language:
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{ "query": "count walls per level" }
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Find manuals for an explanation without connecting to Revit:
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"scope": "documentation",
|
|
55
|
+
"names": ["manage_schedules", "get_schedule_fields"],
|
|
56
|
+
"limit": 20
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Browse without activating:
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
{ "offset": 0, "limit": 20 }
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Results and effects
|
|
67
|
+
|
|
68
|
+
The response reports `scope`, `match` (`all`, `partial`, `none`, `names` or `browse`), `bridge_catalog_known`, `bridge_catalog_observed_at`, paging fields (`total_count`, `offset`, `returned_count`, `next_offset`), `tools`, and `guidance`. A successful empty bridge catalogue is known empty; unknown means no successful discovery snapshot. Each tool entry gives its description, tier, effects and `source` (`native` or `bridge`), and these separate states:
|
|
69
|
+
|
|
70
|
+
- `registered`: the tool was registered in this Pi extension session. Bridge registrations can survive a switch even when the tool becomes inactive and the new bridge does not advertise it.
|
|
71
|
+
- `advertised_by_selected_bridge`: the selected bridge's last successful discovery snapshot advertises this tool. It is `null` before a successful snapshot and for native utilities; false can be meaningful after a known empty snapshot.
|
|
72
|
+
- `active`: the tool is exposed to the model. This does not prove current bridge support, a live connection, or a successful operation.
|
|
73
|
+
- `limits`: what the tool deliberately does not cover, each with an `alternative`. The kinds are `tool` (another public tool), `api` (Revit API members to verify with `search_api_docs` before custom execution), `user` (needs a user action or decision) or `revit_unsupported` (the Revit API itself does not offer it; the reference states the evidence). A tool from a newer bridge without declared limits reports them as unknown.
|
|
74
|
+
- `verification`: the minimum sufficient check of the tool's outcome (`reread`, `capture`, `inspect_output` or `none`).
|
|
75
|
+
|
|
76
|
+
When a query matches only partially or not at all, the result includes a `fallback` route. A missing dedicated tool is not evidence that the operation is impossible: verify the needed API members with `search_api_docs`, then use `execute_csharp` within the requested scope. Report "not possible" only after that check, naming what was checked. <!-- inv:limits-have-alternatives -->
|
|
77
|
+
|
|
78
|
+
`guidance` lists matching workflows, shared references and skills, including subject skills added to the package later, with absolute paths to read.
|
|
79
|
+
|
|
80
|
+
Each tool also carries a `documentation` object: `key`, absolute `path` when available, `status` (`available` or `missing`), `revision`, `package_version`, `packaged_contract_hash`, `live_contract_hash`, `observed_bridge_version` and `compatibility`. Missing, unreadable, non-file or outside-root manual targets are reported as missing without failing discovery; paths are resolved only inside the package. <!-- inv:manual-path-containment --> Compatibility compares the executable contract (input schema and declared effects) of the selected bridge's live tool with the contract its manual was generated from:
|
|
81
|
+
|
|
82
|
+
- `contract_match`: the manual was generated from this exact contract.
|
|
83
|
+
- `contract_changed`: the live contract differs. The active schema is authoritative; do not assume features the manual describes.
|
|
84
|
+
- `undocumented`: a newer bridge tool with no packaged manual.
|
|
85
|
+
- `unknown`: no live contract observed yet.
|
|
86
|
+
- `package_local`: a native utility shipped with this extension.
|
|
87
|
+
|
|
88
|
+
Wording changes to descriptions or guidelines do not change the contract.
|
|
89
|
+
|
|
90
|
+
Available-scope activation is additive: it preserves other Pi tools and activates the returned page, not every matching page. Partial pages default to five entries. Follow `next_offset` if more matches are needed. Newly activated schemas become available on the next model request; inspect them before constructing a call. Documentation scope only discovers references and leaves activation/connection state unchanged.
|
|
91
|
+
|
|
92
|
+
## Failures, recovery, and verification
|
|
93
|
+
|
|
94
|
+
Unknown exact names are rejected; check spelling, scope, and current bridge discovery. If a bridge tool is only in documentation scope, establish the intended running bridge and refresh via [ping](ping.md) before using it. If a selected instance becomes unavailable, use [manage_revit_instances](manage_revit_instances.md); the catalogue is not a live health check. Missing manuals do not establish tool unavailability, and manuals alone do not establish executability.
|
|
95
|
+
|
|
96
|
+
Verify the returned tool name, source, registration/activation, compatibility, and current schema. No document guard or `_operation_id` applies: discovery is not a model operation. Contract sources: `extensions/pi-revit/tool-catalog.ts`, `extensions/pi-revit/discovery.ts`, the generated contract snapshot and the documentation manifest. The inventory grows with the package; the current tool count is not an architectural limit.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# get_element_details
|
|
2
|
+
|
|
3
|
+
## Purpose and preconditions
|
|
4
|
+
|
|
5
|
+
Inspect known host elements: parameters, type information, location, model bounding box, or materials. This core tool requires the intended active document and discovered element IDs. For listing/filtering use `get_elements`; linked IDs do not identify elements in the host document.
|
|
6
|
+
|
|
7
|
+
<!-- generated:contract:start (npm run generate:contracts; do not edit this block) -->
|
|
8
|
+
## Contract (generated)
|
|
9
|
+
|
|
10
|
+
- **Source:** bridge tool, core tier: active by default.
|
|
11
|
+
- **Writes model:** no. **Effects:** none. **Requires an open document:** yes.
|
|
12
|
+
- **Works in:** project and family documents.
|
|
13
|
+
- **Contract hash:** `37ca1810049de7e3`. `find_revit_tools` compares it with the selected bridge's live contract.
|
|
14
|
+
|
|
15
|
+
| Input | Type | Required | Default | Allowed values |
|
|
16
|
+
| --- | --- | --- | --- | --- |
|
|
17
|
+
| `element_ids` | array of integer | yes | | |
|
|
18
|
+
| `parameter_names` | array of string | no | | |
|
|
19
|
+
| `include` | object | no | | |
|
|
20
|
+
| `expected_document_id` | string | no | | |
|
|
21
|
+
|
|
22
|
+
Bridge calls also accept `_operation_id`, only to retry an identical earlier request (see [operation recovery](../operation-recovery.md)).
|
|
23
|
+
|
|
24
|
+
| Not covered by this tool | Use instead |
|
|
25
|
+
| --- | --- |
|
|
26
|
+
| Listing or filtering elements | Tool: get_elements |
|
|
27
|
+
| Elements inside linked models | Tool: get_linked_elements |
|
|
28
|
+
| Exact solid geometry or faces | Revit API: Element.Geometry(Options). Check all its members in one call: `search_api_docs` with query `Element.Geometry`, then use `execute_csharp` within the requested scope. |
|
|
29
|
+
<!-- generated:contract:end -->
|
|
30
|
+
|
|
31
|
+
## Public inputs
|
|
32
|
+
|
|
33
|
+
- Required `element_ids`: 1–50 integer IDs per call. Batch larger requests yourself.
|
|
34
|
+
- Optional `parameter_names`: exact case-insensitive localized display names or `BuiltInParameter` enum names. Omission or an empty list returns all applicable parameters. This details filter does **not** support `guid:<GUID>` lookup; that syntax belongs to `get_elements` projections and filters.
|
|
35
|
+
- Optional `include`: `parameters` defaults true; `type_parameters`, `location`, `bounding_box`, and `materials` default false. Type parameters can be requested independently of instance parameters.
|
|
36
|
+
- Optional `expected_document_id`: exact document read guard. Optional `_operation_id`: previous exact operation ID for identical retry only.
|
|
37
|
+
|
|
38
|
+
## Example
|
|
39
|
+
|
|
40
|
+
The numeric ID is illustrative: replace it with an ID discovered in the intended host model.
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"element_ids": [12345],
|
|
45
|
+
"parameter_names": ["ALL_MODEL_MARK", "ALL_MODEL_INSTANCE_COMMENTS"],
|
|
46
|
+
"include": { "parameters": true, "type_parameters": true, "location": true, "bounding_box": true }
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Results and verification
|
|
51
|
+
|
|
52
|
+
`count` and `elements` cover found inputs; always inspect `not_found`. Returned identity includes type ID/name and level ID. Parameter rows carry `storageType`, `isType`, `isReadOnly`, `value`, and `displayValue`, with `builtInParameter`, shared GUID, and display-unit metadata where available. Preserve multiple same-named parameters; their names alone do not prove a unique writable identity.
|
|
53
|
+
|
|
54
|
+
Raw measurable values are internal Revit units, independent of the field named `unit` (which describes the formatted display unit). Locations, curve lengths, and bounding boxes use internal feet; point rotation is radians; material area/volume use square/cubic feet. There is no requested output-unit input. `displayValue` is formatted text and may be null.
|
|
55
|
+
|
|
56
|
+
`location` can be null, a point, or a bound curve's endpoints/length. `boundingBox` can be null and is not exact geometry. Material data comes from non-paint material IDs; unavailable areas/volumes can be omitted. Empty/partial geometry metadata is not evidence that an element has no physical geometry.
|
|
57
|
+
|
|
58
|
+
There is no query paging: batches are capped at 50 IDs. Finish any separately saved large response using [execution rules](../execution-rules.md). An empty parameter-name match in a localized model should prompt discovery of the actual name or built-in identity, not an assumption that the value is absent.
|
|
59
|
+
|
|
60
|
+
## Effects and recovery
|
|
61
|
+
|
|
62
|
+
Read-only: no edits, selection changes, saves, or exports. Missing individual IDs appear in `not_found`; an empty or oversized input batch fails. Re-discover replaced/deleted elements before a later write. Use [operation recovery](../operation-recovery.md) for identity/transport uncertainty; visual appearance still needs [visual verification](../visual-verification.md) when the broader task changes visible content.
|
|
63
|
+
|
|
64
|
+
## Compatibility
|
|
65
|
+
|
|
66
|
+
Source reference: PI-Revit 0.5.0, [GetElementDetails.cs](../../../../src/Revit/Tools/GetElementDetails.cs), with registry identity and extension retry inputs. Revit 2025–2027 bridge targets; source-reviewed, not newly validated live.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# get_element_relationships
|
|
2
|
+
|
|
3
|
+
## Purpose and preconditions
|
|
4
|
+
|
|
5
|
+
Inspect relationships of one known host element. Activate with `find_revit_tools`; discover the ID in the intended active document. Links are not traversed. Logical dependents are not a complete prediction of deletion effects; use an authorized `delete_elements` preview for its Revit-reported deletion cascade.
|
|
6
|
+
|
|
7
|
+
<!-- generated:contract:start (npm run generate:contracts; do not edit this block) -->
|
|
8
|
+
## Contract (generated)
|
|
9
|
+
|
|
10
|
+
- **Source:** bridge tool, advanced tier: activate it with `find_revit_tools`.
|
|
11
|
+
- **Writes model:** no. **Effects:** none. **Requires an open document:** yes.
|
|
12
|
+
- **Works in:** project and family documents.
|
|
13
|
+
- **Contract hash:** `c597f56ba5735470`. `find_revit_tools` compares it with the selected bridge's live contract.
|
|
14
|
+
|
|
15
|
+
| Input | Type | Required | Default | Allowed values |
|
|
16
|
+
| --- | --- | --- | --- | --- |
|
|
17
|
+
| `element_id` | integer | yes | | |
|
|
18
|
+
| `relationships` | array of string | no | | `type`, `level`, `owner_view`, `host`, `parent`, `subcomponents`, `group`, `assembly`, `members`, `joined`, `dependents` |
|
|
19
|
+
| `offset` | integer | no | | |
|
|
20
|
+
| `limit` | 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
|
+
| A complete prediction of deletion effects | Tool: delete_elements with preview |
|
|
28
|
+
<!-- generated:contract:end -->
|
|
29
|
+
|
|
30
|
+
## Public inputs
|
|
31
|
+
|
|
32
|
+
- Required `element_id`: integer host element ID.
|
|
33
|
+
- Optional `relationships`: array chosen from `type`, `level`, `owner_view`, `host`, `parent`, `subcomponents`, `group`, `assembly`, `members`, `joined`, and `dependents`. Omission requests all; names are case-sensitive.
|
|
34
|
+
- Optional `offset`: default 0; `limit`: 1–200, default 100. The same window is applied independently to every requested relationship.
|
|
35
|
+
- Optional `expected_document_id`: exact read guard. Optional `_operation_id`: exact ID for an identical previous-request retry only.
|
|
36
|
+
|
|
37
|
+
## Example
|
|
38
|
+
|
|
39
|
+
Replace the illustrative ID with an actual host element ID. A targeted relationship list keeps the result focused.
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{ "element_id": 12345, "relationships": ["type", "host", "dependents"], "limit": 100 }
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Results and verification
|
|
46
|
+
|
|
47
|
+
The result identifies `document_id` and `element_id`; `relationships` contains one independently paginated result per requested kind. Each has `total_count`, `returned_count`, `offset`, `has_more`, `next_offset`, and element identities. Results remove duplicate/invalid IDs and sort by element ID. Continue unfinished kinds individually rather than assuming one continuation covers all kinds.
|
|
48
|
+
|
|
49
|
+
`host`, `parent`, and `subcomponents` are family-instance relationships. `members` covers group or assembly members; `group` and `assembly` identify an element's containing membership. Empty results can mean the relationship is inapplicable. Null related-element metadata is not permission to assume a missing element's identity.
|
|
50
|
+
|
|
51
|
+
In a family document, explicitly request kinds excluding `joined`; the default includes it and fails because `JoinGeometryUtils` requires a project. Joined geometry is distinct from physical overlap and from hosted/dependent relationships.
|
|
52
|
+
|
|
53
|
+
Verify the relationship kind answers the question and preserve host-document context when using returned IDs. No coordinate/unit conversion is involved. Separately finish any saved-response retrieval under [execution rules](../execution-rules.md).
|
|
54
|
+
|
|
55
|
+
## Effects and recovery
|
|
56
|
+
|
|
57
|
+
Read-only: no join, unjoin, deletion, selection change, save, or export. Invalid element IDs or relationship kinds fail. Relationship discovery does not authorize editing dependents. Follow [operation recovery](../operation-recovery.md) for stale document or bridge failures.
|
|
58
|
+
|
|
59
|
+
## Compatibility
|
|
60
|
+
|
|
61
|
+
Source reference: PI-Revit 0.5.0, [GetElementRelationships.cs](../../../../src/Revit/Tools/GetElementRelationships.cs), plus identity/retry inputs. Revit 2025–2027 bridge targets; source review only, with no new live validation.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# get_element_types
|
|
2
|
+
|
|
3
|
+
## Purpose and preconditions
|
|
4
|
+
|
|
5
|
+
Discover loaded element types and family symbols, optionally distinguishing placed types from unused loaded types. This core tool requires the intended active document. Returned type IDs can scope `get_elements` or supply an appropriate later creation/type-change operation; availability alone does not establish compatibility with a target element.
|
|
6
|
+
|
|
7
|
+
<!-- generated:contract:start (npm run generate:contracts; do not edit this block) -->
|
|
8
|
+
## Contract (generated)
|
|
9
|
+
|
|
10
|
+
- **Source:** bridge tool, core tier: active by default.
|
|
11
|
+
- **Writes model:** no. **Effects:** none. **Requires an open document:** yes.
|
|
12
|
+
- **Works in:** project and family documents.
|
|
13
|
+
- **Contract hash:** `1eb28b6511ebb61e`. `find_revit_tools` compares it with the selected bridge's live contract.
|
|
14
|
+
|
|
15
|
+
| Input | Type | Required | Default | Allowed values |
|
|
16
|
+
| --- | --- | --- | --- | --- |
|
|
17
|
+
| `category` | string | no | | |
|
|
18
|
+
| `of_class` | string | no | | |
|
|
19
|
+
| `name_filter` | string | no | | |
|
|
20
|
+
| `include_instance_count` | boolean | no | | |
|
|
21
|
+
| `offset` | integer | no | | |
|
|
22
|
+
| `limit` | integer | no | | |
|
|
23
|
+
| `expected_document_id` | string | no | | |
|
|
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
|
+
| Creating or duplicating types | 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. |
|
|
30
|
+
| Loading 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. |
|
|
31
|
+
| The types of the family being edited in a family document | Revit API: FamilyManager.Types; FamilyManager.NewType; FamilyManager.Set; FamilyManager.AddParameter; FamilyManager.SetFormula. Check all its members in one call: `search_api_docs` with query `FamilyManager.Types; FamilyManager.NewType; FamilyManager.Set; FamilyManager.AddParameter; FamilyManager.SetFormula`, then use `execute_csharp` within the requested scope. |
|
|
32
|
+
<!-- generated:contract:end -->
|
|
33
|
+
|
|
34
|
+
## Public inputs
|
|
35
|
+
|
|
36
|
+
All are optional:
|
|
37
|
+
|
|
38
|
+
- `category`: localized category or built-in category name.
|
|
39
|
+
- `of_class`: element type class such as `WallType`, `FamilySymbol`, or `ViewFamilyType`.
|
|
40
|
+
- `name_filter`: case-insensitive substring of the type name or family name.
|
|
41
|
+
- `include_instance_count`: default false. Adds a pass through the scoped category, or the whole host model without a category.
|
|
42
|
+
- `offset`: default 0; `limit`: 1–1000, default 200.
|
|
43
|
+
- `expected_document_id`: exact optional read guard. `_operation_id`: optional identical-retry ID; omit on new calls.
|
|
44
|
+
|
|
45
|
+
## Example
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{ "category": "OST_Doors", "include_instance_count": true, "limit": 100 }
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
For view creation, use `of_class: "ViewFamilyType"`; for titleblocks use `category: "OST_TitleBlocks"`. Choose from actual returned IDs, not sample or remembered numbers.
|
|
52
|
+
|
|
53
|
+
## Results and verification
|
|
54
|
+
|
|
55
|
+
Read `types`, `total_count`, `returned_count`, `has_more`, and `next_offset`. Pages sort by family then type name. Rows contain `id`, `name`, `familyName`, `category`, and `isFamilySymbol`; `instanceCount` appears only when requested.
|
|
56
|
+
|
|
57
|
+
A zero instance count means no placed host instances counted for that type, not that the type is unloaded or safe to delete. Counts exclude linked contents. Verify family/category and inspect the type with `get_element_details` when a subsequent task depends on parameter values or compatibility. Type-name equality alone does not prove two types are interchangeable.
|
|
58
|
+
|
|
59
|
+
Follow query pagination and, independently, any saved-response continuation described in [execution rules](../execution-rules.md). There are no coordinate or unit inputs.
|
|
60
|
+
|
|
61
|
+
## Effects and recovery
|
|
62
|
+
|
|
63
|
+
Read-only; no type activation, creation, deletion, save, or selection change. Resolve invalid category/class errors using the installed API or current model information. Handle stale identity or bridge uncertainty through [operation recovery](../operation-recovery.md).
|
|
64
|
+
|
|
65
|
+
## Compatibility
|
|
66
|
+
|
|
67
|
+
Source reference: PI-Revit 0.5.0, [GetElementTypes.cs](../../../../src/Revit/Tools/GetElementTypes.cs), registry identity guard, and extension retry argument. Supported bridge targets: Revit 2025–2027. No new live validation is claimed.
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# get_elements
|
|
2
|
+
|
|
3
|
+
## Purpose and preconditions
|
|
4
|
+
|
|
5
|
+
List or count host-document instances of any category, including views, sheets, rooms, and levels. Use returned IDs for further inspection or host operations. This core tool requires an active document in the intended session. It excludes element types; use `get_element_types` for those. It does not traverse linked model contents.
|
|
6
|
+
|
|
7
|
+
<!-- generated:contract:start (npm run generate:contracts; do not edit this block) -->
|
|
8
|
+
## Contract (generated)
|
|
9
|
+
|
|
10
|
+
- **Source:** bridge tool, core tier: active by default.
|
|
11
|
+
- **Writes model:** no. **Effects:** none. **Requires an open document:** yes.
|
|
12
|
+
- **Works in:** project and family documents.
|
|
13
|
+
- **Contract hash:** `638881fcadf80086`. `find_revit_tools` compares it with the selected bridge's live contract.
|
|
14
|
+
|
|
15
|
+
| Input | Type | Required | Default | Allowed values |
|
|
16
|
+
| --- | --- | --- | --- | --- |
|
|
17
|
+
| `category` | string | no | | |
|
|
18
|
+
| `of_class` | string | no | | |
|
|
19
|
+
| `filter` | object | no | | |
|
|
20
|
+
| `level` | string | no | | |
|
|
21
|
+
| `type_id` | integer | no | | |
|
|
22
|
+
| `in_active_view` | boolean | no | | |
|
|
23
|
+
| `count_only` | boolean | no | | |
|
|
24
|
+
| `parameter_names` | array of string | no | | |
|
|
25
|
+
| `include_type_parameters` | boolean | no | | |
|
|
26
|
+
| `fields` | array of string | no | | `id`, `name`, `category`, `typeName`, `levelId` |
|
|
27
|
+
| `offset` | integer | no | | |
|
|
28
|
+
| `limit` | integer | no | | |
|
|
29
|
+
| `expected_document_id` | string | no | | |
|
|
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
|
+
| Elements inside linked models | Tool: get_linked_elements |
|
|
36
|
+
| Grouped counts or statistics over a whole scope | Tool: summarize_elements |
|
|
37
|
+
| Spatial containment or intersection | Tool: query_spatial_elements |
|
|
38
|
+
<!-- generated:contract:end -->
|
|
39
|
+
|
|
40
|
+
## Public inputs
|
|
41
|
+
|
|
42
|
+
All inputs are optional:
|
|
43
|
+
|
|
44
|
+
- Scope: `category` (display name or `BuiltInCategory` such as `OST_Walls`), `of_class` (Revit class name), `level` (name or ID represented as a string in the public schema), `type_id` (integer), and `in_active_view` (default false).
|
|
45
|
+
- `filter`: `{ "match": "all" | "any", "rules": [...] }`, default AND. Each rule requires `param` and `op`; `value` and `unit` depend on the operation. Parameters accept localized display names, built-in enum names, or `guid:<GUID>`.
|
|
46
|
+
- Rule `op`: `equals`, `not_equals`, `greater`, `greater_or_equal`, `less`, `less_or_equal`, `contains`, `is_empty`, `is_not_empty`, or `regex`. Empty checks do not need `value`; regex takes a pattern. Numeric comparison values use the supplied compatible `unit`, or the document's display units for that parameter.
|
|
47
|
+
- `count_only` (default false) returns only count information. `fields` selects identity fields `id`, `name`, `category`, `typeName`, `levelId`; `id` is always included, and all five are the default.
|
|
48
|
+
- `parameter_names`: up to 20 requested parameter identities. `include_type_parameters` (default false) also projects those identities from the type. Count-only mode ignores projections.
|
|
49
|
+
- `offset`: default 0. `limit`: 1–1000, default 200.
|
|
50
|
+
- `expected_document_id`: optional exact identity guard for this read. `_operation_id`: optional exact identical-retry ID. See [execution rules](../execution-rules.md) and [operation recovery](../operation-recovery.md).
|
|
51
|
+
|
|
52
|
+
## Examples
|
|
53
|
+
|
|
54
|
+
Count all host walls without transferring rows:
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{ "category": "OST_Walls", "count_only": true }
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Inspect a small parameter projection on matching doors:
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
{
|
|
64
|
+
"category": "OST_Doors",
|
|
65
|
+
"filter": { "rules": [{ "param": "ALL_MODEL_MARK", "op": "is_not_empty" }] },
|
|
66
|
+
"parameter_names": ["ALL_MODEL_MARK", "ALL_MODEL_INSTANCE_COMMENTS"],
|
|
67
|
+
"limit": 100
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Results and verification
|
|
72
|
+
|
|
73
|
+
Listing returns `total_count`, `returned_count`, `elements`, `offset`, `has_more`, and `next_offset`; follow every page required by the task. `total_count` covers all matches, not the page. Count-only results have `count_only: true` and no rows. A separately saved result has its own text-fragment continuation; reading that cannot recover element pages never requested.
|
|
74
|
+
|
|
75
|
+
Each parameter projection reports `requested`, `isType`, `found`, `ambiguous`, and `matches`. Preserve every match instead of silently choosing a duplicate name. Rows of special or system-owned objects carry a `traits` object, such as `titleblock_revision_schedule`, `placeholder_sheet`, `view_template`, `dependent_view_of`, `group_id`, `design_option_id` or `pinned`; ordinary elements have none. <!-- inv:special-objects-flagged --> Raw `value` uses Revit storage/internal numeric units; `displayValue` is formatted separately, and a reported `unit` names the display unit. This differs from numeric filter inputs.
|
|
76
|
+
|
|
77
|
+
Prefer built-in or shared GUID identities for stable filtering. Display-name rules and regex can scan the narrowed scope; a display name need not identify one globally uniform parameter. Narrow by category/class where possible. An unexpected zero plus a missing-parameter warning may be a localization problem, not absence of elements. Inspect details and use the discovered built-in identity. `is_empty` also matches elements that lack the parameter entirely. When the named parameter was not found on the probed elements, its warning is kept even though matches exist, because the matches may be elements without the parameter. <!-- inv:missing-not-silent --> A display name that matches several parameters on one element fails the query with their exact identities rather than silently choosing one; use one of those identities. <!-- inv:parameter-ambiguity -->
|
|
78
|
+
|
|
79
|
+
Verify scope before reporting counts. `in_active_view` is visibility-based and needs a suitable active view. Host IDs from this tool do not authorize changing the selection: use `manage_selection` separately within the requested scope.
|
|
80
|
+
|
|
81
|
+
## Effects and recovery
|
|
82
|
+
|
|
83
|
+
Read-only; no selection, model edit, save, or export. Invalid categories/classes/levels, malformed filters, or excessive projections fail. Recheck names and parameter identities rather than broadening a failed query silently. Query results are live reads, not retained snapshots; use `manage_element_sets` when fixed membership is needed. Follow shared recovery for identity and transport failures.
|
|
84
|
+
|
|
85
|
+
## Compatibility
|
|
86
|
+
|
|
87
|
+
Source reference: PI-Revit 0.5.0, [GetElements.cs](../../../../src/Revit/Tools/GetElements.cs) and [GetElementDetails.cs](../../../../src/Revit/Tools/GetElementDetails.cs) projection helper, plus public identity/retry inputs. Supported bridge targets are Revit 2025–2027; this is source review, not live validation.
|