pi-revit 0.3.1 → 0.4.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/CHANGELOG.md +388 -351
- package/README.md +426 -22
- package/extensions/pi-revit/index.ts +246 -187
- package/extensions/pi-revit/instance-router.ts +86 -0
- package/extensions/pi-revit/script-library.ts +146 -0
- package/extensions/pi-revit/tool-catalog.ts +67 -0
- package/package.json +59 -59
- package/skills/pi-revit/SKILL.md +196 -32
- package/skills/pi-revit/references/model-audit-export.md +29 -0
- package/skills/pi-revit/references/room-documentation.md +28 -0
- package/src/Revit/BridgeServer.cs +87 -37
- package/src/Revit/OperationStore.cs +178 -0
- package/src/Revit/ToolRegistry.cs +57 -35
- package/src/Revit/Tools/CaptureView.cs +2 -1
- package/src/Revit/Tools/ChangeElementTypes.cs +60 -0
- package/src/Revit/Tools/CreateTags.cs +95 -0
- package/src/Revit/Tools/DeleteElements.cs +44 -0
- package/src/Revit/Tools/DocumentGuard.cs +64 -64
- package/src/Revit/Tools/ElementQueryScope.cs +27 -0
- package/src/Revit/Tools/ExecuteCsharp.cs +45 -35
- package/src/Revit/Tools/ExportDocuments.cs +121 -120
- package/src/Revit/Tools/FailureGuard.cs +26 -26
- package/src/Revit/Tools/GetElementDetails.cs +42 -12
- package/src/Revit/Tools/GetElementRelationships.cs +76 -0
- package/src/Revit/Tools/GetElements.cs +37 -23
- package/src/Revit/Tools/GetLinkedElements.cs +82 -0
- package/src/Revit/Tools/GetLinkedModels.cs +66 -0
- package/src/Revit/Tools/GetModelCoordinates.cs +49 -0
- package/src/Revit/Tools/GetModelOverview.cs +2 -2
- package/src/Revit/Tools/GetScheduleFields.cs +37 -0
- package/src/Revit/Tools/GetSchedules.cs +89 -0
- package/src/Revit/Tools/ManageElementSets.cs +106 -0
- package/src/Revit/Tools/ManageSchedules.cs +164 -0
- package/src/Revit/Tools/ManageSelection.cs +37 -36
- package/src/Revit/Tools/ManageSheetPlacements.cs +97 -0
- package/src/Revit/Tools/ManageSheets.cs +63 -0
- package/src/Revit/Tools/ManageViews.cs +100 -0
- package/src/Revit/Tools/MeasureGeometry.cs +54 -0
- package/src/Revit/Tools/ModelEditBatch.cs +102 -0
- package/src/Revit/Tools/ModelEditInputs.cs +49 -0
- package/src/Revit/Tools/OpenView.cs +2 -1
- package/src/Revit/Tools/QuerySpatialElements.cs +63 -0
- package/src/Revit/Tools/SetParameters.cs +43 -93
- package/src/Revit/Tools/SpatialBounds.cs +30 -0
- package/src/Revit/Tools/SummarizeElements.cs +87 -0
- package/src/Revit/Tools/ToolSupport.cs +1 -1
- package/src/Revit/Tools/TransformElements.cs +58 -0
- package/workspace/AGENTS.md +45 -45
package/README.md
CHANGED
|
@@ -45,8 +45,10 @@ enforce mechanically, and is honest about what it cannot:
|
|
|
45
45
|
- Parameter writes, C# scripts, temporary isolation, and IFC export own named Revit
|
|
46
46
|
transactions. Failure handling is attached after transaction start, and results
|
|
47
47
|
check transaction outcomes before claiming commit or rollback. `set_parameters`
|
|
48
|
-
|
|
49
|
-
`
|
|
48
|
+
defaults to partial success; `atomic: true` rolls back the batch if any update
|
|
49
|
+
fails, and `preview: true` rolls back proposed model changes after validation.
|
|
50
|
+
Inspect every failed update, the validation status, and `commitWarnings`.
|
|
51
|
+
An unconfirmed rollback is reported as such.
|
|
50
52
|
- `execute_csharp` is an unrestricted escape hatch by design — scripts have full CLR access.
|
|
51
53
|
Treat it like giving the agent a macro editor, on a model you have saved or can restore.
|
|
52
54
|
- `execute_csharp` has a dialog guard that attempts dismissive responses to dialogs
|
|
@@ -70,8 +72,13 @@ unchanged into `expected_document_id` on subsequent operations:
|
|
|
70
72
|
```
|
|
71
73
|
|
|
72
74
|
Replace the placeholders with the current document ID and an actual element ID.
|
|
73
|
-
The exact ID is required for `set_parameters`, `
|
|
74
|
-
`
|
|
75
|
+
The exact ID is required for `set_parameters`, `transform_elements`,
|
|
76
|
+
`delete_elements`, `change_element_types`, `manage_views`, `manage_sheets`,
|
|
77
|
+
`manage_sheet_placements`, `manage_schedules`, `create_tags`, `execute_csharp`,
|
|
78
|
+
`export_documents`, and `open_view`,
|
|
79
|
+
including supported previews. `manage_sheet_placements` requires it even for its
|
|
80
|
+
read-only `list` action because the tool is classified as write-capable.
|
|
81
|
+
It is also required for selection/zoom
|
|
75
82
|
changes and any `manage_selection` call with `isolate_in_view: true`, including
|
|
76
83
|
action `get`. Pure reads may omit it; a supplied ID is always checked.
|
|
77
84
|
|
|
@@ -208,22 +215,416 @@ Plain `pi` from any folder also works; `pi-revit` just adds the right working fo
|
|
|
208
215
|
|
|
209
216
|
## Tools
|
|
210
217
|
|
|
211
|
-
| Tool | What it does |
|
|
212
|
-
|---|---|
|
|
213
|
-
| `
|
|
214
|
-
| `
|
|
215
|
-
| `
|
|
218
|
+
| Tool | What it does |
|
|
219
|
+
|---|---|
|
|
220
|
+
| `find_revit_tools` | Search the native tool catalogue and activate specialist tools for the current Pi session. |
|
|
221
|
+
| `ping` | Is the bridge reachable? Revit version |
|
|
222
|
+
| `manage_revit_instances` | List reachable local Revit sessions or select the target for this Pi session |
|
|
223
|
+
| `get_model_overview` | Project info, units, levels, grids, category counts — call first |
|
|
224
|
+
| `get_model_coordinates` | Read base points and site/project locations; map internal points through the active shared coordinates |
|
|
225
|
+
| `get_elements` | Query/count elements: parameter filters, optional parameter values, pagination |
|
|
226
|
+
| `summarize_elements` | Count all matching elements by category, type, level, or raw parameter value |
|
|
227
|
+
| `manage_element_sets` | Create, list, read, or forget temporary snapshots of matching host elements |
|
|
216
228
|
| `get_element_details` | Parameter values, location, bounding box, materials per element |
|
|
217
|
-
| `get_element_types` | Element types / family symbols, optional placed-instance counts |
|
|
229
|
+
| `get_element_types` | Element types / family symbols, optional placed-instance counts |
|
|
230
|
+
| `get_linked_models` | Direct Revit link instances, load status, document identities, placement transforms |
|
|
231
|
+
| `get_linked_elements` | Query/count one loaded link, with optional bounding boxes in host coordinates |
|
|
232
|
+
| `query_spatial_elements` | Find host elements by approximate bounding-box intersection or containment in a region |
|
|
233
|
+
| `measure_geometry` | Measure exact point distance or approximate host-element bounding-box separation |
|
|
234
|
+
| `get_schedules` | List schedules or read fields, widths, specifications, sort/filter rules, and displayed cells |
|
|
235
|
+
| `get_schedule_fields` | Discover eligible field parameter/type pairs for an existing schedule |
|
|
236
|
+
| `manage_schedules` | Create or configure regular schedules, including fields, widths, sorting, and filters |
|
|
237
|
+
| `create_tags` | Create host element, room, space, or area tags, with partial/atomic batches and preview |
|
|
238
|
+
| `get_element_relationships` | Host, type, level, members, joined geometry, and logical dependents of one element |
|
|
218
239
|
| `manage_selection` | Get/set/clear the selection, zoom, temporary isolate |
|
|
219
240
|
| `open_view` | Activate a view or sheet in the Revit UI (like double-clicking it in the browser) |
|
|
220
|
-
| `set_parameters` | Bulk parameter writes
|
|
241
|
+
| `set_parameters` | Bulk parameter writes and renames, with previews and optional atomic batches |
|
|
242
|
+
| `transform_elements` | Move, copy, or rotate a whole selection, with explicit units and preview |
|
|
243
|
+
| `delete_elements` | Preview or delete selected elements and report Revit's full deletion set |
|
|
244
|
+
| `change_element_types` | Change types per target, with preview and optional atomic rollback |
|
|
245
|
+
| `manage_views` | Create plans, isometric 3D views, or sections; duplicate or update views |
|
|
246
|
+
| `manage_sheets` | Create, rename, or renumber sheets, with an optional titleblock at creation |
|
|
247
|
+
| `manage_sheet_placements` | List, place, or move viewports and schedule instances in sheet paper space |
|
|
221
248
|
| `search_api_docs` | Search the offline Revit API docs (works with no document open) |
|
|
222
|
-
| `execute_csharp` | Run a C# script in one auto-managed transaction
|
|
249
|
+
| `execute_csharp` | Run a C# script with separate JSON inputs in one auto-managed transaction |
|
|
250
|
+
| `manage_revit_scripts` | Save immutable local script versions, inspect source, run an exact version, and read history |
|
|
223
251
|
| `capture_view` | PNG snapshot of a view to a temp file (read the returned path to see it) |
|
|
224
252
|
| `export_documents` | PDF/DWG/PNG/IFC export of sheets and views — sorted into `Models\<title>--<identity hash>\exports` |
|
|
225
253
|
| `get_model_health` | Warnings grouped + worksets, phases, design options audit |
|
|
226
254
|
| `read_revit_result` | Read bounded fragments of a saved large tool result; extension-only, no Revit call |
|
|
255
|
+
| `get_revit_operation` | Inspect a bridge operation receipt and its retained result without waiting for the model thread |
|
|
256
|
+
|
|
257
|
+
### Choose a Revit instance
|
|
258
|
+
|
|
259
|
+
`manage_revit_instances` defaults to `action: "list"`. It reports reachable
|
|
260
|
+
local bridge sessions with an opaque `bridge_id`, process ID, Revit/add-in
|
|
261
|
+
versions, selection status, and operation-tracking support. Choose the intended
|
|
262
|
+
session with `action: "select"` and the exact returned `bridge_id`. Selection
|
|
263
|
+
belongs to the current Pi extension session; it does not activate a document
|
|
264
|
+
or change the model.
|
|
265
|
+
|
|
266
|
+
When the first connection finds a sole instance, Pi binds to it automatically.
|
|
267
|
+
If several instances are available before a target is bound, explicitly select
|
|
268
|
+
one before model calls. Once bound, Pi keeps that exact bridge session. If it
|
|
269
|
+
closes or restarts, calls fail instead of switching to another instance, even
|
|
270
|
+
when only one remains. List again and explicitly select the intended new
|
|
271
|
+
identity. Selection refreshes the tool catalogue; check `tool_catalog_ready`,
|
|
272
|
+
and retry `ping` if discovery has not completed. Then read `get_model_overview`
|
|
273
|
+
for a fresh document identity before continuing work.
|
|
274
|
+
|
|
275
|
+
Each current bridge publishes its own discovery file in
|
|
276
|
+
`%APPDATA%\RevitBridge\instances\<bridgeId>.json`. The legacy `bridge.json`
|
|
277
|
+
discovery file is still supported. Older bridges without a generation ID receive
|
|
278
|
+
an opaque hash selector in the instance list; copy it unchanged rather than
|
|
279
|
+
constructing one. Legacy discovery can expose only the older instance named by
|
|
280
|
+
that shared file, so updating each add-in enables discovery of all instances.
|
|
281
|
+
|
|
282
|
+
Operation receipts and identical `_operation_id` retries route to the original
|
|
283
|
+
bridge encoded in the operation ID, even after selecting a different instance.
|
|
284
|
+
They do not switch the target for new calls. If the original bridge is unavailable,
|
|
285
|
+
the request fails without sending the action to another session.
|
|
286
|
+
|
|
287
|
+
### Read project coordinates
|
|
288
|
+
|
|
289
|
+
`get_model_coordinates` reads project/survey base points, the active project
|
|
290
|
+
location, site data, and paginated project locations. Supply a length `unit`;
|
|
291
|
+
optional `points` accepts up to 100 positions along document internal axes.
|
|
292
|
+
Revit's active project location maps those points to shared coordinates. Returned
|
|
293
|
+
lengths use the requested unit, while angles and latitude/longitude use degrees.
|
|
294
|
+
Location pages default to 50 entries (maximum 100); follow `next_offset`.
|
|
295
|
+
The tool requires a project document, makes no coordinate changes, and does not
|
|
296
|
+
infer a GIS coordinate reference system or datum.
|
|
297
|
+
|
|
298
|
+
### Query regions and measure distances
|
|
299
|
+
|
|
300
|
+
`query_spatial_elements` takes a region `min`/`max` in the document's internal
|
|
301
|
+
axes and an explicit length `unit`. It compares host-element axis-aligned
|
|
302
|
+
bounding boxes with the region, using `intersects` (default) or `inside`.
|
|
303
|
+
Containment requires the whole box to fit; touching boundaries are included.
|
|
304
|
+
The nested `query` uses whole-scope element filters and must match at most
|
|
305
|
+
10,000 candidates before region testing. Query-level paging and projections
|
|
306
|
+
are not accepted. Results sort by element ID with outer paging (default 100,
|
|
307
|
+
maximum 200); follow `next_offset`. `without_bounds_count` reports candidates
|
|
308
|
+
omitted because they have no model bounding box.
|
|
309
|
+
|
|
310
|
+
`measure_geometry` measures exact Euclidean distance between supplied points
|
|
311
|
+
with `mode: "point_distance"`, or approximate bounding-box separation between
|
|
312
|
+
two host elements with `mode: "bounding_box_gap"`. Point mode returns signed
|
|
313
|
+
A-to-B `delta`; box mode returns nonnegative axis gaps. The required `unit`
|
|
314
|
+
applies to all inputs and outputs: millimeters, centimeters, meters, feet, or
|
|
315
|
+
inches. Both modes use document internal axes; linked contents are not traversed.
|
|
316
|
+
|
|
317
|
+
Bounding-box gaps are lower bounds on geometry separation. Boxes can enclose
|
|
318
|
+
nonphysical geometry, so touching/overlapping boxes do not establish a clash.
|
|
319
|
+
An optional nonnegative `clearance` in box mode flags gaps strictly below that
|
|
320
|
+
threshold; it identifies review candidates, not verified clearance failures.
|
|
321
|
+
Keep the returned method and approximation status with any reported result.
|
|
322
|
+
|
|
323
|
+
Practical workflows are available in the Pi skill references:
|
|
324
|
+
[room documentation](skills/pi-revit/references/room-documentation.md) and
|
|
325
|
+
[model audit and export](skills/pi-revit/references/model-audit-export.md).
|
|
326
|
+
|
|
327
|
+
### Read parameter values and summarize queries
|
|
328
|
+
|
|
329
|
+
Add `parameter_names` to `get_elements` to read up to 20 requested parameters
|
|
330
|
+
alongside element identity fields. Names can be display names, built-in parameter
|
|
331
|
+
names, or `guid:<GUID>` identities. `include_type_parameters: true` also reads
|
|
332
|
+
those parameters from each element's type. Projections expose missing and
|
|
333
|
+
ambiguous matches and include every matching parameter. Raw `value` uses Revit
|
|
334
|
+
internal units for measurable numbers; `displayValue` uses document formatting.
|
|
335
|
+
Bare counts return no parameter projections.
|
|
336
|
+
|
|
337
|
+
`summarize_elements` groups a host-element `query` by `category`, `typeName`,
|
|
338
|
+
`levelId`, or `parameter`. Parameter grouping uses exact raw values, with a
|
|
339
|
+
separate missing-parameter group, and rejects ambiguous display names. Set
|
|
340
|
+
`type_parameter: true` to group by a parameter on the type. The outer
|
|
341
|
+
`offset`/`limit` pages groups (default 100, maximum 500); counts always cover the
|
|
342
|
+
whole matching scope.
|
|
343
|
+
|
|
344
|
+
`summarize_elements` and element-set creation accept category, class, level,
|
|
345
|
+
type, active-view, and parameter filters inside `query`. They reject query-level
|
|
346
|
+
paging, projections, and `count_only`, and require at most 10,000 matching
|
|
347
|
+
elements. Narrow larger queries; an omitted query covers all host instances.
|
|
348
|
+
|
|
349
|
+
### Reuse an element set
|
|
350
|
+
|
|
351
|
+
Use `manage_element_sets` with `action: "create"` to snapshot query membership,
|
|
352
|
+
then `read` its `set_id`, `list` active-document sets, or `forget` a set. This
|
|
353
|
+
changes neither the model nor selection. The bridge retains at most 32 sets;
|
|
354
|
+
each expires 30 minutes after creation and belongs to the exact open document
|
|
355
|
+
and bridge session. Reads do not renew it. Reopening the document or restarting
|
|
356
|
+
the bridge requires a fresh set.
|
|
357
|
+
|
|
358
|
+
Read pages return current values for the original members, without reapplying
|
|
359
|
+
the query. Deleted or identity-changed members appear in `missing`. Check those
|
|
360
|
+
entries before passing surviving IDs to other tools. Pages default to 100
|
|
361
|
+
members (maximum 1000); follow `next_offset`, which includes missing members in
|
|
362
|
+
`visited_count`. Set reads also support `parameter_names` and
|
|
363
|
+
`include_type_parameters`.
|
|
364
|
+
|
|
365
|
+
### Preview parameter changes
|
|
366
|
+
|
|
367
|
+
`set_parameters` accepts 1–200 updates and defaults to committing successful
|
|
368
|
+
updates while reporting failures. Each update has its own subtransaction.
|
|
369
|
+
`atomic: true` rolls back the entire batch if any update fails. `preview: true`
|
|
370
|
+
performs eligible commit checks inside a transaction group, then rolls the
|
|
371
|
+
group back. Both options require the same exact document identity as an ordinary
|
|
372
|
+
write and can be combined.
|
|
373
|
+
|
|
374
|
+
Read `commit_validation_performed`: an atomic batch rejected before commit, or
|
|
375
|
+
a batch with no accepted updates, has not passed commit-time validation.
|
|
376
|
+
Successful preview responses confirm model rollback. Errors report the cleanup
|
|
377
|
+
outcome instead; inspect it before retrying.
|
|
378
|
+
|
|
379
|
+
Only committed updates appear in `succeeded`. Accepted steps from previews or
|
|
380
|
+
rolled-back batches appear in `proposed`, with `updated: 0` and
|
|
381
|
+
`committed: false`. Their `before`/`after` values describe each step in input
|
|
382
|
+
order, identified by its zero-based `index`. Repeated writes can have intermediate
|
|
383
|
+
values; reread the element when final values matter. Inspect `failed` and
|
|
384
|
+
`commitWarnings` as well. Numeric write inputs use the explicit `unit` or the
|
|
385
|
+
document's display units; raw numeric values in the returned snapshots use
|
|
386
|
+
Revit internal units.
|
|
387
|
+
|
|
388
|
+
### Transform, delete, and change types
|
|
389
|
+
|
|
390
|
+
These advanced tools can be activated with `find_revit_tools`. They operate on
|
|
391
|
+
the active host document and require `expected_document_id` for both previews
|
|
392
|
+
and writes. Their results use the same `succeeded`, `proposed`, `failed`,
|
|
393
|
+
`committed`, and commit-validation fields as parameter batches. `updated` counts
|
|
394
|
+
steps: one whole-selection transform or deletion counts as one step.
|
|
395
|
+
|
|
396
|
+
`transform_elements` moves, copies, or rotates 1–200 distinct `element_ids`
|
|
397
|
+
together. Always supply `unit`: `millimeters`, `centimeters`, `meters`, `feet`,
|
|
398
|
+
or `inches`. Move/copy takes a `translation` vector. Rotation takes an
|
|
399
|
+
`axis_origin`, a nonzero dimensionless `axis_direction`, and signed right-hand
|
|
400
|
+
`angle_degrees`. Coordinates refer to the document's internal origin and axes;
|
|
401
|
+
returned location snapshots use feet, regardless of input units. The selection
|
|
402
|
+
succeeds or rolls back as one step. Move/rotate rejects pinned requested
|
|
403
|
+
elements; the tool never unpins them automatically. Copy previews return
|
|
404
|
+
temporary `created_ids`, which must not be reused after rollback.
|
|
405
|
+
|
|
406
|
+
`delete_elements` deletes 1–200 distinct requested elements in one step, rejecting
|
|
407
|
+
pinned requested elements. Use `preview: true` to inspect Revit's complete
|
|
408
|
+
`deleted_ids` set and its `dependent_ids`, with rollback. A cascade exceeding
|
|
409
|
+
10,000 IDs rolls back. To check a later deletion against the preview, optionally
|
|
410
|
+
pass the full `deleted_ids` as `expected_deleted_ids`; a changed set causes
|
|
411
|
+
rollback before commit. This compares membership only. The actual deletion is
|
|
412
|
+
a new request, not an identical retry of the preview, so do not reuse the
|
|
413
|
+
preview's `_operation_id` for it.
|
|
414
|
+
|
|
415
|
+
`change_element_types` accepts 1–200 `element_id`/`type_id` pairs in `updates`,
|
|
416
|
+
with each target appearing once. Invalid types or pinned targets fail individually;
|
|
417
|
+
other valid changes can commit by default. `atomic: true` rolls back the complete
|
|
418
|
+
batch on any failure. Some type changes replace the original element: use the
|
|
419
|
+
committed `resulting_id` and `unique_id` afterward. Replacement IDs reported in
|
|
420
|
+
`proposed` are temporary after preview or atomic rollback.
|
|
421
|
+
|
|
422
|
+
Transforms and type changes can affect constrained or hosted elements beyond
|
|
423
|
+
the target snapshots. Deletion IDs cover elements returned by Revit's deletion
|
|
424
|
+
API, not surviving elements Revit may also modify. Review these results as
|
|
425
|
+
bounded descriptions of the operation, not a complete audit of every effect.
|
|
426
|
+
|
|
427
|
+
### Create views and arrange sheets
|
|
428
|
+
|
|
429
|
+
Activate `manage_views`, `manage_sheets`, and `manage_sheet_placements` through
|
|
430
|
+
`find_revit_tools`. Edits support `preview: true` and require the exact document
|
|
431
|
+
identity. Each call edits one view, sheet, or placement in one step. Created IDs
|
|
432
|
+
in previews are marked `id_is_temporary` and must not be reused after rollback.
|
|
433
|
+
Inspect the common transaction outcome and validation fields. Use `open_view`
|
|
434
|
+
to display committed views/sheets and `delete_elements` to remove them.
|
|
435
|
+
|
|
436
|
+
`manage_views` supports `create_plan`, `create_3d`, `create_section`, `duplicate`,
|
|
437
|
+
and `update`. Creation uses a compatible `view_family_type_id`; discover it with
|
|
438
|
+
`get_element_types` and `of_class: "ViewFamilyType"`. Plans also need `level_id`;
|
|
439
|
+
3D creation produces an isometric view. Duplicate/update targets `view_id`.
|
|
440
|
+
Duplication options are `duplicate`, `with_detailing`, and `dependent` where
|
|
441
|
+
supported. Optional name, scale, and template apply in the same step. Template
|
|
442
|
+
ID `-1` removes a template explicitly; incompatible templates or controlled
|
|
443
|
+
scale changes fail without automatically removing the template.
|
|
444
|
+
|
|
445
|
+
Sections use the document's internal coordinate frame. Supply `origin`, explicit
|
|
446
|
+
length `unit`, orthogonal nonzero `viewing_direction` and `up`, and positive
|
|
447
|
+
width/height/depth. Width and height center on the origin; depth extends in the
|
|
448
|
+
viewing direction. Direction vectors are dimensionless.
|
|
449
|
+
|
|
450
|
+
`manage_sheets` creates a sheet from `name` and `number`, optionally using a loaded
|
|
451
|
+
titleblock `FamilySymbol` specified by `titleblock_type_id`. Omitting it creates
|
|
452
|
+
a sheet without a titleblock. Updates use `sheet_id` and name/number; changing
|
|
453
|
+
an existing titleblock type uses `change_element_types` on its instance instead.
|
|
454
|
+
|
|
455
|
+
`manage_sheet_placements` lists both viewports and schedule instances for a
|
|
456
|
+
`sheet_id` (default 100 per page, maximum 200). Follow `next_offset`. Although
|
|
457
|
+
listing changes no model state, the tool's write-capable metadata means
|
|
458
|
+
`expected_document_id` is required for this action too.
|
|
459
|
+
|
|
460
|
+
To place content, supply `sheet_id`, `view_id`, explicit `unit`, and
|
|
461
|
+
`position: [x,y,0]`; to move it, supply `placement_id`, unit, and position.
|
|
462
|
+
Positions are paper-space sheet coordinates and must never be multiplied by
|
|
463
|
+
view scale. Viewports use their box center excluding the label; schedules use
|
|
464
|
+
their insertion point. Returned positions use feet and state `position_kind`.
|
|
465
|
+
Viewports support rotation `none`, `clockwise`, or `counterclockwise`; omit
|
|
466
|
+
rotation for schedules. Pinned placements cannot be moved, placeholder sheets
|
|
467
|
+
cannot receive content, and Revit checks whether a view can be placed.
|
|
468
|
+
|
|
469
|
+
### Configure schedules and create tags
|
|
470
|
+
|
|
471
|
+
`manage_schedules` creates a regular schedule from `category` and `name`, with
|
|
472
|
+
an optional `area_scheme_id` for area schedules. Configure an existing schedule
|
|
473
|
+
with `schedule_id`. Each call is one atomic step, requires `expected_document_id`,
|
|
474
|
+
and supports preview rollback. Revision schedules, templates, embedded schedules,
|
|
475
|
+
and calculated/combined-field authoring are outside this tool.
|
|
476
|
+
|
|
477
|
+
Use `get_schedule_fields` to discover eligible fields for an existing schedule.
|
|
478
|
+
It supports localized name filtering and paging (default 100, maximum 200).
|
|
479
|
+
`add_fields` identifies each field by its `parameter_id` plus `field_type` pair;
|
|
480
|
+
negative built-in parameter IDs are valid. When Count appears in discovery,
|
|
481
|
+
pass its returned pair unchanged, just like other fields. Count can also be
|
|
482
|
+
added as `{ "field_type": "Count" }` without a parameter ID. A supplied pair
|
|
483
|
+
must be eligible for the target schedule; do not guess its parameter ID.
|
|
484
|
+
`included` marks pairs already present.
|
|
485
|
+
|
|
486
|
+
In contrast, `update_fields`, `sort_fields`, and `filters` use the schedule-local
|
|
487
|
+
`field_id` returned by `get_schedules`. These IDs are neither parameter IDs nor
|
|
488
|
+
column indices. Read newly committed fields before assigning their sort/filter
|
|
489
|
+
rules. New schedule and field IDs returned by previews are temporary.
|
|
490
|
+
|
|
491
|
+
Field additions and updates support heading, hidden state, and width, with up
|
|
492
|
+
to 50 entries each. Widths require explicit length units and apply to both grid
|
|
493
|
+
and sheet columns. `sort_fields` allows four rules; `filters` allows eight.
|
|
494
|
+
Supplying either array replaces its entire list, including clearing it with
|
|
495
|
+
`[]`; omitting the property preserves it. `is_itemized` controls itemization.
|
|
496
|
+
|
|
497
|
+
Filter comparisons are `equals`, `not_equals`, `contains`, `greater_than`, or
|
|
498
|
+
`less_than`. Supply a matching `value_type` and value. Measured numeric filters
|
|
499
|
+
require an explicit compatible `unit`; unitless numbers must omit it.
|
|
500
|
+
`get_schedules` exposes each field's specification, filtering capabilities,
|
|
501
|
+
grid/sheet widths in feet, and current sort/filter rules. Returned numeric filter
|
|
502
|
+
values use internal units; returned comparison names use Revit enums rather
|
|
503
|
+
than the write schema's comparison strings.
|
|
504
|
+
|
|
505
|
+
`create_tags` accepts 1–100 host-document targets in one explicit view, using a
|
|
506
|
+
loaded tag `FamilySymbol`. Choose `kind` as `element`, `room`, `space`, or `area`.
|
|
507
|
+
Each target has `element_id` and `head_position: [x,y,z]` in document internal
|
|
508
|
+
coordinates, using the required length `unit`. The position always means the
|
|
509
|
+
tag head, including when `leader: true`; returned positions use feet. Linked
|
|
510
|
+
targets and face/subelement references are unsupported.
|
|
511
|
+
|
|
512
|
+
Element tags support horizontal/vertical orientation. Spatial tags require a
|
|
513
|
+
compatible plan view and positions at the spatial element's level; omit their
|
|
514
|
+
orientation property. Independent tags cannot use templates, perspective views,
|
|
515
|
+
or unlocked 3D views. Creation requires exact document targeting, defaults to
|
|
516
|
+
partial success, and supports `atomic: true` and `preview: true`. IDs in
|
|
517
|
+
`proposed` are temporary after preview or atomic rollback; use only committed
|
|
518
|
+
tag IDs for subsequent calls.
|
|
519
|
+
|
|
520
|
+
### Inspect links, schedules, and relationships
|
|
521
|
+
|
|
522
|
+
Call `get_linked_models` before querying a link. Pass its `link_instance_id` and
|
|
523
|
+
`linked_document_id` to `get_linked_elements` as `link_instance_id` and
|
|
524
|
+
`expected_linked_document_id`. The optional `expected_document_id` still identifies
|
|
525
|
+
the active host model. Refresh discovery after unloading or reloading a link.
|
|
526
|
+
Queries support `get_elements` filters and pagination, except active-view scoping.
|
|
527
|
+
Unloaded links cannot be queried, and nested links are not traversed.
|
|
528
|
+
|
|
529
|
+
Keep the full `reference` returned for each linked element: its numeric ID belongs
|
|
530
|
+
to the linked document and must not be used with host selection or write tools.
|
|
531
|
+
Different placements of one linked model can produce different host coordinates.
|
|
532
|
+
Optional `host_bounds` use internal feet and enclose all eight transformed box
|
|
533
|
+
corners; they are axis-aligned bounds, not exact geometry. A missing box is null.
|
|
534
|
+
|
|
535
|
+
Use `get_schedules` without an ID to list schedules, or with `schedule_id` to read
|
|
536
|
+
field definitions, width/specification metadata, sort/filter rules, and displayed
|
|
537
|
+
body cells. Text follows Revit's formatting and
|
|
538
|
+
can include grouped entries, headings, and totals; rows are not element IDs.
|
|
539
|
+
Hidden field definitions need not correspond to displayed columns. Follow both
|
|
540
|
+
`next_offset` and `next_column_offset`: finish the column pages for a row page
|
|
541
|
+
before moving to the next rows. List/body pages default to 50 entries (maximum
|
|
542
|
+
200); column pages default to 50 (maximum 50).
|
|
543
|
+
|
|
544
|
+
`get_element_relationships` reports each requested relationship separately, with
|
|
545
|
+
its own count and continuation offset. It reads host-document relationships only;
|
|
546
|
+
logical dependents are not a complete deletion-impact prediction. In family
|
|
547
|
+
documents, request relationship kinds that exclude `joined`. Relationship pages
|
|
548
|
+
default to 100 entries (maximum 200). Link-instance pages default to 100 (maximum
|
|
549
|
+
1000), and linked-element pages default to 200 (maximum 1000).
|
|
550
|
+
|
|
551
|
+
### Reuse a script with structured inputs
|
|
552
|
+
|
|
553
|
+
`execute_csharp` accepts an optional `inputs` JSON object separately from its
|
|
554
|
+
source code. The script reads it through the `inputs` `JsonElement` global,
|
|
555
|
+
for example `inputs.GetProperty("value").GetDouble()`. Inputs default to an
|
|
556
|
+
empty object and are not interpolated into source text. Scripts validate their
|
|
557
|
+
contents; the serialized object is limited to 100,000 characters.
|
|
558
|
+
|
|
559
|
+
`manage_revit_scripts` stores reusable definitions under
|
|
560
|
+
`%APPDATA%\pi-revit\scripts`. Its actions are `save`, `list`, `read`, `run`, and
|
|
561
|
+
`history`. Saving requires a name, description, code, and `input_types`; it never
|
|
562
|
+
executes the script. Versions are immutable 64-character SHA-256 hashes of the
|
|
563
|
+
saved definition. Read a version to inspect its source, then explicitly run that
|
|
564
|
+
exact name/hash with current `expected_document_id` and inputs. Runs verify
|
|
565
|
+
saved content integrity and require a bridge with operation receipts.
|
|
566
|
+
|
|
567
|
+
Up to 40 named `input_types` can be declared as string, number, integer, boolean,
|
|
568
|
+
object, or array. Every declared input is required and extra inputs are rejected.
|
|
569
|
+
Validation covers top-level kinds only: scripts still validate nested objects,
|
|
570
|
+
array contents, ranges, units, and model-specific rules. The Pi skill includes
|
|
571
|
+
a short save/read/run example using a numeric input.
|
|
572
|
+
|
|
573
|
+
Library runs use unrestricted `execute_csharp`, with the same model, UI, file,
|
|
574
|
+
and external effects, synchronous execution, transaction, and timeout behavior.
|
|
575
|
+
There is no preview mode, scheduled execution, or automatic model saving. A saved
|
|
576
|
+
script is not a saved Revit model.
|
|
577
|
+
|
|
578
|
+
List/history pages default to 20 entries (maximum 100), with optional exact-name
|
|
579
|
+
filtering. Local history stores version, document identity, input hash,
|
|
580
|
+
timestamps, and receipt IDs, rather than raw inputs or results. History states
|
|
581
|
+
record dispatch/response progress, not a model transaction outcome. After a
|
|
582
|
+
timeout or interruption, inspect `get_revit_operation`; an identical retry uses
|
|
583
|
+
the original `_operation_id`, script version, inputs, and document identity.
|
|
584
|
+
|
|
585
|
+
### Check an operation after a timeout
|
|
586
|
+
|
|
587
|
+
With a bridge that supports operation tracking, Pi automatically assigns an
|
|
588
|
+
operation ID to each bridge tool call and includes it in responses or request
|
|
589
|
+
errors. Call the native `get_revit_operation` tool with that `operation_id` to
|
|
590
|
+
check progress or recover the original result. This extension tool contacts the
|
|
591
|
+
operation's original local bridge directly, even when another instance is selected,
|
|
592
|
+
so it works while Revit's model thread is busy or no
|
|
593
|
+
document is open; the bridge must still be running.
|
|
594
|
+
|
|
595
|
+
| Receipt state | Meaning |
|
|
596
|
+
|---|---|
|
|
597
|
+
| `queued` | Waiting to begin; no tool execution has started. |
|
|
598
|
+
| `running` | Execution started; a client timeout or cancellation does not stop it. |
|
|
599
|
+
| `succeeded` | The tool returned successfully; inspect its payload for the actual model outcome. |
|
|
600
|
+
| `failed` | The call returned an error; this alone does not confirm rollback or absence of effects. |
|
|
601
|
+
| `expired_before_start` | Its queue deadline passed before execution; no tool action was performed. |
|
|
602
|
+
| `result_unavailable` | The tool finished, but a response could not be retained correctly; effects may already exist. |
|
|
603
|
+
| `unknown` | This bridge session has no receipt; the outcome is unknown. |
|
|
604
|
+
|
|
605
|
+
A successful receipt is not proof of a committed edit. For example, a completed
|
|
606
|
+
parameter preview can have receipt state `succeeded` while its payload reports
|
|
607
|
+
`preview: true`, `committed: false`, and proposed changes that were rolled back.
|
|
608
|
+
Inspect `committed`, validation flags, failures, and warnings in the retained
|
|
609
|
+
tool result.
|
|
610
|
+
|
|
611
|
+
To retry the same request, pass its exact ID as `_operation_id` on the original
|
|
612
|
+
tool call and preserve all original arguments. Within the same bridge session,
|
|
613
|
+
this waits for the existing operation or returns its cached response; it never
|
|
614
|
+
executes that ID a second time. Reusing the ID with a different tool or arguments
|
|
615
|
+
is rejected. Omitting `_operation_id` creates a new operation, so establish the
|
|
616
|
+
previous outcome before retrying an edit that way.
|
|
617
|
+
|
|
618
|
+
The bridge retains at most 128 completed full results, with a combined 32 MiB
|
|
619
|
+
limit. Older or oversized results can be evicted, but their receipt records
|
|
620
|
+
remain reserved for the session and report `result_available: false`. Replaying
|
|
621
|
+
an evicted result returns an error without repeating the action. At 10,000
|
|
622
|
+
receipt records, new tracked calls are rejected; existing receipts remain
|
|
623
|
+
queryable. A bridge restart clears all receipts and changes its identity. Old
|
|
624
|
+
IDs cannot be replayed in the new session. An unavailable original bridge or an
|
|
625
|
+
`unknown` receipt does not prove that an earlier edit never ran. Changing the
|
|
626
|
+
selected instance does not redirect old receipts or retries. Inspect the original
|
|
627
|
+
model before deciding on a new operation.
|
|
227
628
|
|
|
228
629
|
### Read complete results
|
|
229
630
|
|
|
@@ -260,23 +661,26 @@ allows a type-only result.
|
|
|
260
661
|
|
|
261
662
|
## Limitations — read before using on real projects
|
|
262
663
|
|
|
263
|
-
- **
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
664
|
+
- **Writes change the open model directly.** There is no confirmation prompt.
|
|
665
|
+
Typed editing tools provide preview and transaction outcomes; `execute_csharp`
|
|
666
|
+
remains unrestricted and attempts rollback after script failure. Parameter
|
|
667
|
+
and type-change batches default to partial success, with optional atomic rollback.
|
|
668
|
+
Transforms and deletions apply the whole selection in one step. Read the
|
|
267
669
|
actual transaction outcome and failed lists. Script result-projection failure
|
|
268
670
|
can leave a successful edit committed with a `returnValueError`; filesystem and
|
|
269
671
|
UI effects are separate from model rollback.
|
|
270
672
|
- The add-in multi-targets .NET 8 (Revit 2025/2026) and .NET 10 (Revit 2027); `deploy.ps1`
|
|
271
673
|
auto-detects the Revit versions you have installed and builds only the matching framework(s),
|
|
272
|
-
so you only need the SDK for the Revit you run. The 0.
|
|
273
|
-
on Revit 2025.
|
|
674
|
+
so you only need the SDK for the Revit you run. The 0.4.0 tools were tested in bounded live
|
|
675
|
+
workflows on Revit 2025. Revit 2026/2027 and large-model
|
|
274
676
|
performance were not tested for this release. Export API/file checks do not
|
|
275
677
|
establish full DWG drawing or IFC schema/geometry validation.
|
|
276
|
-
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
678
|
+
- Pi targets one bridge session at a time. Use `manage_revit_instances` to select
|
|
679
|
+
among reachable instances. Closing or restarting the selected bridge requires
|
|
680
|
+
explicit selection of an available identity; model calls never fall back to another.
|
|
681
|
+
- A tool call that outlives its timeout is abandoned client-side but may still complete inside
|
|
682
|
+
Revit. Check its receipt with `get_revit_operation`; when retrying the identical request,
|
|
683
|
+
reuse `_operation_id`. If its outcome remains unknown, inspect the model before a new write.
|
|
280
684
|
- Long-running scripts cannot be interrupted mid-execution (Revit's API is single-threaded);
|
|
281
685
|
the `execute_csharp` budget is 120s.
|
|
282
686
|
|