@snaptrude/plugin-core 0.9.6 → 0.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/api-manifest.full.json +8443 -0
  3. package/api-manifest.json +167 -10
  4. package/dist/api/core/io/import/index.d.ts +3 -1
  5. package/dist/api/core/io/import/index.d.ts.map +1 -1
  6. package/dist/api/design/create/bulk-items.d.ts +185 -0
  7. package/dist/api/design/create/bulk-items.d.ts.map +1 -0
  8. package/dist/api/design/create/index.d.ts +310 -22
  9. package/dist/api/design/create/index.d.ts.map +1 -1
  10. package/dist/api/design/create/opening-fields.d.ts +37 -0
  11. package/dist/api/design/create/opening-fields.d.ts.map +1 -0
  12. package/dist/api/design/delete/index.d.ts +4 -0
  13. package/dist/api/design/delete/index.d.ts.map +1 -1
  14. package/dist/api/design/dimensions.d.ts +427 -0
  15. package/dist/api/design/dimensions.d.ts.map +1 -0
  16. package/dist/api/design/doors/index.d.ts +20 -13
  17. package/dist/api/design/doors/index.d.ts.map +1 -1
  18. package/dist/api/design/index.d.ts +5 -0
  19. package/dist/api/design/index.d.ts.map +1 -1
  20. package/dist/api/presentation/annotate.d.ts +2 -2
  21. package/dist/api/presentation/shapes.d.ts +2 -2
  22. package/dist/handles.d.ts +19 -0
  23. package/dist/handles.d.ts.map +1 -1
  24. package/dist/index.cjs +2011 -1869
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.js +1988 -1869
  27. package/dist/index.js.map +1 -1
  28. package/package.json +1 -1
  29. package/src/api/core/io/import/index.ts +11 -3
  30. package/src/api/design/create/bulk-items.ts +186 -0
  31. package/src/api/design/create/index.ts +335 -38
  32. package/src/api/design/create/opening-fields.ts +37 -0
  33. package/src/api/design/delete/index.ts +4 -0
  34. package/src/api/design/dimensions.ts +453 -0
  35. package/src/api/design/doors/index.ts +20 -13
  36. package/src/api/design/index.ts +5 -0
  37. package/src/handles.ts +24 -0
@@ -18,12 +18,21 @@ import {
18
18
  PluginBuildableEnvelopeVerticalCap,
19
19
  PluginBuildableEnvelopeCreateResult,
20
20
  } from "../../entity/buildableEnvelope"
21
+ import { PluginOpeningBaseOptions } from "./opening-fields"
22
+ import type {
23
+ PluginCreateDoorItem,
24
+ PluginCreateFloorItem,
25
+ PluginCreateFurnitureItem,
26
+ PluginCreateWallRunItem,
27
+ PluginCreateWindowItem,
28
+ } from "./bulk-items"
21
29
 
22
30
  /**
23
31
  * `design.create.*` — author new scene-committed BIM entities.
24
32
  *
25
33
  * Every creator takes geometry handles + scalars and returns a
26
- * {@linkcode ComponentHandle} (or `ComponentHandle[]` for plural creators) — the
34
+ * {@linkcode ComponentHandle} (or `ComponentHandle[]` for plural creators;
35
+ * `wallRuns` returns one `ComponentHandle[]` per run) — the
27
36
  * `Component.id` of the created entity, resolvable across the rest of the
28
37
  * `design.*` surface. Creation is an undoable host call; it **throws** on failure
29
38
  * (no `Result` wrapper — consistent with `core.geom.create.*`).
@@ -234,6 +243,10 @@ export abstract class PluginDesignCreateApi {
234
243
  * const contour = await snaptrude.core.geom.create.contourFromProfile(rect)
235
244
  * const floor = await snaptrude.design.create.floor(contour, 0.1)
236
245
  * ```
246
+ *
247
+ * @performance For MORE THAN ONE floor, call `design.create.floors(items[])` — one
248
+ * host round-trip and ONE undo entry for the whole batch. Looping this single-floor
249
+ * creator is N round-trips and N undo entries.
237
250
  */
