@snaptrude/plugin-core 0.0.0-dev-20260908074328 → 0.0.0-surfaces-20260921090636

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 (73) hide show
  1. package/CHANGELOG.md +0 -23
  2. package/api-manifest.json +151 -12
  3. package/dist/api/core/geom/create/index.d.ts +918 -93
  4. package/dist/api/core/geom/create/index.d.ts.map +1 -1
  5. package/dist/api/core/geom/query/brep.d.ts +50 -0
  6. package/dist/api/core/geom/query/brep.d.ts.map +1 -1
  7. package/dist/api/core/geom/query/curve.d.ts +58 -35
  8. package/dist/api/core/geom/query/curve.d.ts.map +1 -1
  9. package/dist/api/core/geom/query/edge.d.ts +2 -2
  10. package/dist/api/core/geom/query/face.d.ts +105 -0
  11. package/dist/api/core/geom/query/face.d.ts.map +1 -1
  12. package/dist/api/core/geom/update/curve.d.ts +5 -5
  13. package/dist/api/core/geom/update/profile.d.ts +1 -1
  14. package/dist/api/design/create/index.d.ts +6 -29
  15. package/dist/api/design/create/index.d.ts.map +1 -1
  16. package/dist/api/design/delete/index.d.ts +2 -20
  17. package/dist/api/design/delete/index.d.ts.map +1 -1
  18. package/dist/api/design/query/geometry/index.d.ts +27 -1
  19. package/dist/api/design/query/geometry/index.d.ts.map +1 -1
  20. package/dist/api/design/query/index.d.ts +47 -2
  21. package/dist/api/design/query/index.d.ts.map +1 -1
  22. package/dist/api/design/query/spaces.d.ts +5 -66
  23. package/dist/api/design/query/spaces.d.ts.map +1 -1
  24. package/dist/api/design/update/index.d.ts +87 -0
  25. package/dist/api/design/update/index.d.ts.map +1 -1
  26. package/dist/api/entity/referenceLine.d.ts +2 -2
  27. package/dist/api/entity/referenceLine.d.ts.map +1 -1
  28. package/dist/api/entity/space.d.ts +5 -7
  29. package/dist/api/entity/space.d.ts.map +1 -1
  30. package/dist/api/entity/story.d.ts +4 -4
  31. package/dist/api/presentation/placedViews.d.ts +1 -35
  32. package/dist/api/presentation/placedViews.d.ts.map +1 -1
  33. package/dist/api/presentation/sheets.d.ts +2 -20
  34. package/dist/api/presentation/sheets.d.ts.map +1 -1
  35. package/dist/api/program/site.d.ts +4 -4
  36. package/dist/api/program/spreadsheet.d.ts +4 -4
  37. package/dist/errors/codes.d.ts +3 -8
  38. package/dist/errors/codes.d.ts.map +1 -1
  39. package/dist/handles.d.ts +12 -3
  40. package/dist/handles.d.ts.map +1 -1
  41. package/dist/index.cjs +3188 -2769
  42. package/dist/index.cjs.map +1 -1
  43. package/dist/index.d.ts +2 -0
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +3141 -2764
  46. package/dist/index.js.map +1 -1
  47. package/dist/massParameters.d.ts +280 -0
  48. package/dist/massParameters.d.ts.map +1 -0
  49. package/dist/massParameters.ops.d.ts +135 -0
  50. package/dist/massParameters.ops.d.ts.map +1 -0
  51. package/package.json +1 -1
  52. package/src/api/core/geom/create/index.ts +1011 -94
  53. package/src/api/core/geom/query/brep.ts +51 -0
  54. package/src/api/core/geom/query/curve.ts +25 -2
  55. package/src/api/core/geom/query/edge.ts +2 -2
  56. package/src/api/core/geom/query/face.ts +109 -4
  57. package/src/api/design/create/index.ts +8 -34
  58. package/src/api/design/delete/index.ts +1 -20
  59. package/src/api/design/query/geometry/index.ts +29 -0
  60. package/src/api/design/query/index.ts +50 -2
  61. package/src/api/design/query/spaces.ts +0 -68
  62. package/src/api/design/update/index.ts +94 -0
  63. package/src/api/entity/space.ts +0 -2
  64. package/src/api/presentation/placedViews.ts +1 -29
  65. package/src/api/presentation/sheets.ts +3 -19
  66. package/src/errors/codes.ts +2 -30
  67. package/src/handles.ts +15 -3
  68. package/src/index.ts +2 -0
  69. package/src/massParameters.ops.ts +243 -0
  70. package/src/massParameters.ts +418 -0
  71. package/test/errors.test.mjs +0 -4
  72. package/test/massParameters.test.mjs +936 -0
  73. package/snaptrude-plugin-core-0.11.0.tgz +0 -0
