@snaptrude/plugin-core 0.9.16 → 0.9.18-edgesetbacks-20261021.1

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 (221) hide show
  1. package/AGENTS.md +231 -231
  2. package/CHANGELOG.md +408 -402
  3. package/CLAUDE.md +11 -11
  4. package/api-manifest.json +1510 -701
  5. package/dist/api/analysis/daylight.d.ts +5 -5
  6. package/dist/api/analysis/solar.d.ts +2 -2
  7. package/dist/api/core/camera/index.d.ts +29 -0
  8. package/dist/api/core/camera/index.d.ts.map +1 -1
  9. package/dist/api/core/geom/create/index.d.ts +7 -1
  10. package/dist/api/core/geom/create/index.d.ts.map +1 -1
  11. package/dist/api/core/geom/update/contour.d.ts +8 -2
  12. package/dist/api/core/geom/update/contour.d.ts.map +1 -1
  13. package/dist/api/core/storeys/index.d.ts +5 -2
  14. package/dist/api/core/storeys/index.d.ts.map +1 -1
  15. package/dist/api/core/zoom/index.d.ts +13 -0
  16. package/dist/api/core/zoom/index.d.ts.map +1 -1
  17. package/dist/api/design/bim.d.ts +299 -0
  18. package/dist/api/design/bim.d.ts.map +1 -0
  19. package/dist/api/design/boolean/index.d.ts +2 -0
  20. package/dist/api/design/boolean/index.d.ts.map +1 -1
  21. package/dist/api/design/catalog.d.ts +320 -0
  22. package/dist/api/design/catalog.d.ts.map +1 -0
  23. package/dist/api/design/create/bulk-items.d.ts +65 -25
  24. package/dist/api/design/create/bulk-items.d.ts.map +1 -1
  25. package/dist/api/design/create/index.d.ts +299 -100
  26. package/dist/api/design/create/index.d.ts.map +1 -1
  27. package/dist/api/design/create/opening-fields.d.ts +13 -12
  28. package/dist/api/design/create/opening-fields.d.ts.map +1 -1
  29. package/dist/api/design/delete/index.d.ts +1 -0
  30. package/dist/api/design/delete/index.d.ts.map +1 -1
  31. package/dist/api/design/doors/index.d.ts +18 -24
  32. package/dist/api/design/doors/index.d.ts.map +1 -1
  33. package/dist/api/design/family.d.ts +813 -35
  34. package/dist/api/design/family.d.ts.map +1 -1
  35. package/dist/api/design/index.d.ts +16 -0
  36. package/dist/api/design/index.d.ts.map +1 -1
  37. package/dist/api/design/networks.d.ts +1703 -0
  38. package/dist/api/design/networks.d.ts.map +1 -0
  39. package/dist/api/design/query/grids.d.ts +2 -2
  40. package/dist/api/design/query/index.d.ts +42 -32
  41. package/dist/api/design/query/index.d.ts.map +1 -1
  42. package/dist/api/design/selection/index.d.ts +10 -10
  43. package/dist/api/design/types/index.d.ts +40 -24
  44. package/dist/api/design/types/index.d.ts.map +1 -1
  45. package/dist/api/design/update/index.d.ts +111 -6
  46. package/dist/api/design/update/index.d.ts.map +1 -1
  47. package/dist/api/design/windows/index.d.ts +8 -8
  48. package/dist/api/design/windows/index.d.ts.map +1 -1
  49. package/dist/api/entity/buildableEnvelope.d.ts +84 -2
  50. package/dist/api/entity/buildableEnvelope.d.ts.map +1 -1
  51. package/dist/api/presentation/aiInspiration.d.ts +10 -10
  52. package/dist/api/presentation/annotate.d.ts +38 -22
  53. package/dist/api/presentation/annotate.d.ts.map +1 -1
  54. package/dist/api/presentation/drawingContract.d.ts +32 -0
  55. package/dist/api/presentation/drawingContract.d.ts.map +1 -0
  56. package/dist/api/presentation/drawings.d.ts +3523 -0
  57. package/dist/api/presentation/drawings.d.ts.map +1 -0
  58. package/dist/api/presentation/export.d.ts +23 -5
  59. package/dist/api/presentation/export.d.ts.map +1 -1
  60. package/dist/api/presentation/index.d.ts +41 -12
  61. package/dist/api/presentation/index.d.ts.map +1 -1
  62. package/dist/api/presentation/placedViews.d.ts +106 -6
  63. package/dist/api/presentation/placedViews.d.ts.map +1 -1
  64. package/dist/api/presentation/sections.d.ts +461 -0
  65. package/dist/api/presentation/sections.d.ts.map +1 -0
  66. package/dist/api/presentation/shapes.d.ts +2 -2
  67. package/dist/api/presentation/sheets.d.ts +175 -19
  68. package/dist/api/presentation/sheets.d.ts.map +1 -1
  69. package/dist/api/presentation/viewPresets.d.ts +222 -0
  70. package/dist/api/presentation/viewPresets.d.ts.map +1 -0
  71. package/dist/api/presentation/views.d.ts +141 -8
  72. package/dist/api/presentation/views.d.ts.map +1 -1
  73. package/dist/api/presentation/walkthroughs.d.ts +6 -6
  74. package/dist/errors/codes.d.ts +3 -1
  75. package/dist/errors/codes.d.ts.map +1 -1
  76. package/dist/index.cjs +3883 -2385
  77. package/dist/index.cjs.map +1 -1
  78. package/dist/index.js +3744 -2385
  79. package/dist/index.js.map +1 -1
  80. package/package.json +1 -1
  81. package/scripts/check-dist-fresh.mjs +22 -22
  82. package/scripts/generate-manifest.mjs +243 -238
  83. package/scripts/generate-manifest.test.mjs +303 -303
  84. package/src/api/analysis/daylight.ts +470 -470
  85. package/src/api/analysis/heatmaps.ts +683 -683
  86. package/src/api/analysis/illuminance.ts +155 -155
  87. package/src/api/analysis/index.ts +61 -61
  88. package/src/api/analysis/shadows.ts +183 -183
  89. package/src/api/analysis/solar.ts +237 -237
  90. package/src/api/analysis/sunlightHours.ts +211 -211
  91. package/src/api/analysis/sunpath.ts +83 -83
  92. package/src/api/analysis/weather.ts +179 -179
  93. package/src/api/core/buildings.ts +485 -485
  94. package/src/api/core/camera/index.ts +696 -667
  95. package/src/api/core/comment/index.ts +376 -376
  96. package/src/api/core/geom/create/index.ts +2139 -2133
  97. package/src/api/core/geom/delete/index.ts +84 -84
  98. package/src/api/core/geom/index.ts +35 -35
  99. package/src/api/core/geom/query/arc.ts +169 -169
  100. package/src/api/core/geom/query/brep.ts +621 -621
  101. package/src/api/core/geom/query/circle.ts +404 -404
  102. package/src/api/core/geom/query/contour.ts +540 -540
  103. package/src/api/core/geom/query/curve.ts +1102 -1102
  104. package/src/api/core/geom/query/edge.ts +130 -130
  105. package/src/api/core/geom/query/face.ts +508 -508
  106. package/src/api/core/geom/query/halfedge.ts +210 -210
  107. package/src/api/core/geom/query/index.ts +63 -63
  108. package/src/api/core/geom/query/profile.ts +473 -473
  109. package/src/api/core/geom/query/vertex.ts +205 -205
  110. package/src/api/core/geom/update/contour.ts +323 -317
  111. package/src/api/core/geom/update/curve.ts +209 -209
  112. package/src/api/core/geom/update/index.ts +29 -29
  113. package/src/api/core/geom/update/profile.ts +379 -379
  114. package/src/api/core/groups.ts +521 -521
  115. package/src/api/core/handles/index.ts +234 -234
  116. package/src/api/core/history/index.ts +84 -84
  117. package/src/api/core/index.ts +99 -99
  118. package/src/api/core/io/export/index.ts +126 -126
  119. package/src/api/core/io/import/index.ts +504 -504
  120. package/src/api/core/io/index.ts +42 -42
  121. package/src/api/core/io/job/index.ts +140 -140
  122. package/src/api/core/io/query/index.ts +71 -71
  123. package/src/api/core/io/terrain/index.ts +360 -360
  124. package/src/api/core/io/underlay/index.ts +705 -705
  125. package/src/api/core/layers.ts +540 -540
  126. package/src/api/core/math/index.ts +20 -20
  127. package/src/api/core/math/quat.ts +172 -172
  128. package/src/api/core/math/vec3.ts +179 -179
  129. package/src/api/core/mode/index.ts +108 -108
  130. package/src/api/core/project/index.ts +479 -479
  131. package/src/api/core/proposals/index.ts +570 -570
  132. package/src/api/core/storeys/index.ts +311 -308
  133. package/src/api/core/storeys/layers.ts +339 -339
  134. package/src/api/core/tags.ts +911 -911
  135. package/src/api/core/units/index.ts +164 -164
  136. package/src/api/core/user.ts +46 -46
  137. package/src/api/core/zoom/index.ts +64 -51
  138. package/src/api/design/bim.ts +210 -0
  139. package/src/api/design/boolean/index.ts +181 -179
  140. package/src/api/design/catalog.ts +203 -0
  141. package/src/api/design/create/bulk-items.ts +294 -254
  142. package/src/api/design/create/grids.ts +137 -137
  143. package/src/api/design/create/index.ts +2178 -1980
  144. package/src/api/design/create/opening-fields.ts +40 -37
  145. package/src/api/design/delete/index.ts +75 -74
  146. package/src/api/design/dimensions.ts +453 -453
  147. package/src/api/design/doors/index.ts +516 -500
  148. package/src/api/design/edit/index.ts +54 -54
  149. package/src/api/design/erase/index.ts +151 -151
  150. package/src/api/design/family.ts +1342 -704
  151. package/src/api/design/furniture/index.ts +319 -319
  152. package/src/api/design/grids.ts +237 -237
  153. package/src/api/design/index.ts +304 -274
  154. package/src/api/design/lock.ts +69 -69
  155. package/src/api/design/materials/index.ts +608 -608
  156. package/src/api/design/networks.ts +607 -0
  157. package/src/api/design/query/geometry/index.ts +319 -319
  158. package/src/api/design/query/grids.ts +197 -197
  159. package/src/api/design/query/index.ts +1236 -1226
  160. package/src/api/design/query/referenceLines.ts +52 -52
  161. package/src/api/design/query/spaces.ts +275 -275
  162. package/src/api/design/selection/index.ts +273 -273
  163. package/src/api/design/shared.ts +40 -40
  164. package/src/api/design/transform/index.ts +254 -254
  165. package/src/api/design/types/index.ts +163 -156
  166. package/src/api/design/update/index.ts +1096 -983
  167. package/src/api/design/visibility.ts +143 -143
  168. package/src/api/design/windows/index.ts +351 -333
  169. package/src/api/entity/buildableEnvelope.ts +397 -322
  170. package/src/api/entity/index.ts +30 -30
  171. package/src/api/entity/referenceLine.ts +235 -235
  172. package/src/api/entity/space.ts +612 -612
  173. package/src/api/entity/story.ts +517 -517
  174. package/src/api/index.ts +47 -47
  175. package/src/api/presentation/aiInspiration.ts +1116 -1116
  176. package/src/api/presentation/annotate.ts +417 -385
  177. package/src/api/presentation/camera.ts +289 -289
  178. package/src/api/presentation/diagrams.ts +194 -194
  179. package/src/api/presentation/drawingContract.ts +70 -0
  180. package/src/api/presentation/drawings.ts +1179 -0
  181. package/src/api/presentation/export.ts +134 -108
  182. package/src/api/presentation/import.ts +159 -159
  183. package/src/api/presentation/index.ts +160 -126
  184. package/src/api/presentation/placedViews.ts +1211 -1120
  185. package/src/api/presentation/sections.ts +420 -0
  186. package/src/api/presentation/shapes.ts +274 -274
  187. package/src/api/presentation/sheets.ts +746 -585
  188. package/src/api/presentation/slideshow.ts +134 -134
  189. package/src/api/presentation/tables.ts +84 -84
  190. package/src/api/presentation/viewPresets.ts +241 -0
  191. package/src/api/presentation/views.ts +742 -673
  192. package/src/api/presentation/walkthroughs.ts +1201 -1201
  193. package/src/api/program/adjacency.ts +164 -164
  194. package/src/api/program/areas.ts +408 -408
  195. package/src/api/program/classification.ts +138 -138
  196. package/src/api/program/cores.ts +83 -83
  197. package/src/api/program/departments.ts +517 -517
  198. package/src/api/program/index.ts +73 -73
  199. package/src/api/program/labels.ts +332 -332
  200. package/src/api/program/layout.ts +422 -422
  201. package/src/api/program/metadata.ts +364 -364
  202. package/src/api/program/metrics.ts +120 -120
  203. package/src/api/program/site.ts +748 -748
  204. package/src/api/program/spreadsheet.ts +2698 -2698
  205. package/src/api/workspace/index.ts +612 -612
  206. package/src/errors/codes.ts +143 -136
  207. package/src/errors/envelope.ts +75 -75
  208. package/src/errors/index.ts +21 -21
  209. package/src/errors/plugin-error.ts +134 -134
  210. package/src/handles.ts +297 -297
  211. package/src/host-utils.ts +67 -67
  212. package/src/index.ts +7 -7
  213. package/src/massParameters.ops.ts +246 -246
  214. package/src/massParameters.ts +427 -427
  215. package/src/types.ts +16 -16
  216. package/test/drawingContract.test.mjs +288 -0
  217. package/test/errors.test.mjs +185 -184
  218. package/test/massParameters.test.mjs +952 -952
  219. package/test/presentationViewSettings.test.mjs +85 -0
  220. package/tsconfig.json +22 -22
  221. package/tsup.config.ts +12 -12