238
251
  public abstract floor(
239
252
  contour: ContourHandle,
@@ -241,6 +254,46 @@ export abstract class PluginDesignCreateApi {
241
254
  position?: Vec3Handle,
242
255
  ): PluginApiReturn<ComponentHandle>
243
256
 
257
+ /**
258
+ * Create **many floors** in one undoable operation (bulk plural of
259
+ * {@linkcode floor}). Each item extrudes its own footprint contour (outer
260
+ * profile + holes) upward by its own `thickness`, at its own optional
261
+ * position offset. Validate-all-or-throw; one command.
262
+ *
263
+ * @param items - One {@linkcode PluginCreateFloorItem} per floor to create
264
+ * (≥1, ≤1000)
265
+ * @returns the created floors as {@linkcode ComponentHandle}`[]`, in input order
266
+ * @throws `VALIDATION` if the items fail the schema (empty array, more than
267
+ * 1000 items, a non-positive thickness) or a contour is degenerate;
268
+ * `HANDLE_INVALID` if a `contour` or `position` handle is unknown or
269
+ * released; `OPERATION_FAILED` if extrusion fails (nothing is created —
270
+ * `details.itemIndex` is the failing item); `METHOD_NOT_PERMITTED` if the
271
+ * plugin may not write.
272
+ *
273
+ * @examplePrompt Create floors for all these room outlines at once
274
+ * @examplePrompt Add a floor to every space in one operation
275
+ * @examplePrompt Bulk create the floor plates for this building
276
+ * @examplePrompt Lay 100mm floors across these five footprints in one undo step
277
+ * @examplePrompt Create the ground and first floor slabs together
278
+ *
279
+ * @performance Bulk creator — the whole batch is ONE host round-trip and ONE undo
280
+ * entry. Always prefer this over calling `design.create.floor` in a loop: build the
281
+ * full `items[]` array first (all contours and offsets up front), then make one call.
282
+ *
283
+ * # Example
284
+ * ```ts
285
+ * const rect = await snaptrude.core.geom.create.profileRect(5, 4)
286
+ * const contour = await snaptrude.core.geom.create.contourFromProfile(rect)
287
+ * const [ground, upper] = await snaptrude.design.create.floors([
288
+ * { contour, thickness: 0.1 },
289
+ * { contour, thickness: 0.1, position: await snaptrude.core.math.vec3.new(0, 3, 0) },
290
+ * ])
291
+ * ```
292
+ */
293
+ public abstract floors(
294
+ items: PluginCreateFloorItem[],
295
+ ): PluginApiReturn<ComponentHandle[]>
296
+
244
297
  /**
245
298
  * Create a **roof** by extruding a footprint contour by `thickness`. Created
246
299
  * flat (extruded downward); pitch/slope is a separate post-creation edit.
@@ -422,6 +475,10 @@ export abstract class PluginDesignCreateApi {
422
475
  * centerlines, 3, undefined, brick.label,
423
476
  * )
424
477
  * ```
478
+ *
479
+ * @performance For MORE THAN ONE run, call `design.create.wallRuns(items[])` — one
480
+ * host round-trip and ONE undo entry for every run in the batch. Looping this
481
+ * single-run creator is N round-trips and N undo entries.
425
482
  */
426
483
  public abstract walls(
427
484
  profile: ProfileHandle,
@@ -431,6 +488,60 @@ export abstract class PluginDesignCreateApi {
431
488
  storey?: number,
432
489
  ): PluginApiReturn<ComponentHandle[]>
433
490
 
491
+ /**
492
+ * Create **many wall runs** in one undoable operation (bulk plural of
493
+ * {@linkcode walls}). Each item is one full run — a wall per curve in that
494
+ * item's profile chain, mitred at shared endpoints. Junctions resolve within a
495
+ * run, not between runs. Each item carries its own
496
+ * dimensions, `wallType` and `storey`, so a single call can build a whole
497
+ * floor plate or several storeys at once. Validate-all-or-throw; one command.
498
+ *
499
+ * @param items - One {@linkcode PluginCreateWallRunItem} per run to create
500
+ * (≥1, ≤1000)
501
+ * @returns one {@linkcode ComponentHandle}`[]` per item, in input order —
502
+ * each inner array holding that run's walls in profile-curve order
503
+ * @throws `VALIDATION` if the items fail the schema (empty array, more than
504
+ * 1000 items, a non-positive height or thickness, a zero-length curve);
505
+ * `HANDLE_INVALID` if a `profile` handle is unknown or released;
506
+ * `PRECONDITION_FAILED` if a profile has no curves, `wallType` names no
507
+ * wall type in the project, or `storey` does not exist;
508
+ * `OPERATION_FAILED` if wall creation fails (nothing is created —
509
+ * `details.itemIndex` is the failing item); `METHOD_NOT_PERMITTED` if the
510
+ * plugin may not write.
511
+ *
512
+ * @examplePrompt Draw all the walls of this floor plan at once
513
+ * @examplePrompt Build every room's perimeter in one operation
514
+ * @examplePrompt Bulk create wall runs from these centerlines
515
+ * @examplePrompt Create the walls for both storeys in a single undo step
516
+ * @examplePrompt Turn these polylines into 200mm brick walls together
517
+ *
518
+ * @performance Bulk creator — the whole batch is ONE host round-trip and ONE undo
519
+ * entry. Always prefer this over calling `design.create.walls` in a loop: build the
520
+ * full `items[]` array first (all profiles up front), then make one call.
521
+ *
522
+ * # Example
523
+ * ```ts
524
+ * const v = snaptrude.core.math.vec3
525
+ * const ground = await snaptrude.core.geom.create.profileFromLinePoints([
526
+ * await v.new(0, 0, 0),
527
+ * await v.new(8, 0, 0),
528
+ * await v.new(8, 0, 6),
529
+ * ])
530
+ * const upper = await snaptrude.core.geom.create.profileFromLinePoints([
531
+ * await v.new(0, 0, 0),
532
+ * await v.new(8, 0, 0),
533
+ * ])
534
+ * const [groundWalls, upperWalls] = await snaptrude.design.create.wallRuns([
535
+ * { profile: ground, height: 3, thickness: 0.2 },
536
+ * { profile: upper, height: 3, storey: 2 },
537
+ * ])
538
+ * console.log(groundWalls.length, "walls on the ground floor")
539
+ * ```
540
+ */
541
+ public abstract wallRuns(
542
+ items: PluginCreateWallRunItem[],
543
+ ): PluginApiReturn<ComponentHandle[][]>
544
+
434
545
  /**
435
546
  * Create a **staircase** from a parametric preset, placed at a point.
436
547
  *
@@ -535,15 +646,19 @@ export abstract class PluginDesignCreateApi {
535
646
  * `position.y` (the same surface-flush contract as interactive drag-drop) —
536
647
  * pass the floor/storey elevation to stand furniture on it; never add half
537
648
  * the item's height yourself.
538
- * @param options - Optional placement options: `label` — instance name
539
- * (default auto `${name}Ins${n}`); `createNewSourceMesh` — emit a
540
- * source-mesh creation command (default `true`)
649
+ * @param options - Optional placement options: `label` — instance name and
650
+ * readable label (`design.query.getLabel`; default auto `${name}Ins${n}`);
651
+ * `createNewSourceMesh` legacy flag, kept for compatibility. The host owns
652
+ * source-mesh persistence: a catalog source is recorded exactly once, by the
653
+ * first placement that brings it in, and this flag cannot skip that record.
541
654
  * @param angleInDegrees - Optional signed rotation about the vertical axis, in
542
655
  * degrees (same convention as {@linkcode PluginDesignTransformApi.rotate}).
543
656
  * Applied at creation time so it is part of the placement's single undo entry.
544
657
  * Default: the item's own (unrotated) orientation.
545
658
  * @returns the {@linkcode ComponentHandle} of the placed furniture instance
546
- * @throws if the catalog id is unknown, the source mesh fails to load, or placement fails
659
+ * @throws if the catalog id is unknown, the source mesh fails to load, or placement fails;
660
+ * `PRECONDITION_FAILED` (`details.engineCode: "TOOL_ACTIVE"`) while the interactive
661
+ * furniture tool is active — finish or cancel it first
547
662
  *
548
663
  * @examplePrompt Place a chair from the library at this spot
549
664
  * @examplePrompt Add a sofa from the furniture catalog to the living room
@@ -567,6 +682,10 @@ export abstract class PluginDesignCreateApi {
567
682
  * 90,
568
683
  * )
569
684
  * ```
685
+ *
686
+ * @performance For MORE THAN ONE item, call `design.create.furnitureItems(items[])` —
687
+ * one host round-trip and ONE undo entry, and a catalog source shared by several
688
+ * items is fetched once. Looping this single-item creator is N round-trips.
570
689
  */
571
690
  public abstract furniture(
572
691
  catalogId: string,
@@ -575,6 +694,52 @@ export abstract class PluginDesignCreateApi {
575
694
  angleInDegrees?: number,
576
695
  ): PluginApiReturn<ComponentHandle>
577
696
 
697
+ /**
698
+ * Place **many furniture items** in one undoable operation (bulk plural of
699
+ * {@linkcode furniture}). Each item names a catalog id and an absolute world
700
+ * position (`position.y` is the REST elevation — the same grounding contract
701
+ * as the singular creator), with optional label and rotation. A catalog
702
+ * source shared by several items is fetched and recorded once for the whole
703
+ * batch, so the host — not the caller — owns source persistence (there is no
704
+ * per-item `createNewSourceMesh`). Validate-all-or-throw; one command.
705
+ *
706
+ * @param items - One {@linkcode PluginCreateFurnitureItem} per instance to
707
+ * place (≥1, ≤1000)
708
+ * @returns the placed instances as {@linkcode ComponentHandle}`[]`, in input order
709
+ * @throws `VALIDATION` if the items fail the schema (empty array, more than
710
+ * 1000 items); `HANDLE_INVALID` if a `position` handle is unknown or
711
+ * released; `PRECONDITION_FAILED` if a catalog id is unknown, a furniture
712
+ * tool is active, or a parametric group is active (exit it first, or place
713
+ * items one at a time with `furniture`); `OPERATION_FAILED` if a source
714
+ * mesh fails to load or placement fails (nothing is created —
715
+ * `details.itemIndex` is the failing item); `METHOD_NOT_PERMITTED` if the plugin may not write.
716
+ *
717
+ * @examplePrompt Place all the desks for this office at once
718
+ * @examplePrompt Furnish every bedroom in one operation
719
+ * @examplePrompt Bulk place these chairs around the table
720
+ * @examplePrompt Add the whole furniture layout in a single undo step
721
+ * @examplePrompt Drop twenty copies of this chair at these positions
722
+ *
723
+ * @performance Bulk creator — the whole batch is ONE host round-trip and ONE undo
724
+ * entry, and each distinct catalog source loads once. Always prefer this over
725
+ * calling `design.create.furniture` in a loop: build the full `items[]` array
726
+ * first (all positions and angles up front), then make one call.
727
+ *
728
+ * # Example
729
+ * ```ts
730
+ * const v = snaptrude.core.math.vec3
731
+ * const [chair] = await snaptrude.design.furniture.listCatalog()
732
+ * const placed = await snaptrude.design.create.furnitureItems([
733
+ * { catalogId: chair.id, position: await v.new(3, 0, 5), label: "Chair-01" },
734
+ * { catalogId: chair.id, position: await v.new(4, 0, 5), angleInDegrees: 90 },
735
+ * { catalogId: chair.id, position: await v.new(5, 0, 5), angleInDegrees: 180 },
736
+ * ])
737
+ * ```
738
+ */
739
+ public abstract furnitureItems(
740
+ items: PluginCreateFurnitureItem[],
741
+ ): PluginApiReturn<ComponentHandle[]>
742
+
578
743
  /**
579
744
  * Place a **door** from the catalog into a host wall.
580
745
  *
@@ -588,12 +753,15 @@ export abstract class PluginDesignCreateApi {
588
753
  * @param catalogId - Library id: team `_id` or general `fullName`
589
754
  * @param hostWall - The wall to host the door
590
755
  * @param position - World point projected onto the wall to locate the opening
591
- * @param options - Optional placement options: `label` — instance name
592
- * @param facing - World point selecting which side of the wall the door faces
593
- * (the room it opens into) the same convention as approaching the wall
594
- * from that side with the cursor in the interactive tool. Any point clearly
595
- * on that side works (e.g. the room's center). Default: the engine picks a
596
- * side (nondeterministic when `position` sits on the wall centerline).
756
+ * @param options - Optional placement options: `label` — instance name;
757
+ * `hinge` world point near the jamb the door is hinged on (the door is
758
+ * reflected along the wall so its hinged jamb is the one nearer this
759
+ * point; default the catalog item's authored hinge side)
760
+ * @param facing - World point on the side of the wall the door swings open
761
+ * to (the room it opens into — where the plan symbol draws the swing arc).
762
+ * Any point clearly on that side works (e.g. the room's center). Default:
763
+ * the engine picks a side (nondeterministic when `position` sits on the
764
+ * wall centerline).
597
765
  * @returns the {@linkcode ComponentHandle} of the placed door
598
766
  * @throws if the catalog id is unknown, the host is not a wall, the source
599
767
  * mesh fails to load, or the projected point falls **outside** the host wall
@@ -604,6 +772,7 @@ export abstract class PluginDesignCreateApi {
604
772
  * @examplePrompt Insert the entrance door into this wall
605
773
  * @examplePrompt Add a door to the wall and call it Entry-01
606
774
  * @examplePrompt Add a door that opens into the living room
775
+ * @examplePrompt Put a door here hinged on the north jamb
607
776
  *
608
777
  * # Example
609
778
  * ```ts
@@ -623,16 +792,83 @@ export abstract class PluginDesignCreateApi {
623
792
  * undefined,
624
793
  * await snaptrude.core.math.vec3.new(3, 0, 9),
625
794
  * )
795
+ * // …and hinged on the jamb nearest a point (here the +x end of the opening):
796
+ * const hingedRight = await snaptrude.design.create.door(
797
+ * entry.id,
798
+ * wall,
799
+ * await snaptrude.core.math.vec3.new(3, 0, 5),
800
+ * { hinge: await snaptrude.core.math.vec3.new(3.5, 0, 5) },
801
+ * await snaptrude.core.math.vec3.new(3, 0, 9),
802
+ * )
626
803
  * ```
804
+ *
805
+ * @performance For MORE THAN ONE door, call `design.create.doors(items[])` — one host
806
+ * round-trip and ONE undo entry, with each host wall re-cut once per opening inside
807
+ * that single call. Looping this single-door creator is N round-trips.
627
808
  */
628
809
  public abstract door(
629
810
  catalogId: string,
630
811
  hostWall: ComponentHandle,
631
812
  position: Vec3Handle,
632
- options?: { label?: string },
813
+ options?: { label?: string; hinge?: Vec3Handle },
633
814
  facing?: Vec3Handle,
634
815
  ): PluginApiReturn<ComponentHandle>
635
816
 
817
+ /**
818
+ * Place **many doors** into host walls in one undoable operation (bulk plural
819
+ * of {@linkcode door}). Each item carries its own catalog id, host wall,
820
+ * world position, and optional `facing`, `label`, `width` and `height` — the
821
+ * same fields as a `"door"` {@linkcode PluginDesignCreateOpeningOptions}.
822
+ * Validate-all-or-throw; one command.
823
+ *
824
+ * As with the singular creator, placing an opening **re-cuts its host wall**:
825
+ * the wall you passed as `hostWall` stops resolving once the call returns.
826
+ * Several items MAY name the same original wall handle in one call — the host
827
+ * chains the re-cuts internally — but after the call recover the surviving
828
+ * wall with `design.query.getHost(opening)`, never by reusing the handle you
829
+ * passed in.
830
+ *
831
+ * @param items - One {@linkcode PluginCreateDoorItem} per door to place
832
+ * (≥1, ≤1000)
833
+ * @returns the placed doors as {@linkcode ComponentHandle}`[]`, in input order
834
+ * @throws `VALIDATION` if the items fail the schema (empty array, more than
835
+ * 1000 items, unknown fields, a non-positive `width`/`height`);
836
+ * `HANDLE_INVALID` if a `position`, `facing` or `hinge` handle is unknown
837
+ * or released; `PRECONDITION_FAILED` if a catalog id is unknown, a `hostWall`
838
+ * is not a wall / is locked / is not in the active proposal, the projected
839
+ * point falls outside its host wall, or a door tool is active;
840
+ * `OPERATION_FAILED` if a source mesh fails to load or placement fails
841
+ * (nothing is created — `details.itemIndex` is the failing item);
842
+ * `METHOD_NOT_PERMITTED` if the plugin may not write.
843
+ *
844
+ * @examplePrompt Add doors to all of these walls at once
845
+ * @examplePrompt Place a door in every room in one operation
846
+ * @examplePrompt Bulk add the entrance doors from this schedule
847
+ * @examplePrompt Put three doors on this wall in a single undo step
848
+ * @examplePrompt Add all the doors for this floor plan together
849
+ *
850
+ * @performance Bulk creator — the whole batch is ONE host round-trip and ONE undo
851
+ * entry, and each distinct catalog source loads once. Always prefer this over
852
+ * calling `design.create.door` in a loop: build the full `items[]` array first
853
+ * (all host walls and points up front), then make one call.
854
+ *
855
+ * # Example
856
+ * ```ts
857
+ * const v = snaptrude.core.math.vec3
858
+ * const [wall] = await snaptrude.design.query.listWalls({ isSelected: true })
859
+ * const [entry] = await snaptrude.design.doors.listCatalog()
860
+ * const [front, side] = await snaptrude.design.create.doors([
861
+ * { catalogId: entry.id, hostWall: wall, position: await v.new(2, 0, 5), label: "D-01" },
862
+ * { catalogId: entry.id, hostWall: wall, position: await v.new(6, 0, 5), width: 1.2 },
863
+ * ])
864
+ * // `wall` was re-cut twice and no longer resolves — ask the opening for its host:
865
+ * const currentWall = await snaptrude.design.query.getHost(front)
866
+ * ```
867
+ */
868
+ public abstract doors(
869
+ items: PluginCreateDoorItem[],
870
+ ): PluginApiReturn<ComponentHandle[]>
871
+
636
872
  /**
637
873
  * Place a **window** from the catalog into a host wall.
638
874
  *
@@ -646,11 +882,14 @@ export abstract class PluginDesignCreateApi {
646
882
  * @param catalogId - Library id: team `_id` or general `fullName`
647
883
  * @param hostWall - The wall to host the window
648
884
  * @param position - World point projected onto the wall to locate the opening
649
- * @param options - Optional placement options: `label` — instance name
650
- * @param facing - World point selecting which side of the wall the window
651
- * faces (matters for asymmetric windows, e.g. casement swing) same
652
- * convention as {@linkcode PluginDesignCreateApi.door}. Default: the engine
653
- * picks a side (nondeterministic when `position` sits on the centerline).
885
+ * @param options - Optional placement options: `label` — instance name;
886
+ * `hinge` world point near the jamb the window is hinged on (same rule
887
+ * as {@linkcode PluginDesignCreateApi.door}; default the catalog item's
888
+ * authored side)
889
+ * @param facing - World point on the side of the wall the window opens to
890
+ * (matters for asymmetric windows, e.g. casement swing) — same convention
891
+ * as {@linkcode PluginDesignCreateApi.door}. Default: the engine picks a
892
+ * side (nondeterministic when `position` sits on the centerline).
654
893
  * @returns the {@linkcode ComponentHandle} of the placed window
655
894
  * @throws if the catalog id is unknown, the host is not a wall, the source
656
895
  * mesh fails to load, or the projected point falls **outside** the host wall
@@ -673,15 +912,75 @@ export abstract class PluginDesignCreateApi {
673
912
  * { label: "Win-01" },
674
913
  * )
675
914
  * ```
915
+ *
916
+ * @performance For MORE THAN ONE window, call `design.create.windows(items[])` — one
917
+ * host round-trip and ONE undo entry, with each host wall re-cut once per opening
918
+ * inside that single call. Looping this single-window creator is N round-trips.
676
919
  */
677
920
  public abstract window(
678
921
  catalogId: string,
679
922
  hostWall: ComponentHandle,
680
923
  position: Vec3Handle,
681
- options?: { label?: string },
924
+ options?: { label?: string; hinge?: Vec3Handle },
682
925
  facing?: Vec3Handle,
683
926
  ): PluginApiReturn<ComponentHandle>
684
927
 
928
+ /**
929
+ * Place **many windows** into host walls in one undoable operation (bulk
930
+ * plural of {@linkcode window}). Each item carries its own catalog id, host
931
+ * wall, world position, and optional `facing`, `label`, `width`, `height` and
932
+ * `sillHeight` — the same fields as a `"window"`
933
+ * {@linkcode PluginDesignCreateOpeningOptions}. `sillHeight` is measured from
934
+ * the host wall base to the BOTTOM of the window. Validate-all-or-throw; one
935
+ * command.
936
+ *
937
+ * As with the singular creator, placing an opening **re-cuts its host wall**:
938
+ * the wall you passed as `hostWall` stops resolving once the call returns.
939
+ * Several items MAY name the same original wall handle in one call — the host
940
+ * chains the re-cuts internally — but after the call recover the surviving
941
+ * wall with `design.query.getHost(opening)`, never by reusing the handle you
942
+ * passed in.
943
+ *
944
+ * @param items - One {@linkcode PluginCreateWindowItem} per window to place
945
+ * (≥1, ≤1000)
946
+ * @returns the placed windows as {@linkcode ComponentHandle}`[]`, in input order
947
+ * @throws `VALIDATION` if the items fail the schema (empty array, more than
948
+ * 1000 items, unknown fields, a non-positive `width`/`height`, a negative
949
+ * `sillHeight`); `HANDLE_INVALID` if a `position`, `facing` or `hinge`
950
+ * handle is unknown or released; `PRECONDITION_FAILED` if a catalog id is unknown, a
951
+ * `hostWall` is not a wall / is locked / is not in the active proposal, the
952
+ * projected point falls outside its host wall, or a window tool is active;
953
+ * `OPERATION_FAILED` if a source mesh fails to load or placement fails
954
+ * (nothing is created — `details.itemIndex` is the failing item);
955
+ * `METHOD_NOT_PERMITTED` if the plugin may not write.
956
+ *
957
+ * @examplePrompt Add windows along this whole facade at once
958
+ * @examplePrompt Place a window in every bedroom in one operation
959
+ * @examplePrompt Bulk add the windows from this schedule
960
+ * @examplePrompt Put four windows on this wall in a single undo step
961
+ * @examplePrompt Add all the windows with a 0.9m sill height together
962
+ *
963
+ * @performance Bulk creator — the whole batch is ONE host round-trip and ONE undo
964
+ * entry, and each distinct catalog source loads once. Always prefer this over
965
+ * calling `design.create.window` in a loop: build the full `items[]` array first
966
+ * (all host walls and points up front), then make one call.
967
+ *
968
+ * # Example
969
+ * ```ts
970
+ * const v = snaptrude.core.math.vec3
971
+ * const [wall] = await snaptrude.design.query.listWalls({ isSelected: true })
972
+ * const [casement] = await snaptrude.design.windows.listCatalog()
973
+ * const placed = await snaptrude.design.create.windows([
974
+ * { catalogId: casement.id, hostWall: wall, position: await v.new(2, 0, 5), sillHeight: 0.9 },
975
+ * { catalogId: casement.id, hostWall: wall, position: await v.new(5, 0, 5), sillHeight: 0.9 },
976
+ * ])
977
+ * const currentWall = await snaptrude.design.query.getHost(placed[0])
978
+ * ```
979
+ */
980
+ public abstract windows(
981
+ items: PluginCreateWindowItem[],
982
+ ): PluginApiReturn<ComponentHandle[]>
983
+
685
984
  /**
686
985
  * Place a catalog **door or window** into a host wall with optional size overrides.
687
986
  *
@@ -691,7 +990,7 @@ export abstract class PluginDesignCreateApi {
691
990
  * its center. Placement is asynchronous and committed as one undoable creation.
692
991
  *
693
992
  * @param options - Opening kind, catalog and host references, placement, and
694
- * optional facing, label, and dimensions
993
+ * optional facing (swing side), hinge (hinged jamb), label, and dimensions
695
994
  * @returns the {@linkcode ComponentHandle} of the placed door or window
696
995
  * @throws if the options are invalid, the catalog id is unknown, the host is
697
996
  * not a wall, loading fails, or the opening cannot be placed on the host
@@ -699,8 +998,9 @@ export abstract class PluginDesignCreateApi {
699
998
  * @examplePrompt Add a 1m wide door to this wall here
700
999
  * @examplePrompt Place a window with a 0.9m sill height on the selected wall
701
1000
  *
702
- * @performance Single-opening creator — use it for one hosted opening. A plural
703
- * API is intentionally unavailable until host placement can be atomic.
1001
+ * @performance Single-opening creator — use it for one hosted opening. For MORE
1002
+ * THAN ONE, call `design.create.doors(items[])` / `design.create.windows(items[])`:
1003
+ * the same per-item fields, one host round-trip, ONE undo entry.
704
1004
  *
705
1005
  * # Example
706
1006
  * ```ts
@@ -1262,7 +1562,7 @@ export type PluginDesignCreateStaircaseArgs = z.infer<
1262
1562
  * | `catalogId` | `string` | Library id: team `_id` or general `fullName` |
1263
1563
  * | `position` | {@linkcode Vec3Handle} | Absolute world placement point |
1264
1564
  * | `label` | `string`? | Instance name (default auto `${name}Ins${n}`) |
1265
- * | `createNewSourceMesh` | `boolean`? | Emit a source-mesh creation command (default `true`) |
1565
+ * | `createNewSourceMesh` | `boolean`? | Legacy, kept for compatibility; the host records a catalog source exactly once and this flag cannot skip it |
1266
1566
  * | `angleInDegrees` | `number`? | Rotation about the vertical axis, in degrees (default unrotated) |
1267
1567
  */
1268
1568
  export const PluginDesignCreateFurnitureArgs = z.object({
@@ -1291,7 +1591,8 @@ export type PluginDesignCreateFurnitureArgs = z.infer<
1291
1591
  * | `hostWall` | {@linkcode ComponentHandle} | The wall to host the door |
1292
1592
  * | `position` | {@linkcode Vec3Handle} | World point projected onto the wall |
1293
1593
  * | `label` | `string`? | Instance name (optional) |
1294
- * | `facing` | {@linkcode Vec3Handle}? | World point on the side of the wall the door faces (default engine-chosen) |
1594
+ * | `facing` | {@linkcode Vec3Handle}? | World point on the side of the wall the door swings open to (default engine-chosen) |
1595
+ * | `hinge` | {@linkcode Vec3Handle}? | World point near the jamb the door is hinged on (default the catalog item's authored side) |
1295
1596
  */
1296
1597
  export const PluginDesignCreateDoorArgs = z.object({
1297
1598
  catalogId: z.string().min(1),
@@ -1299,12 +1600,13 @@ export const PluginDesignCreateDoorArgs = z.object({
1299
1600
  position: Vec3Handle,
1300
1601
  label: z.string().optional(),
1301
1602
  facing: Vec3Handle.optional(),
1603
+ hinge: Vec3Handle.optional(),
1302
1604
  })
1303
1605
  export type PluginDesignCreateDoorArgs = z.infer<
1304
1606
  typeof PluginDesignCreateDoorArgs
1305
1607
  >
1306
- // TRANSPORT: positional signature shipped — facing is the trailing 5th arg:
1307
- // door(catalogId: string, hostWall: ComponentHandle, position: Vec3Handle, options?: { label? }, facing?: Vec3Handle)
1608
+ // TRANSPORT: positional signature shipped — facing is the trailing 5th arg, hinge rides in options:
1609
+ // door(catalogId: string, hostWall: ComponentHandle, position: Vec3Handle, options?: { label?, hinge? }, facing?: Vec3Handle)
1308
1610
 
1309
1611
  // ---------------------------------------------------------------------------
1310
1612
  // window
@@ -1319,7 +1621,8 @@ export type PluginDesignCreateDoorArgs = z.infer<
1319
1621
  * | `hostWall` | {@linkcode ComponentHandle} | The wall to host the window |
1320
1622
  * | `position` | {@linkcode Vec3Handle} | World point projected onto the wall |
1321
1623
  * | `label` | `string`? | Instance name (optional) |
1322
- * | `facing` | {@linkcode Vec3Handle}? | World point on the side of the wall the window faces (default engine-chosen) |
1624
+ * | `facing` | {@linkcode Vec3Handle}? | World point on the side of the wall the window opens to (default engine-chosen) |
1625
+ * | `hinge` | {@linkcode Vec3Handle}? | World point near the jamb the window is hinged on (default the catalog item's authored side) |
1323
1626
  */
1324
1627
  export const PluginDesignCreateWindowArgs = z.object({
1325
1628
  catalogId: z.string().min(1),
@@ -1327,27 +1630,18 @@ export const PluginDesignCreateWindowArgs = z.object({
1327
1630
  position: Vec3Handle,
1328
1631
  label: z.string().optional(),
1329
1632
  facing: Vec3Handle.optional(),
1633
+ hinge: Vec3Handle.optional(),
1330
1634
  })
1331
1635
  export type PluginDesignCreateWindowArgs = z.infer<
1332
1636
  typeof PluginDesignCreateWindowArgs
1333
1637
  >
1334
- // TRANSPORT: positional signature shipped — facing is the trailing 5th arg:
1335
- // window(catalogId: string, hostWall: ComponentHandle, position: Vec3Handle, options?: { label? }, facing?: Vec3Handle)
1638
+ // TRANSPORT: positional signature shipped — facing is the trailing 5th arg, hinge rides in options:
1639
+ // window(catalogId: string, hostWall: ComponentHandle, position: Vec3Handle, options?: { label?, hinge? }, facing?: Vec3Handle)
1336
1640
 
1337
1641
  // ---------------------------------------------------------------------------
1338
1642
  // opening
1339
1643
  // ---------------------------------------------------------------------------
1340
1644
 
1341
- const PluginOpeningBaseOptions = {
1342
- catalogId: z.string().min(1),
1343
- hostWall: ComponentHandle,
1344
- position: Vec3Handle,
1345
- facing: Vec3Handle.optional(),
1346
- label: z.string().optional(),
1347
- width: z.number().finite().positive().optional(),
1348
- height: z.number().finite().positive().optional(),
1349
- }
1350
-
1351
1645
  /**
1352
1646
  * Options for {@linkcode PluginDesignCreateApi.opening}, discriminated by
1353
1647
  * `kind`. Width and height are positive Snaptrude engine-unit values.
@@ -1524,3 +1818,6 @@ export const PluginCreateSpaceItem = z.object({
1524
1818
  storey: z.number().int().optional(),
1525
1819
  })
1526
1820
  export type PluginCreateSpaceItem = z.infer<typeof PluginCreateSpaceItem>
1821
+
1822
+ export * from "./opening-fields"
1823
+ export * from "./bulk-items"
@@ -0,0 +1,37 @@
1
+ import * as z from "zod"
2
+ import { ComponentHandle, Vec3Handle } from "../../../handles"
3
+
4
+ /**
5
+ * The shared field bag every hosted opening (door / window) carries — used by
6
+ * {@linkcode PluginDesignCreateOpeningOptions} and by the bulk item schemas in
7
+ * `bulk-items.ts`, so singular and plural openings validate identically.
8
+ *
9
+ * `facing` and `hinge` are WORLD POINTS, not directions: `facing` sits on the
10
+ * side of the wall the leaf swings open to (where the plan symbol draws the
11
+ * swing arc); `hinge` sits near the jamb the leaf is hinged on — the item is
12
+ * reflected along the wall so its hinged jamb is the one nearer that point.
13
+ * Either may be omitted (engine-chosen side / the catalog item's authored
14
+ * hinge side). Neither has a visible effect on symmetric items such as
15
+ * sliders or fixed windows.
16
+ *
17
+ * | Property | Type | Description |
18
+ * |---|---|---|
19
+ * | `catalogId` | `string` | Library id: team `_id` or general `fullName` |
20
+ * | `hostWall` | {@linkcode ComponentHandle} | The wall to host the opening |
21
+ * | `position` | {@linkcode Vec3Handle} | World point projected onto the wall |
22
+ * | `facing` | {@linkcode Vec3Handle}? | World point on the side of the wall the opening swings open to (default engine-chosen) |
23
+ * | `hinge` | {@linkcode Vec3Handle}? | World point near the jamb the opening is hinged on (default the catalog item's authored side) |
24
+ * | `label` | `string`? | Instance name (optional) |
25
+ * | `width` | `number`? | Width override (Snaptrude units, > 0; default the catalog item's) |
26
+ * | `height` | `number`? | Height override (Snaptrude units, > 0; default the catalog item's) |
27
+ */
28
+ export const PluginOpeningBaseOptions = {
29
+ catalogId: z.string().min(1),
30
+ hostWall: ComponentHandle,
31
+ position: Vec3Handle,
32
+ facing: Vec3Handle.optional(),
33
+ hinge: Vec3Handle.optional(),
34
+ label: z.string().optional(),
35
+ width: z.number().finite().positive().optional(),
36
+ height: z.number().finite().positive().optional(),
37
+ }
@@ -39,6 +39,10 @@ export abstract class PluginDesignDeleteApi {
39
39
  * children are removed and linked-list neighbours are fixed up — not caller-tunable
40
40
  * in v1. Undoable — commits as a **single** undo entry.
41
41
  *
42
+ * Dimension lines anchored to a deleted entity are removed with it, in the same undo
43
+ * entry, exactly as the editor's Delete key does — see `design.dimensions`. They are
44
+ * NOT listed in `affected`, which reports component handles only.
45
+ *
42
46
  * @param components - Entities to delete. Unknown/forged handles reject the whole call (fail-fast).
43
47
  * @returns The entities that were deleted, as {@linkcode ComponentHandle}`[]`
44
48
  * (echoed host-side from the resolved+deleted set — the engine returns no ids).