@@ -174,6 +174,11 @@ export abstract class PluginGeomQueryBrepApi {
174
174
  * | `"line"` | `startPoint`, `endPoint`, `length` |
175
175
  * | `"arc"` | `startPoint`, `endPoint`, `centre`, `axis`, `radius`, `length` |
176
176
  * | `"circle"` | `centre`, `axis`, `radius`, `length` — a full-circle edge (e.g. a cylinder cap rim) |
177
+ * | `"spline"` | `startPoint`, `endPoint`, `degree`, `controlPoints`, `knots`, `length` — a free-form NURBS edge |
178
+ *
179
+ * For a `"spline"` edge, `knots` is the **expanded** knot vector — each knot
180
+ * repeated by its multiplicity, the textbook NURBS form — so
181
+ * `knots.length === controlPoints.length + degree + 1`.
177
182
  *
178
183
  * @param brep The brep the edge belongs to
179
184
  * @param edge The edge whose curve to read
@@ -184,6 +189,7 @@ export abstract class PluginGeomQueryBrepApi {
184
189
  * @examplePrompt Is this edge straight or an arc?
185
190
  * @examplePrompt Get the exact start and end points of this edge
186
191
  * @examplePrompt Measure the length of each edge of this mass
192
+ * @examplePrompt Read the control points of this curved edge
187
193
  *
188
194
  * # Example
189
195
  * ```ts
@@ -219,6 +225,16 @@ export abstract class PluginGeomQueryBrepApi {
219
225
  radius: number
220
226
  length: number
221
227
  }
228
+ | {
229
+ type: "spline"
230
+ startPoint: Vec3Components
231
+ endPoint: Vec3Components
232
+ degree: number
233
+ controlPoints: Vec3Components[]
234
+ /** Expanded by multiplicity: `controlPoints.length + degree + 1` entries. */
235
+ knots: number[]
236
+ length: number
237
+ }
222
238
  >
223
239
 
224
240
  /**
@@ -366,6 +382,37 @@ export abstract class PluginGeomQueryBrepApi {
366
382
  */
367
383
  public abstract getBoundingBox(brep: BrepHandle): PluginApiReturn<BBoxComponents>
368
384
 
385
+ /**
386
+ * Get the enclosed **volume** of a closed solid, integrated from its exact
387
+ * surfaces. Curved faces are measured analytically, not from their
388
+ * tessellation — a real sphere of radius 5 reports 523.6, whatever its
389
+ * triangle count. That makes this the reliable way to confirm a solid is the
390
+ * shape you intended (a torus should measure 2·π²·R·r²).
391
+ *
392
+ * Runs on the OpenCascade kernel (the first kernel call loads a wasm of tens
393
+ * of MB — expect a pause of seconds).
394
+ *
395
+ * @param brep The solid to measure
396
+ * @returns The enclosed volume in cubic raw Babylon units
397
+ * @throws OPERATION_FAILED if the kernel cannot compute the volume (the brep
398
+ * is not a closed solid)
399
+ *
400
+ * @examplePrompt What is the volume of this mass?
401
+ * @examplePrompt How much concrete is in this shape?
402
+ * @examplePrompt Check the volume of the dome I just made
403
+ *
404
+ * # Example
405
+ * ```ts
406
+ * const [mass] = await snaptrude.design.query.listMasses()
407
+ * const brep = await snaptrude.design.query.geometry.getBrep(mass)
408
+ * if (brep) {
409
+ * const volume = await snaptrude.core.geom.query.brep.getVolume(brep)
410
+ * console.log("volume:", volume)
411
+ * }
412
+ * ```
413
+ */
414
+ public abstract getVolume(brep: BrepHandle): PluginApiReturn<number>
415
+
369
416
  /**
370
417
  * Test whether two breps are geometrically equal.
371
418
  * @param brepA First brep
@@ -534,6 +581,10 @@ export type PluginGeomQueryBrepGetBoundingBoxArgs = z.infer<
534
581
  typeof PluginGeomQueryBrepGetBoundingBoxArgs
535
582
  >
536
583
 
584
+ /** Arguments for {@linkcode PluginGeomQueryBrepApi.getVolume}. `{ brep: BrepHandle }` */
585
+ export const PluginGeomQueryBrepGetVolumeArgs = brepArg
586
+ export type PluginGeomQueryBrepGetVolumeArgs = z.infer<typeof PluginGeomQueryBrepGetVolumeArgs>
587
+
537
588
  /**
538
589
  * Arguments for {@linkcode PluginGeomQueryBrepApi.isEqual}.
539
590
  *
@@ -3,8 +3,8 @@ import { PluginApiReturn } from "../../../../types"
3
3
  import { Vec3Handle, CurveHandle, LineHandle, Vec3Components } from "../../../../handles"
4
4
 
5
5
  /**
6
- * Curve queries — read-only geometric questions about curves (lines and arcs)
7
- * and the relationships between two curves (all-handle model, §11).
6
+ * Curve queries — read-only geometric questions about curves (lines, arcs and
7
+ * splines) and the relationships between two curves (all-handle model, §11).
8
8
  *
9
9
  * Every method takes opaque curve handles ({@linkcode CurveHandle}/{@linkcode LineHandle})
10
10
  * and point handles ({@linkcode Vec3Handle}) and returns plain values — points as
@@ -13,6 +13,29 @@ import { Vec3Handle, CurveHandle, LineHandle, Vec3Components } from "../../../..
13
13
  * {@linkcode CurveHandle} (or `null` when there is no result). No query mutates its
14
14
  * inputs.
15
15
  *
16
+ * ## Splines
17
+ *
18
+ * A {@linkcode CurveHandle} is a line, an arc, or a NURBS spline (minted by
19
+ * `core.geom.create.splineFromPoints`). Every method here accepts a spline at
20
+ * compile time, but only the reads backed by the engine's spline math answer
21
+ * for one today. The rest throw `PRECONDITION_FAILED` ("not supported for
22
+ * splines yet") — a typed refusal, never a quietly wrong answer.
23
+ *
24
+ * | Splines | Members |
25
+ * |---|---|
26
+ * | **supported** | {@linkcode PluginGeomQueryCurveApi.getStartPoint}, {@linkcode PluginGeomQueryCurveApi.getEndPoint}, {@linkcode PluginGeomQueryCurveApi.getLength}, {@linkcode PluginGeomQueryCurveApi.getTangent}, {@linkcode PluginGeomQueryCurveApi.listPoints}, {@linkcode PluginGeomQueryCurveApi.getNearestPoint} |
27
+ * | **not yet** | `getMidPoint`, `getChordLength`, `getNormal`, `getProjection`, `getPointAtDistance`, `getParameterAtPoint`, `getCurvature`, `getDistanceToPoint`, `getDistanceAlong`, `listSubdivisions`, `isLinear`, `isOnCurve`, `hasPoint`, `isEqual`, `isOverlapping`, `getCommonPart`, `listIntersections`, `getMergedCurve`, `isContinuous`, `isParallel`, `getShortestGap`, `getDistanceBetween` |
28
+ *
29
+ * {@linkcode PluginGeomQueryCurveApi.isOverlapping} is deliberately in the
30
+ * second row: its line/arc path falls back to structural equality, which would
31
+ * answer a spline pair wrongly rather than not at all.
32
+ *
33
+ * To work around the second row, sample the curve —
34
+ * {@linkcode PluginGeomQueryCurveApi.listPoints} then the ordinary
35
+ * `core.math.vec3` operations — or read a spline brep edge exactly with
36
+ * `core.geom.query.brep.getEdgeCurve`, which returns its degree, control points
37
+ * and knots.
38
+ *
16
39
  * Accessed via `snaptrude.core.geom.query.curve`.
17
40
  */
18
41
  export abstract class PluginGeomQueryCurveApi {
@@ -69,9 +69,9 @@ export abstract class PluginGeomQueryEdgeApi {
69
69
  public abstract listVertices(edge: EdgeHandle): PluginApiReturn<VertexHandle[]>
70
70
 
71
71
  /**
72
- * Get the underlying curve geometry of an edge (a line or arc).
72
+ * Get the underlying curve geometry of an edge (a line, arc or spline).
73
73
  * @param edge The edge to query
74
- * @returns The curve as a {@linkcode CurveHandle}, or `null` if it is a circle or unset
74
+ * @returns The curve as a {@linkcode CurveHandle} (`line_`, `arc_` or `spline_`), or `null` if it is a circle or unset
75
75
  *
76
76
  * # Example
77
77
  * ```ts
@@ -59,6 +59,49 @@ export abstract class PluginGeomQueryFaceApi {
59
59
  */
60
60
  public abstract getMaterialIndex(face: FaceHandle): PluginApiReturn<number>
61
61
 
62
+ /**
63
+ * Read what KIND of surface a face lies on. This is the one read that tells a
64
+ * genuinely curved face from a faceted approximation of one: every face of a
65
+ * 200-triangle "dome" answers `"plane"`, while a real dome has faces
66
+ * answering `"sphere"`. Use it to confirm a curved solid actually came out
67
+ * curved.
68
+ *
69
+ * | Value | Surface |
70
+ * |---|---|
71
+ * | `"plane"` | Flat face |
72
+ * | `"cylinder"` | Cylindrical face — constant radius about an axis |
73
+ * | `"cone"` | Conical face — a tapered ring (a cone or frustum side) |
74
+ * | `"sphere"` | Spherical face |
75
+ * | `"torus"` | Toroidal face — the ring surface of a donut |
76
+ * | `"spline"` | Free-form NURBS face |
77
+ *
78
+ * Pure read: no geometry kernel is loaded.
79
+ *
80
+ * @param face The face to query
81
+ * @returns The surface kind (see the table), or `null` when the face carries
82
+ * no surface classification
83
+ *
84
+ * @examplePrompt Is this face flat or curved?
85
+ * @examplePrompt Check that this dome is a real sphere, not a faceted approximation
86
+ * @examplePrompt What kind of surface is this face?
87
+ * @examplePrompt How many curved faces does this mass have?
88
+ *
89
+ * # Example
90
+ * ```ts
91
+ * const [mass] = await snaptrude.design.query.listMasses()
92
+ * const brep = await snaptrude.design.query.geometry.getBrep(mass)
93
+ * if (brep) {
94
+ * const faces = await snaptrude.core.geom.query.brep.listFaces(brep)
95
+ * const kinds = []
96
+ * for (const face of faces) kinds.push(await snaptrude.core.geom.query.face.getSurfaceKind(face))
97
+ * console.log("spherical faces:", kinds.filter((k) => k === "sphere").length)
98
+ * }
99
+ * ```
100
+ */
101
+ public abstract getSurfaceKind(
102
+ face: FaceHandle,
103
+ ): PluginApiReturn<"plane" | "cylinder" | "cone" | "sphere" | "torus" | "spline" | null>
104
+
62
105
  /**
63
106
  * Get a seed half-edge of a face's outer loop.
64
107
  * @param face The face to query
@@ -257,6 +300,56 @@ export abstract class PluginGeomQueryFaceApi {
257
300
  brep: BrepHandle,
258
301
  ): PluginApiReturn<Vec3Components[]>
259
302
 
303
+ /**
304
+ * Exact surface area of one face of `brep`, in internal length units SQUARED —
305
+ * integrated off the face's own surface, not its facets, so a curved patch
306
+ * reads exactly rather than as its triangles. Needs the parent brep: a face
307
+ * handle cannot name its own solid.
308
+ * @param face The face to measure
309
+ * @param brep The parent brep (owner last, as in
310
+ * {@linkcode PluginGeomQueryFaceApi.listVertexPositions})
311
+ * @returns The area as a `number`
312
+ * @throws VALIDATION if `face` is not a face of `brep`
313
+ * @throws OPERATION_FAILED if the kernel could not measure the face
314
+ *
315
+ * @examplePrompt How big is this roof patch?
316
+ * @examplePrompt Which face of this mass has the largest area?
317
+ *
318
+ * # Example
319
+ * ```ts
320
+ * const [mass] = await snaptrude.design.query.listMasses()
321
+ * const brep = await snaptrude.design.query.geometry.getBrep(mass)
322
+ * if (brep) {
323
+ * const faces = await snaptrude.core.geom.query.brep.listFaces(brep)
324
+ * const areas = await Promise.all(
325
+ * faces.map((f) => snaptrude.core.geom.query.face.getArea(f, brep)),
326
+ * )
327
+ * }
328
+ * ```
329
+ */
330
+ public abstract getArea(face: FaceHandle, brep: BrepHandle): PluginApiReturn<number>
331
+
332
+ /**
333
+ * Centre of area of one face of `brep`, as a point in that brep's frame
334
+ * (internal length units). On a solid whose every face reads `"spline"` this
335
+ * is the read that tells two patches apart — the top of a thickened patch from
336
+ * its bottom, one quarter of a closed surface from the next.
337
+ * @param face The face to measure
338
+ * @param brep The parent brep (owner last)
339
+ * @returns The centroid as {@linkcode Vec3Components}
340
+ * @throws VALIDATION if `face` is not a face of `brep`
341
+ * @throws OPERATION_FAILED if the kernel could not measure the face
342
+ *
343
+ * @examplePrompt Where is the middle of this face?
344
+ * @examplePrompt Pick the topmost face of this curved mass
345
+ *
346
+ * # Example
347
+ * ```ts
348
+ * const centre = await snaptrude.core.geom.query.face.getCentroid(face, brep)
349
+ * ```
350
+ */
351
+ public abstract getCentroid(face: FaceHandle, brep: BrepHandle): PluginApiReturn<Vec3Components>
352
+
260
353
  /**
261
354
  * List the tessellated boundary points of a face's outer loop (arcs sampled,
262
355
  * sense-corrected). Not cardinality-equal to {@linkcode PluginGeomQueryFaceApi.listVertexPositions}.
@@ -301,6 +394,7 @@ export abstract class PluginGeomQueryFaceApi {
301
394
  }
302
395
 
303
396
  const faceArg = z.object({ face: FaceHandle })
397
+ const faceWithBrepArg = z.object({ face: FaceHandle, brep: BrepHandle })
304
398
 
305
399
  /** Arguments for {@linkcode PluginGeomQueryFaceApi.getIndex}. `{ face: FaceHandle }` */
306
400
  export const PluginGeomQueryFaceGetIndexArgs = faceArg
@@ -312,6 +406,12 @@ export type PluginGeomQueryFaceGetMaterialIndexArgs = z.infer<
312
406
  typeof PluginGeomQueryFaceGetMaterialIndexArgs
313
407
  >
314
408
 
409
+ /** Arguments for {@linkcode PluginGeomQueryFaceApi.getSurfaceKind}. `{ face: FaceHandle }` */
410
+ export const PluginGeomQueryFaceGetSurfaceKindArgs = faceArg
411
+ export type PluginGeomQueryFaceGetSurfaceKindArgs = z.infer<
412
+ typeof PluginGeomQueryFaceGetSurfaceKindArgs
413
+ >
414
+
315
415
  /** Arguments for {@linkcode PluginGeomQueryFaceApi.getHalfEdge}. `{ face: FaceHandle }` */
316
416
  export const PluginGeomQueryFaceGetHalfEdgeArgs = faceArg
317
417
  export type PluginGeomQueryFaceGetHalfEdgeArgs = z.infer<typeof PluginGeomQueryFaceGetHalfEdgeArgs>
@@ -382,14 +482,19 @@ export type PluginGeomQueryFaceGetHoleContainingHalfEdgeArgs = z.infer<
382
482
  * | `face` | {@linkcode FaceHandle} | The face to query |
383
483
  * | `brep` | {@linkcode BrepHandle} | The parent brep (source of vertex coordinates) |
384
484
  */
385
- export const PluginGeomQueryFaceListVertexPositionsArgs = z.object({
386
- face: FaceHandle,
387
- brep: BrepHandle,
388
- })
485
+ export const PluginGeomQueryFaceListVertexPositionsArgs = faceWithBrepArg
389
486
  export type PluginGeomQueryFaceListVertexPositionsArgs = z.infer<
390
487
  typeof PluginGeomQueryFaceListVertexPositionsArgs
391
488
  >
392
489
 
490
+ /** Arguments for {@linkcode PluginGeomQueryFaceApi.getArea}. `{ face: FaceHandle, brep: BrepHandle }` */
491
+ export const PluginGeomQueryFaceGetAreaArgs = faceWithBrepArg
492
+ export type PluginGeomQueryFaceGetAreaArgs = z.infer<typeof PluginGeomQueryFaceGetAreaArgs>
493
+
494
+ /** Arguments for {@linkcode PluginGeomQueryFaceApi.getCentroid}. `{ face: FaceHandle, brep: BrepHandle }` */
495
+ export const PluginGeomQueryFaceGetCentroidArgs = faceWithBrepArg
496
+ export type PluginGeomQueryFaceGetCentroidArgs = z.infer<typeof PluginGeomQueryFaceGetCentroidArgs>
497
+
393
498
  /** Arguments for {@linkcode PluginGeomQueryFaceApi.listVertexPositionsWithCurves}. `{ face: FaceHandle }` */
394
499
  export const PluginGeomQueryFaceListVertexPositionsWithCurvesArgs = faceArg
395
500
  export type PluginGeomQueryFaceListVertexPositionsWithCurvesArgs = z.infer<
@@ -217,26 +217,11 @@ export abstract class PluginDesignCreateApi {
217
217
  * Create a **floor** by extruding a footprint contour by `thickness`
218
218
  * (extruded upward).
219
219
  *
220
- * The parametric engine owns floor topology and may resolve the request
221
- * differently than asked: drawing against existing floors can **split** the
222
- * footprint into several floors, or **merge** it into a pre-existing
223
- * neighbour (that floor's region grows; nothing new is created). The call
224
- * honors the engine's resolution and returns **every floor that covers the
225
- * requested footprint after the operation** — the newly created floor(s),
226
- * and/or the pre-existing floor that absorbed it. The array is never empty
227
- * on success; a lone independently-created floor comes back as `[floor]`.
228
- *
229
- * **Breaking change in 0.11.0** — previously returned a single
230
- * {@linkcode ComponentHandle}; callers must switch to the array (the first
231
- * element preserves the old single-floor behavior for simple creates).
232
- *
233
220
  * @param contour - Footprint (outer + holes)
234
221
  * @param thickness - Floor thickness (> 0)
235
222
  * @param position - Offset from origin
236
- * @returns the {@linkcode ComponentHandle}s of every floor covering the
237
- * requested footprint after parametric resolution (created and/or absorbing)
238
- * @throws if the contour is invalid, the thickness is not positive, or the
239
- * engine rejected the operation (nothing covers the footprint)
223
+ * @returns the {@linkcode ComponentHandle} of the created floor
224
+ * @throws if the contour is invalid or the thickness is not positive
240
225
  *
241
226
  * @examplePrompt Create a floor from this room outline
242
227
  * @examplePrompt Add a 100mm thick floor over the footprint
@@ -247,14 +232,14 @@ export abstract class PluginDesignCreateApi {
247
232
  * ```ts
248
233
  * const rect = await snaptrude.core.geom.create.profileRect(5, 4)
249
234
  * const contour = await snaptrude.core.geom.create.contourFromProfile(rect)
250
- * const [floor, ...siblings] = await snaptrude.design.create.floor(contour, 0.1)
235
+ * const floor = await snaptrude.design.create.floor(contour, 0.1)
251
236
  * ```
252
237
  */
253
238
  public abstract floor(
254
239
  contour: ContourHandle,
255
240
  thickness: number,
256
241
  position?: Vec3Handle,
257
- ): PluginApiReturn<ComponentHandle[]>
242
+ ): PluginApiReturn<ComponentHandle>
258
243
 
259
244
  /**
260
245
  * Create a **roof** by extruding a footprint contour by `thickness`. Created
@@ -410,13 +395,7 @@ export abstract class PluginDesignCreateApi {
410
395
  * single undo entry. The storey must already exist
411
396
  * (`core.storeys.create` first). Default: geometry-derived — a profile
412
397
  * drawn at y = 0 lands on storey 1; the ACTIVE storey is NOT consulted.
413
- * @returns the actually-created wall {@linkcode ComponentHandle}s. The
414
- * parametric engine owns wall topology — curves touching existing walls
415
- * may merge into or split against them, so the returned count can differ
416
- * from the input curve count. Profile-ordered 1:1 matches come first,
417
- * then the remaining merged/split products in creation order. Re-query
418
- * (e.g. `design.query.spaces.listGeneratedBim`) rather than assuming a
419
- * wall per input curve.
398
+ * @returns a {@linkcode ComponentHandle}`[]` (one per wall), in profile order
420
399
  * @throws if the profile is empty, `wallType` names no wall type in the
421
400
  * project, `storey` does not exist, or wall creation fails
422
401
  *
@@ -558,9 +537,7 @@ export abstract class PluginDesignCreateApi {
558
537
  * the item's height yourself.
559
538
  * @param options - Optional placement options: `label` — instance name
560
539
  * (default auto `${name}Ins${n}`); `createNewSourceMesh` — emit a
561
- * source-mesh creation command (default `true`). `position.y` is always
562
- * grounded: the placed instance's bounding-box bottom rests at it (the
563
- * surface-flush grounding described above)
540
+ * source-mesh creation command (default `true`)
564
541
  * @param angleInDegrees - Optional signed rotation about the vertical axis, in
565
542
  * degrees (same convention as {@linkcode PluginDesignTransformApi.rotate}).
566
543
  * Applied at creation time so it is part of the placement's single undo entry.
@@ -594,10 +571,7 @@ export abstract class PluginDesignCreateApi {
594
571
  public abstract furniture(
595
572
  catalogId: string,
596
573
  position: Vec3Handle,
597
- options?: {
598
- label?: string
599
- createNewSourceMesh?: boolean
600
- },
574
+ options?: { label?: string; createNewSourceMesh?: boolean },
601
575
  angleInDegrees?: number,
602
576
  ): PluginApiReturn<ComponentHandle>
603
577
 
@@ -1245,7 +1219,7 @@ export const PluginDesignCreateWallsArgs = z.object({
1245
1219
  export type PluginDesignCreateWallsArgs = z.infer<
1246
1220
  typeof PluginDesignCreateWallsArgs
1247
1221
  >
1248
- // TRANSPORT: positional signature shipped:
1222
+ // TRANSPORT: positional signature shipped — storey is the trailing 5th arg:
1249
1223
  // walls(profile: ProfileHandle, height?: number, thickness?: number, wallType?: string, storey?: number)
1250
1224
 
1251
1225
  // ---------------------------------------------------------------------------
@@ -20,22 +20,6 @@ export const PluginDesignDeleteEntitiesArgs = z.object({
20
20
  })
21
21
  export type PluginDesignDeleteEntitiesArgs = z.infer<typeof PluginDesignDeleteEntitiesArgs>
22
22
 
23
- /**
24
- * Result of {@linkcode PluginDesignDeleteApi.entities} — the shared
25
- * change-result shape plus the delete cascade. Deliberately a delete-specific
26
- * extension of {@linkcode PluginDesignChangeResult} (which other change
27
- * mutations keep unchanged).
28
- *
29
- * | Property | Type | Description |
30
- * |---|---|---|
31
- * | `affected` | {@linkcode ComponentHandle}`[]` | The entities that were deleted (the resolved input set) |
32
- * | `cascaded` | {@linkcode ComponentHandle}`[]`? | Components PG2 removed as a consequence — derived walls/floors/slabs of deleted spaces; returned so callers can invalidate cached handles |
33
- */
34
- export const PluginDesignDeleteResult = PluginDesignChangeResult.extend({
35
- cascaded: z.array(ComponentHandle).optional(),
36
- })
37
- export type PluginDesignDeleteResult = z.infer<typeof PluginDesignDeleteResult>
38
-
39
23
  /**
40
24
  * `snaptrude.design.delete.*` — **hard removal** of scene BIM entities.
41
25
  *
@@ -59,9 +43,6 @@ export abstract class PluginDesignDeleteApi {
59
43
  * @returns The entities that were deleted, as {@linkcode ComponentHandle}`[]`
60
44
  * (echoed host-side from the resolved+deleted set — the engine returns no ids).
61
45
  * Deleted handles are **stale** afterwards: re-resolving one throws `HANDLE_INVALID`.
62
- * When the parametric engine removes further components as a consequence
63
- * (derived walls/floors/slabs of deleted spaces), those are reported in the
64
- * optional `cascaded` array — invalidate any cached handles to them too.
65
46
  * @throws If any supplied handle is unknown/forged (`HANDLE_INVALID`) — the whole
66
47
  * call rejects before anything is deleted (all-or-nothing resolution).
67
48
  *
@@ -85,5 +66,5 @@ export abstract class PluginDesignDeleteApi {
85
66
  */
86
67
  public abstract entities(
87
68
  components: ComponentHandle[],
88
- ): PluginApiReturn<PluginDesignDeleteResult>
69
+ ): PluginApiReturn<PluginDesignChangeResult>
89
70
  }
@@ -34,10 +34,25 @@ export abstract class PluginDesignQueryGeometryApi {
34
34
  * scene entity, as a reusable {@linkcode BrepHandle} for the
35
35
  * `core.geom.query.brep.*` reads.
36
36
  *
37
+ * **Frame.** By default the brep comes back in the component's own LOCAL frame
38
+ * (its vertices are relative to the mesh origin, exactly as stored) — the
39
+ * behaviour every 0.9.x caller relies on. Pass `{ frame: "world" }` to get the
40
+ * same solid placed where it sits in the scene (world coordinates, like
41
+ * `getBottomContour` / `getTriangulatedMeshes` and every `design.query.measure`
42
+ * read). Use `"world"` whenever the handle will be COMBINED with other scene
43
+ * geometry or committed back beside its source: booleans between two scene
44
+ * masses, `brepFromFillet` / `brepFromShell` / `brepFromOffset` /
45
+ * `brepFromChamfer` on a scene mass followed by `massFromBrep`, or comparing
46
+ * its vertices with a bounding box. A world-frame handle from a parametrically
47
+ * live mass also carries that mass's recipe, so an operation result keeps an
48
+ * editable record.
49
+ *
37
50
  * @param component - The scene component to read
51
+ * @param options - `frame`: `"local"` (default, mesh-local coordinates) or `"world"` (scene coordinates)
38
52
  * @returns The brep as a {@linkcode BrepHandle}, or `null` if the component has no brep geometry
39
53
  *
40
54
  * @examplePrompt Get the 3D solid geometry of the selected wall
55
+ * @examplePrompt Round the top rim of this column and put it back where it is
41
56
  * @examplePrompt How many faces does this mass have?
42
57
  * @examplePrompt Inspect the mesh of this slab so I can look at its faces and edges
43
58
  * @examplePrompt Read the vertices of the selected column's geometry
@@ -48,10 +63,16 @@ export abstract class PluginDesignQueryGeometryApi {
48
63
  * if (brep) {
49
64
  * const faces = await snaptrude.core.geom.query.brep.listFaces(brep)
50
65
  * }
66
+ *
67
+ * // Operate on a scene mass and commit the result where the mass sits:
68
+ * const placed = await snaptrude.design.query.geometry.getBrep(mass, { frame: "world" })
69
+ * const rounded = await snaptrude.core.geom.create.brepFromFillet(placed, edges, 0.2)
70
+ * await snaptrude.design.create.massFromBrep(rounded, "Rounded")
51
71
  * ```
52
72
  */
53
73
  public abstract getBrep(
54
74
  component: ComponentHandle,
75
+ options?: PluginDesignQueryGeometryGetBrepOptions,
55
76
  ): PluginApiReturn<BrepHandle | null>
56
77
 
57
78
  /**
@@ -189,8 +210,16 @@ export abstract class PluginDesignQueryGeometryApi {
189
210
  * |---|---|---|
190
211
  * | `component` | {@linkcode ComponentHandle} | The scene component to read |
191
212
  */
213
+ /** Options for {@linkcode PluginDesignQueryGeometryApi.getBrep}: `frame` defaults to `"local"`. */
214
+ export type PluginDesignQueryGeometryGetBrepOptions = { frame?: "local" | "world" }
215
+ export const PluginDesignQueryGeometryGetBrepOptions: z.ZodType<
216
+ PluginDesignQueryGeometryGetBrepOptions,
217
+ PluginDesignQueryGeometryGetBrepOptions
218
+ > = z.object({ frame: z.enum(["local", "world"]).optional() })
219
+
192
220
  export const PluginDesignQueryGeometryGetBrepArgs = z.object({
193
221
  component: ComponentHandle,
222
+ options: PluginDesignQueryGeometryGetBrepOptions.optional(),
194
223
  })
195
224
 
196
225
  export type PluginDesignQueryGeometryGetBrepArgs = z.infer<
@@ -1,6 +1,7 @@
1
1
  import * as z from "zod"
2
2
  import { PluginApiReturn } from "../../../types"
3
3
  import { ComponentHandle, BBoxComponents } from "../../../handles"
4
+ import type { MassParametersRecord } from "../../../massParameters"
4
5
  import {
5
6
  PluginSpaceType,
6
7
  PluginMassType,
@@ -175,7 +176,6 @@ export type PluginDesignQueryComponentsArgs = z.infer<
175
176
  * | `isLocked` | `boolean` | Lock flag |
176
177
  * | `isHidden` | `boolean` | User-hidden flag |
177
178
  * | `isSelected` | `boolean` | Current selection state |
178
- * | `isVisible` | `boolean` | Whether the entity currently has a visible representation on canvas (user hide flag AND LOD/mode gating both considered); read-only |
179
179
  * | `boundingBox` | {@linkcode BBoxComponents} | World-space AABB |
180
180
  * | `adjacency` | `{ spaceId: string; value: number }[]` | Adjacency relationships (spaces/masses only). `value`: `2` = Direct (required), `1` = Indirect or physical contact, `-1` = Restricted; `0` entries are filtered out. `[]` when adjacency has never been computed — see `program.adjacency.compute`. |
181
181
  */
@@ -195,7 +195,6 @@ export const PluginEntityProperties = z
195
195
  isLocked: z.boolean(),
196
196
  isHidden: z.boolean(),
197
197
  isSelected: z.boolean(),
198
- isVisible: z.boolean(),
199
198
  boundingBox: BBoxComponents,
200
199
  adjacency: z.array(z.object({ spaceId: z.string(), value: z.number() })),
201
200
  })
@@ -1016,6 +1015,55 @@ export abstract class PluginDesignQueryApi {
1016
1015
  staircase: ComponentHandle,
1017
1016
  ): PluginApiReturn<PluginStaircaseParams | null>
1018
1017
 
1018
+ /**
1019
+ * Read a mass's creation-parameter record — the recipe it was built from
1020
+ * (`kind` plus the values that constructor was called with). Present on
1021
+ * masses committed from a `core.geom.create` brep constructor that carries a
1022
+ * recipe: {@linkcode MassParametersRecord} covers the four primitives
1023
+ * (sphere, cylinder, cone, torus), extrusions, revolutions, lofts and sweeps.
1024
+ *
1025
+ * A fillet, chamfer, shell or offset of a recorded solid keeps the record
1026
+ * too: `kind` stays the base constructor and the operation is appended to the
1027
+ * record's `operations` list. Edit any of it with `design.update.parameters`.
1028
+ *
1029
+ * `null` for everything else — drawn masses, imported geometry, booleans,
1030
+ * split parts, `brepFromFaces` / `brepFromMesh`, and results built on a
1031
+ * source that carried no record — and for a mass whose record no longer
1032
+ * matches what is on
1033
+ * screen (a later free-form edit dropped the recipe, or the mass carries a
1034
+ * baked scale). `null` too when the recipe was not recordable: the record
1035
+ * schema has its own caps (a sweep path of at most 512 points, a loft of at
1036
+ * most 32 sections, at most 8 chained `operations`, at most 256 curves in one
1037
+ * profile loop and 64 holes in one contour), and a mass built past one of
1038
+ * them — through a route that does not enforce the matching creator cap —
1039
+ * commits as ordinary geometry carrying no record. The `operations` cap is
1040
+ * the one an agent can walk into by accident: a 9th chained
1041
+ * fillet/chamfer/shell/offset drops the record silently, so the result
1042
+ * commits as ordinary geometry and reads back `null` here. A record is never
1043
+ * reported unless it is still the truth.
1044
+ *
1045
+ * Points and axes come back in **world** coordinates. Pure read — nothing is
1046
+ * created or modified.
1047
+ *
1048
+ * @param component - the mass's {@linkcode ComponentHandle}
1049
+ * @returns the {@linkcode MassParametersRecord}, or `null`
1050
+ *
1051
+ * @examplePrompt What radius is this sphere?
1052
+ * @examplePrompt Is this mass parametric?
1053
+ * @examplePrompt Read back the dome's creation parameters
1054
+ * @examplePrompt How tall was this cylinder made?
1055
+ *
1056
+ * # Example
1057
+ * ```ts
1058
+ * const [mass] = await snaptrude.design.query.listMasses({ isSelected: true })
1059
+ * const params = await snaptrude.design.query.getParameters(mass)
1060
+ * if (params?.kind === "sphere") console.log("radius:", params.values.radius)
1061
+ * ```
1062
+ */
1063
+ public abstract getParameters(
1064
+ component: ComponentHandle,
1065
+ ): PluginApiReturn<MassParametersRecord | null>
1066
+
1019
1067
  /**
1020
1068
  * Get the **union** axis-aligned bounding box enclosing a set of entities.
1021
1069
  *
@@ -124,41 +124,6 @@ export abstract class PluginDesignQuerySpacesApi {
124
124
  public abstract getEnclosure(
125
125
  space: ComponentHandle,
126
126
  ): PluginApiReturn<PluginSpaceEnclosure | null>
127
-
128
- /**
129
- * List the space's **engine-generated BIM components** — the walls, floors
130
- * and slabs the parametric engine derived from this space, grouped by kind.
131
- *
132
- * Unlike {@linkcode getEnclosure} (a geometric best-effort match), this read
133
- * reports the engine's own derivation records, so every returned handle is a
134
- * component the engine created *for this space*.
135
- *
136
- * The derived set is NOT stable across writes: a merge/split/rebuild of the
137
- * space graph retires members and creates successors — re-query after any
138
- * write that touches the space. This is the churn-recovery anchor: when a
139
- * cached derived handle goes stale, call this again to pick up the current
140
- * set.
141
- *
142
- * @param space - The space (room mass) to read
143
- * @returns the generated component handles, grouped by kind
144
- * ({@linkcode PluginSpaceGeneratedBim}); a group is `[]` when the engine
145
- * derived nothing of that kind
146
- * @throws If the space does not exist or the component is not a space/mass
147
- *
148
- * @examplePrompt Which walls did this room generate?
149
- * @examplePrompt List the BIM components derived from the selected space
150
- * @examplePrompt Get the floors and slabs that belong to this room
151
- *
152
- * # Example
153
- * ```ts
154
- * const [space] = await snaptrude.design.query.listSpaces()
155
- * const bim = await snaptrude.design.query.spaces.listGeneratedBim(space)
156
- * console.log(`${bim.walls.length} walls, ${bim.floors.length} floors`)
157
- * ```
158
- */
159
- public abstract listGeneratedBim(
160
- space: ComponentHandle,
161
- ): PluginApiReturn<PluginSpaceGeneratedBim>
162
127
  }
163
128
 
164
129
  /**
@@ -308,36 +273,3 @@ export const PluginSpaceEnclosure = z.object({
308
273
  adjacentSpaces: z.array(PluginAdjacentSpace),
309
274
  })
310
275
  export type PluginSpaceEnclosure = z.infer<typeof PluginSpaceEnclosure>
311
-
312
- /**
313
- * Arguments for {@linkcode PluginDesignQuerySpacesApi.listGeneratedBim}.
314
- *
315
- * | Property | Type | Description |
316
- * |---|---|---|
317
- * | `space` | {@linkcode ComponentHandle} | The space (room mass) to read |
318
- */
319
- export const PluginDesignQuerySpacesListGeneratedBimArgs = z.object({
320
- space: ComponentHandle,
321
- })
322
- export type PluginDesignQuerySpacesListGeneratedBimArgs = z.infer<
323
- typeof PluginDesignQuerySpacesListGeneratedBimArgs
324
- >
325
-
326
- /**
327
- * Result of {@linkcode PluginDesignQuerySpacesApi.listGeneratedBim} — the
328
- * space's engine-generated BIM component handles, grouped by kind. The set
329
- * changes whenever a write merges/splits/rebuilds the space graph — re-query
330
- * after writes rather than caching it.
331
- *
332
- * | Property | Type | Description |
333
- * |---|---|---|
334
- * | `walls` | {@linkcode ComponentHandle}`[]` | Walls the engine derived from the space |
335
- * | `floors` | {@linkcode ComponentHandle}`[]` | Floors the engine derived from the space |
336
- * | `slabs` | {@linkcode ComponentHandle}`[]` | Slabs the engine derived from the space |
337
- */
338
- export const PluginSpaceGeneratedBim = z.object({
339
- walls: z.array(ComponentHandle),
340
- floors: z.array(ComponentHandle),
341
- slabs: z.array(ComponentHandle),
342
- })
343
- export type PluginSpaceGeneratedBim = z.infer<typeof PluginSpaceGeneratedBim>