@@ -0,0 +1,420 @@
1
+ import * as z from "zod"
2
+ import type { PluginApiReturn } from "../../types"
3
+ import { Vec3Components } from "../../handles"
4
+
5
+ /** A point on the plan: world `x` and `z` in babylon units. */
6
+ export const PluginSectionPoint = z
7
+ .object({ x: z.number().finite(), z: z.number().finite() })
8
+ .strict()
9
+ export type PluginSectionPoint = z.infer<typeof PluginSectionPoint>
10
+
11
+ /**
12
+ * A section: a line drawn on the plan that cuts the model and looks one way
13
+ * along it.
14
+ *
15
+ * | Property | Type | Description |
16
+ * |---|---|---|
17
+ * | `sectionId` | `string` | The section's id |
18
+ * | `name` | `string` | Its name in the Views panel ("Section 1") |
19
+ * | `tagLabel` | `string` | What its heads are marked with on the plan ("A") |
20
+ * | `buildingId` | `string` | The building it belongs to |
21
+ * | `start` | {@linkcode PluginSectionPoint} | First head on the plan |
22
+ * | `end` | {@linkcode PluginSectionPoint} | Second head on the plan |
23
+ * | `isFlipped` | `boolean` | Looks the other way along the line |
24
+ * | `depth` | `number` | How far behind the line the view keeps, babylon units |
25
+ * | `base` | `number` | Bottom of the slice, world Y |
26
+ * | `top` | `number` | Top of the slice, world Y |
27
+ * | `isHidden` | `boolean` | The line is hidden on the plan |
28
+ * | `isLocked` | `boolean` | Geometry edits are refused |
29
+ * | `isActive` | `boolean` | It is the section view open now |
30
+ */
31
+ export const PluginSection = z.object({
32
+ sectionId: z.string(),
33
+ name: z.string(),
34
+ tagLabel: z.string(),
35
+ buildingId: z.string(),
36
+ start: PluginSectionPoint,
37
+ end: PluginSectionPoint,
38
+ isFlipped: z.boolean(),
39
+ depth: z.number(),
40
+ base: z.number(),
41
+ top: z.number(),
42
+ isHidden: z.boolean(),
43
+ isLocked: z.boolean(),
44
+ isActive: z.boolean(),
45
+ })
46
+ export type PluginSection = z.infer<typeof PluginSection>
47
+
48
+ export const PluginSectionIdArgs = z
49
+ .object({ sectionId: z.string().min(1) })
50
+ .strict()
51
+ export type PluginSectionIdArgs = z.infer<typeof PluginSectionIdArgs>
52
+
53
+ /**
54
+ * Options for {@linkcode PluginPresentationSectionsApi.create}.
55
+ *
56
+ * | Property | Type | Description |
57
+ * |---|---|---|
58
+ * | `name` | `string \| undefined` | Name in the Views panel (default: the next "Section N") |
59
+ * | `tagLabel` | `string \| undefined` | Head mark on the plan (default: the next free mark) |
60
+ * | `depth` | `number \| undefined` | How far behind the line the view keeps (default: to the far side of the model) |
61
+ * | `base` | `number \| undefined` | Bottom of the slice, world Y (default: the building's base) |
62
+ * | `top` | `number \| undefined` | Top of the slice, world Y (default: the building's top) |
63
+ * | `buildingId` | `string \| undefined` | Building it belongs to (default: the active one) |
64
+ * | `isActive` | `boolean \| undefined` | Open the section view once created (default `false`) |
65
+ */
66
+ export const PluginSectionCreateOptions = z
67
+ .object({
68
+ name: z.string().trim().min(1).optional(),
69
+ tagLabel: z.string().trim().min(1).optional(),
70
+ depth: z.number().finite().positive().optional(),
71
+ base: z.number().finite().optional(),
72
+ top: z.number().finite().optional(),
73
+ buildingId: z.string().min(1).optional(),
74
+ isActive: z.boolean().optional(),
75
+ })
76
+ .strict()
77
+ export type PluginSectionCreateOptions = z.infer<
78
+ typeof PluginSectionCreateOptions
79
+ >
80
+
81
+ export const PluginSectionCreateArgs = z
82
+ .object({
83
+ start: PluginSectionPoint,
84
+ end: PluginSectionPoint,
85
+ options: PluginSectionCreateOptions.optional(),
86
+ })
87
+ .strict()
88
+ export type PluginSectionCreateArgs = z.infer<typeof PluginSectionCreateArgs>
89
+
90
+ /**
91
+ * The fields to change in {@linkcode PluginPresentationSectionsApi.update};
92
+ * omitted fields keep their value.
93
+ *
94
+ * | Property | Type | Description |
95
+ * |---|---|---|
96
+ * | `name` | `string \| undefined` | Name in the Views panel |
97
+ * | `tagLabel` | `string \| undefined` | Head mark on the plan |
98
+ * | `start` | {@linkcode PluginSectionPoint} `\| undefined` | First head |
99
+ * | `end` | {@linkcode PluginSectionPoint} `\| undefined` | Second head |
100
+ * | `isFlipped` | `boolean \| undefined` | Look the other way; without `depth`, the depth re-spans the model the new way |
101
+ * | `depth` | `number \| undefined` | View depth behind the line, > 0 |
102
+ * | `base` | `number \| undefined` | Bottom of the slice, world Y |
103
+ * | `top` | `number \| undefined` | Top of the slice, world Y; above `base` |
104
+ * | `isHidden` | `boolean \| undefined` | Hide the line on the plan |
105
+ */
106
+ export const PluginSectionPatch = z
107
+ .object({
108
+ name: z.string().trim().min(1).optional(),
109
+ tagLabel: z.string().trim().min(1).optional(),
110
+ start: PluginSectionPoint.optional(),
111
+ end: PluginSectionPoint.optional(),
112
+ isFlipped: z.boolean().optional(),
113
+ depth: z.number().finite().positive().optional(),
114
+ base: z.number().finite().optional(),
115
+ top: z.number().finite().optional(),
116
+ isHidden: z.boolean().optional(),
117
+ })
118
+ .strict()
119
+ export type PluginSectionPatch = z.infer<typeof PluginSectionPatch>
120
+
121
+ export const PluginSectionUpdateArgs = PluginSectionIdArgs.extend({
122
+ patch: PluginSectionPatch,
123
+ })
124
+ export type PluginSectionUpdateArgs = z.infer<typeof PluginSectionUpdateArgs>
125
+
126
+ /**
127
+ * Options for {@linkcode PluginPresentationSectionsApi.getCut}.
128
+ *
129
+ * | Property | Type | Description |
130
+ * |---|---|---|
131
+ * | `maxSegmentsPerElement` | `number \| undefined` | Outline segments to return per element, 0 to 2000 (default 0: none) |
132
+ */
133
+ export const PluginSectionCutOptions = z
134
+ .object({
135
+ maxSegmentsPerElement: z.number().int().min(0).max(2000).optional(),
136
+ })
137
+ .strict()
138
+ export type PluginSectionCutOptions = z.infer<typeof PluginSectionCutOptions>
139
+
140
+ export const PluginSectionCutArgs = PluginSectionIdArgs.extend({
141
+ options: PluginSectionCutOptions.optional(),
142
+ })
143
+ export type PluginSectionCutArgs = z.infer<typeof PluginSectionCutArgs>
144
+
145
+ /**
146
+ * A rect on the cutting plane. `u` runs along the line from the first head
147
+ * (0) to the second (the line's length); `v` is world Y.
148
+ */
149
+ export const PluginSectionExtent = z.object({
150
+ uMin: z.number(),
151
+ uMax: z.number(),
152
+ vMin: z.number(),
153
+ vMax: z.number(),
154
+ })
155
+ export type PluginSectionExtent = z.infer<typeof PluginSectionExtent>
156
+
157
+ /**
158
+ * One element a section cuts.
159
+ *
160
+ * | Property | Type | Description |
161
+ * |---|---|---|
162
+ * | `entityId` | `string` | The element's component id (a `ComponentHandle`) |
163
+ * | `type` | `string` | Its component type ("wall", "slab", "mass", …) |
164
+ * | `area` | `number` | Cut area inside the section's extents, square babylon units |
165
+ * | `perimeter` | `number` | Length of the cut outline inside the extents, babylon units |
166
+ * | `extent` | {@linkcode PluginSectionExtent} | Where the cut lies on the plane |
167
+ * | `isHatched` | `boolean` | `false` for masses and voids, which the drawing leaves unfilled |
168
+ * | `isOpening` | `boolean` | Doors and windows, which the drawing fills white |
169
+ * | `segments` | `[u0, v0, u1, v1][]` | Cut outline segments, when asked for |
170
+ * | `droppedSegmentCount` | `number` | Segments not returned because of `maxSegmentsPerElement` |
171
+ */
172
+ export const PluginSectionCutElement = z.object({
173
+ entityId: z.string(),
174
+ type: z.string(),
175
+ area: z.number(),
176
+ perimeter: z.number(),
177
+ extent: PluginSectionExtent,
178
+ isHatched: z.boolean(),
179
+ isOpening: z.boolean(),
180
+ segments: z.array(z.tuple([z.number(), z.number(), z.number(), z.number()])),
181
+ droppedSegmentCount: z.number().int(),
182
+ })
183
+ export type PluginSectionCutElement = z.infer<typeof PluginSectionCutElement>
184
+
185
+ /**
186
+ * What a section cuts, from {@linkcode PluginPresentationSectionsApi.getCut}.
187
+ *
188
+ * | Property | Type | Description |
189
+ * |---|---|---|
190
+ * | `sectionId` | `string` | The section |
191
+ * | `origin` | `{ x, y, z }` | World point at `u = 0, v = 0`: the first head, at Y 0 |
192
+ * | `uAxis` | `{ x, y, z }` | Unit direction of `u`: from the first head to the second |
193
+ * | `normal` | `{ x, y, z }` | Unit direction the section looks |
194
+ * | `extent` | {@linkcode PluginSectionExtent} | The cut rect: `u` 0 to the line's length, `v` base to top |
195
+ * | `elements` | {@linkcode PluginSectionCutElement}`[]` | What it cuts, largest area first |
196
+ * | `candidateCount` | `number` | Meshes near the plane that were tested |
197
+ * | `durationInMs` | `number` | Time the query took |
198
+ */
199
+ export const PluginSectionCut = z.object({
200
+ sectionId: z.string(),
201
+ origin: Vec3Components,
202
+ uAxis: Vec3Components,
203
+ normal: Vec3Components,
204
+ extent: PluginSectionExtent,
205
+ elements: z.array(PluginSectionCutElement),
206
+ candidateCount: z.number().int(),
207
+ durationInMs: z.number(),
208
+ })
209
+ export type PluginSectionCut = z.infer<typeof PluginSectionCut>
210
+
211
+ /**
212
+ * Sections: lines on the plan that cut the model, each with its own section
213
+ * view.
214
+ *
215
+ * A section is a cutting plane through its line, vertical, looking one way
216
+ * along it; its view keeps `depth` behind the line, between `base` and `top`.
217
+ * Create, read, edit and delete sections (`create`, `list`, `get`, `update`,
218
+ * `delete`), open one's view (`setActive`, `getActive`), and ask what it cuts
219
+ * (`getCut`): which elements the plane passes through, with the area, outline
220
+ * and extent of each cut. `getCut` is computed from the model, needs no open
221
+ * view and changes nothing.
222
+ *
223
+ * Writes are write-gated and each call is one undo step. Geometry edits
224
+ * (`start`, `end`, `isFlipped`, `depth`, `base`, `top`) are refused on a locked
225
+ * section; names, marks and hiding are not, and repeating a locked section's
226
+ * geometry unchanged is not a geometry edit. View-only collaborators cannot
227
+ * write.
228
+ *
229
+ * Positions are world coordinates in internal `babylon` units (1 unit =
230
+ * 0.254 m, Y up); a section's heads are plan points `{ x, z }`. Accessed via
231
+ * `snaptrude.presentation.sections`.
232
+ */
233
+ export abstract class PluginPresentationSectionsApi {
234
+ constructor() {}
235
+
236
+ /**
237
+ * List the project's sections, in Views panel order.
238
+ *
239
+ * @returns Every {@linkcode PluginSection} (`[]` when there are none).
240
+ *
241
+ * @examplePrompt Which sections are there?
242
+ * @examplePrompt List the section lines in this project
243
+ * @examplePrompt Is there a section through the stair?
244
+ *
245
+ * # Example
246
+ * ```ts
247
+ * const sections = await snaptrude.presentation.sections.list()
248
+ * ```
249
+ */
250
+ public abstract list(): PluginApiReturn<PluginSection[]>
251
+
252
+ /**
253
+ * Get one section by id.
254
+ *
255
+ * @param sectionId - The section's id
256
+ * @returns The {@linkcode PluginSection}, or `null` when there is none with that id.
257
+ *
258
+ * @examplePrompt Where does Section A run?
259
+ * @examplePrompt How deep is this section?
260
+ *
261
+ * # Example
262
+ * ```ts
263
+ * const section = await snaptrude.presentation.sections.get(sectionId)
264
+ * console.log(section?.start, section?.end)
265
+ * ```
266
+ */
267
+ public abstract get(sectionId: string): PluginApiReturn<PluginSection | null>
268
+
269
+ /**
270
+ * Get the section whose view is open.
271
+ *
272
+ * @returns The open {@linkcode PluginSection}, or `null` when no section view is open.
273
+ *
274
+ * @examplePrompt Which section am I looking at?
275
+ *
276
+ * # Example
277
+ * ```ts
278
+ * const open = await snaptrude.presentation.sections.getActive()
279
+ * ```
280
+ */
281
+ public abstract getActive(): PluginApiReturn<PluginSection | null>
282
+
283
+ /**
284
+ * Open a section's view, or close the open one with `null`. Opening frames
285
+ * the section's saved camera, or a straight-on view when it has none.
286
+ * Closing returns to 3D; with no section view open, `null` does nothing. Not
287
+ * an edit: nothing is added to the undo history.
288
+ *
289
+ * @param sectionId - The section to open, or `null` to close the section view
290
+ * @returns The open {@linkcode PluginSection}, or `null` after closing.
291
+ * @throws HANDLE_INVALID when there is no section with that id.
292
+ *
293
+ * @examplePrompt Open Section A
294
+ * @examplePrompt Show me the section through the atrium
295
+ * @examplePrompt Close the section view
296
+ *
297
+ * # Example
298
+ * ```ts
299
+ * await snaptrude.presentation.sections.setActive(section.sectionId)
300
+ * await snaptrude.presentation.sections.setActive(null)
301
+ * ```
302
+ */
303
+ public abstract setActive(
304
+ sectionId: string | null,
305
+ ): PluginApiReturn<PluginSection | null>
306
+
307
+ /**
308
+ * Draw a section line from `start` to `end` on the plan. The section looks
309
+ * along the line's direction turned a quarter turn — a line drawn toward +x
310
+ * looks toward +z; flip it with `update(id, { isFlipped: true })`. Its slice
311
+ * defaults to the building's full height and its depth to the far side of
312
+ * the model. Write-gated; one undo step.
313
+ *
314
+ * @param start - First head, a plan point `{ x, z }`
315
+ * @param end - Second head; must differ from `start`
316
+ * @param options - Name, mark, depth, slice, building and whether to open it ({@linkcode PluginSectionCreateOptions})
317
+ * @returns The new {@linkcode PluginSection}.
318
+ * @throws METHOD_NOT_PERMITTED when plugin writes are disabled. VALIDATION when
319
+ * `start` and `end` coincide or `top` is not above `base`. PRECONDITION_FAILED
320
+ * when the project is view-only or has no model to cut.
321
+ *
322
+ * @examplePrompt Cut a section through the middle of the building, east to west
323
+ * @examplePrompt Add a section across the stair core
324
+ * @examplePrompt Draw a longitudinal section and open it
325
+ *
326
+ * # Example
327
+ * ```ts
328
+ * const section = await snaptrude.presentation.sections.create(
329
+ * { x: -40, z: 10 },
330
+ * { x: 40, z: 10 },
331
+ * { name: "Longitudinal", isActive: true },
332
+ * )
333
+ * ```
334
+ */
335
+ public abstract create(
336
+ start: PluginSectionPoint,
337
+ end: PluginSectionPoint,
338
+ options?: PluginSectionCreateOptions,
339
+ ): PluginApiReturn<PluginSection>
340
+
341
+ /**
342
+ * Change a section. Only the given fields change; the whole patch is one
343
+ * undo step. Flipping without a `depth` carries the depth to the far side of
344
+ * the model in the new direction, as `create` does. Write-gated.
345
+ *
346
+ * @param sectionId - The section's id
347
+ * @param patch - The fields to change ({@linkcode PluginSectionPatch})
348
+ * @returns The updated {@linkcode PluginSection}.
349
+ * @throws METHOD_NOT_PERMITTED when plugin writes are disabled. HANDLE_INVALID when
350
+ * there is no section with that id. VALIDATION when the heads coincide or `top`
351
+ * is not above `base`. PRECONDITION_FAILED when the project is view-only, or the
352
+ * patch changes a locked section's geometry.
353
+ *
354
+ * @examplePrompt Make Section A look the other way
355
+ * @examplePrompt Only show the ground floor in this section
356
+ * @examplePrompt Rename the section to "Through atrium"
357
+ * @examplePrompt Move the section line 5 m north
358
+ *
359
+ * # Example
360
+ * ```ts
361
+ * await snaptrude.presentation.sections.update(sectionId, {
362
+ * isFlipped: true,
363
+ * depth: 60,
364
+ * })
365
+ * ```
366
+ */
367
+ public abstract update(
368
+ sectionId: string,
369
+ patch: PluginSectionPatch,
370
+ ): PluginApiReturn<PluginSection>
371
+
372
+ /**
373
+ * Delete a section. Closes its view first if it is open. Write-gated; one
374
+ * undo step.
375
+ *
376
+ * @param sectionId - The section's id
377
+ * @returns `true` once it has been deleted.
378
+ * @throws METHOD_NOT_PERMITTED when plugin writes are disabled. HANDLE_INVALID when
379
+ * there is no section with that id. PRECONDITION_FAILED when the project is view-only.
380
+ *
381
+ * @examplePrompt Delete Section B
382
+ *
383
+ * # Example
384
+ * ```ts
385
+ * await snaptrude.presentation.sections.delete(sectionId)
386
+ * ```
387
+ */
388
+ public abstract delete(sectionId: string): PluginApiReturn<boolean>
389
+
390
+ /**
391
+ * What a section cuts: every element its cutting plane passes through within
392
+ * the section's extents, with the cut's area, outline length and extent on
393
+ * the plane, largest first. Computed from the model, not from the drawing, so
394
+ * it needs no open view and works however the section is shown; furniture is
395
+ * left out, as in the drawing, and so is anything hidden in the model. Areas are exact for closed solids. Repeated
396
+ * calls reuse the cuts of elements that have not changed. Read-only.
397
+ *
398
+ * @param sectionId - The section's id
399
+ * @param options - Whether to return outline segments ({@linkcode PluginSectionCutOptions})
400
+ * @returns The {@linkcode PluginSectionCut}.
401
+ * @throws HANDLE_INVALID when there is no section with that id.
402
+ *
403
+ * @examplePrompt Which walls does Section A cut?
404
+ * @examplePrompt How thick is the slab where the section crosses it?
405
+ * @examplePrompt Does this section go through the stair?
406
+ * @examplePrompt What is the floor-to-floor height in this section?
407
+ *
408
+ * # Example
409
+ * ```ts
410
+ * const cut = await snaptrude.presentation.sections.getCut(sectionId)
411
+ * const walls = cut.elements.filter((element) => element.type === "wall")
412
+ * const thickest = walls[0]
413
+ * console.log(thickest.extent.uMax - thickest.extent.uMin)
414
+ * ```
415
+ */
416
+ public abstract getCut(
417
+ sectionId: string,
418
+ options?: PluginSectionCutOptions,
419
+ ): PluginApiReturn<PluginSectionCut>
420
+ }