@snaptrude/plugin-core 0.9.12 → 0.9.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -0
- package/api-manifest.json +778 -32
- package/dist/api/core/geom/create/index.d.ts +935 -100
- package/dist/api/core/geom/create/index.d.ts.map +1 -1
- package/dist/api/core/geom/query/brep.d.ts +59 -2
- package/dist/api/core/geom/query/brep.d.ts.map +1 -1
- package/dist/api/core/geom/query/curve.d.ts +59 -35
- package/dist/api/core/geom/query/curve.d.ts.map +1 -1
- package/dist/api/core/geom/query/edge.d.ts +2 -2
- package/dist/api/core/geom/query/face.d.ts +105 -0
- package/dist/api/core/geom/query/face.d.ts.map +1 -1
- package/dist/api/core/geom/update/contour.d.ts +2 -0
- package/dist/api/core/geom/update/contour.d.ts.map +1 -1
- package/dist/api/core/geom/update/curve.d.ts +5 -5
- package/dist/api/core/geom/update/profile.d.ts +3 -1
- package/dist/api/core/geom/update/profile.d.ts.map +1 -1
- package/dist/api/core/handles/index.d.ts +4 -2
- package/dist/api/core/handles/index.d.ts.map +1 -1
- package/dist/api/design/create/grids.d.ts +1 -1
- package/dist/api/design/family.d.ts +117 -10
- package/dist/api/design/family.d.ts.map +1 -1
- package/dist/api/design/query/geometry/index.d.ts +33 -5
- package/dist/api/design/query/geometry/index.d.ts.map +1 -1
- package/dist/api/design/query/grids.d.ts +3 -3
- package/dist/api/design/query/index.d.ts +47 -0
- package/dist/api/design/query/index.d.ts.map +1 -1
- package/dist/api/design/query/spaces.d.ts +5 -5
- package/dist/api/design/update/index.d.ts +99 -0
- package/dist/api/design/update/index.d.ts.map +1 -1
- package/dist/api/entity/referenceLine.d.ts +1 -1
- package/dist/api/entity/space.d.ts +4 -4
- package/dist/api/entity/story.d.ts +4 -4
- package/dist/api/program/site.d.ts +4 -4
- package/dist/api/program/spreadsheet.d.ts +4 -4
- package/dist/handles.d.ts +13 -3
- package/dist/handles.d.ts.map +1 -1
- package/dist/index.cjs +3420 -2943
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3372 -2943
- package/dist/index.js.map +1 -1
- package/dist/massParameters.d.ts +287 -0
- package/dist/massParameters.d.ts.map +1 -0
- package/dist/massParameters.ops.d.ts +138 -0
- package/dist/massParameters.ops.d.ts.map +1 -0
- package/package.json +2 -1
- package/scripts/check-dist-fresh.mjs +22 -0
- package/src/api/core/geom/create/index.ts +1030 -101
- package/src/api/core/geom/query/brep.ts +60 -2
- package/src/api/core/geom/query/curve.ts +26 -2
- package/src/api/core/geom/query/edge.ts +2 -2
- package/src/api/core/geom/query/face.ts +109 -4
- package/src/api/core/geom/update/contour.ts +2 -0
- package/src/api/core/geom/update/profile.ts +2 -0
- package/src/api/core/handles/index.ts +3 -2
- package/src/api/design/family.ts +123 -10
- package/src/api/design/query/geometry/index.ts +35 -4
- package/src/api/design/query/index.ts +50 -0
- package/src/api/design/update/index.ts +106 -0
- package/src/handles.ts +18 -3
- package/src/index.ts +2 -0
- package/src/massParameters.ops.ts +246 -0
- package/src/massParameters.ts +427 -0
- package/test/massParameters.test.mjs +952 -0
|
@@ -174,16 +174,26 @@ 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
|
|
180
185
|
* @returns The curve data as a discriminated union on `type` (see table above)
|
|
181
186
|
* @throws VALIDATION if the edge is not on `brep`
|
|
187
|
+
* @throws PRECONDITION_FAILED if the edge is a RATIONAL (weighted) spline —
|
|
188
|
+
* e.g. a NURBS-converted elliptical intersection edge. The wire form
|
|
189
|
+
* carries no weights, so such an edge is refused rather than reported as a
|
|
190
|
+
* different curve; sample it instead.
|
|
182
191
|
*
|
|
183
192
|
* @examplePrompt Read the radius of this curved edge
|
|
184
193
|
* @examplePrompt Is this edge straight or an arc?
|
|
185
194
|
* @examplePrompt Get the exact start and end points of this edge
|
|
186
195
|
* @examplePrompt Measure the length of each edge of this mass
|
|
196
|
+
* @examplePrompt Read the control points of this curved edge
|
|
187
197
|
*
|
|
188
198
|
* # Example
|
|
189
199
|
* ```ts
|
|
@@ -219,6 +229,16 @@ export abstract class PluginGeomQueryBrepApi {
|
|
|
219
229
|
radius: number
|
|
220
230
|
length: number
|
|
221
231
|
}
|
|
232
|
+
| {
|
|
233
|
+
type: "spline"
|
|
234
|
+
startPoint: Vec3Components
|
|
235
|
+
endPoint: Vec3Components
|
|
236
|
+
degree: number
|
|
237
|
+
controlPoints: Vec3Components[]
|
|
238
|
+
/** Expanded by multiplicity: `controlPoints.length + degree + 1` entries. */
|
|
239
|
+
knots: number[]
|
|
240
|
+
length: number
|
|
241
|
+
}
|
|
222
242
|
>
|
|
223
243
|
|
|
224
244
|
/**
|
|
@@ -263,7 +283,10 @@ export abstract class PluginGeomQueryBrepApi {
|
|
|
263
283
|
public abstract listVertexPositions(brep: BrepHandle): PluginApiReturn<Vec3Components[]>
|
|
264
284
|
|
|
265
285
|
/**
|
|
266
|
-
* Get the centroid
|
|
286
|
+
* Get the centroid of a brep: the mean of its vertex positions for planar
|
|
287
|
+
* and cylinder-sided solids; for a solid with sphere, cone, torus or spline
|
|
288
|
+
* geometry, its exact centre of mass (integrated over the surfaces; the
|
|
289
|
+
* vertex mean again if the kernel cannot integrate it, e.g. an open brep).
|
|
267
290
|
* @param brep The brep to query
|
|
268
291
|
* @returns The centroid as {@linkcode Vec3Components}
|
|
269
292
|
*
|
|
@@ -366,6 +389,37 @@ export abstract class PluginGeomQueryBrepApi {
|
|
|
366
389
|
*/
|
|
367
390
|
public abstract getBoundingBox(brep: BrepHandle): PluginApiReturn<BBoxComponents>
|
|
368
391
|
|
|
392
|
+
/**
|
|
393
|
+
* Get the enclosed **volume** of a closed solid, integrated from its exact
|
|
394
|
+
* surfaces. Curved faces are measured analytically, not from their
|
|
395
|
+
* tessellation — a real sphere of radius 5 reports 523.6, whatever its
|
|
396
|
+
* triangle count. That makes this the reliable way to confirm a solid is the
|
|
397
|
+
* shape you intended (a torus should measure 2·π²·R·r²).
|
|
398
|
+
*
|
|
399
|
+
* Runs on the OpenCascade kernel (the first kernel call loads a wasm of tens
|
|
400
|
+
* of MB — expect a pause of seconds).
|
|
401
|
+
*
|
|
402
|
+
* @param brep The solid to measure
|
|
403
|
+
* @returns The enclosed volume in cubic internal length units
|
|
404
|
+
* @throws OPERATION_FAILED if the kernel cannot compute the volume (the brep
|
|
405
|
+
* is not a closed solid)
|
|
406
|
+
*
|
|
407
|
+
* @examplePrompt What is the volume of this mass?
|
|
408
|
+
* @examplePrompt How much concrete is in this shape?
|
|
409
|
+
* @examplePrompt Check the volume of the dome I just made
|
|
410
|
+
*
|
|
411
|
+
* # Example
|
|
412
|
+
* ```ts
|
|
413
|
+
* const [mass] = await snaptrude.design.query.listMasses()
|
|
414
|
+
* const brep = await snaptrude.design.query.geometry.getBrep(mass)
|
|
415
|
+
* if (brep) {
|
|
416
|
+
* const volume = await snaptrude.core.geom.query.brep.getVolume(brep)
|
|
417
|
+
* console.log("volume:", volume)
|
|
418
|
+
* }
|
|
419
|
+
* ```
|
|
420
|
+
*/
|
|
421
|
+
public abstract getVolume(brep: BrepHandle): PluginApiReturn<number>
|
|
422
|
+
|
|
369
423
|
/**
|
|
370
424
|
* Test whether two breps are geometrically equal.
|
|
371
425
|
* @param brepA First brep
|
|
@@ -388,7 +442,7 @@ export abstract class PluginGeomQueryBrepApi {
|
|
|
388
442
|
public abstract isEqual(brepA: BrepHandle, brepB: BrepHandle): PluginApiReturn<boolean>
|
|
389
443
|
|
|
390
444
|
/**
|
|
391
|
-
* Measures the minimum distance between two solids, with the closest
|
|
445
|
+
* Measures the minimum distance between two solids, with the closest
|
|
392
446
|
* point on each. Touching or overlapping solids report a distance of 0 with
|
|
393
447
|
* contact points.
|
|
394
448
|
*
|
|
@@ -534,6 +588,10 @@ export type PluginGeomQueryBrepGetBoundingBoxArgs = z.infer<
|
|
|
534
588
|
typeof PluginGeomQueryBrepGetBoundingBoxArgs
|
|
535
589
|
>
|
|
536
590
|
|
|
591
|
+
/** Arguments for {@linkcode PluginGeomQueryBrepApi.getVolume}. `{ brep: BrepHandle }` */
|
|
592
|
+
export const PluginGeomQueryBrepGetVolumeArgs = brepArg
|
|
593
|
+
export type PluginGeomQueryBrepGetVolumeArgs = z.infer<typeof PluginGeomQueryBrepGetVolumeArgs>
|
|
594
|
+
|
|
537
595
|
/**
|
|
538
596
|
* Arguments for {@linkcode PluginGeomQueryBrepApi.isEqual}.
|
|
539
597
|
*
|
|
@@ -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
|
|
7
|
-
* and the relationships between two curves
|
|
6
|
+
* Curve queries — read-only geometric questions about curves (lines, arcs and
|
|
7
|
+
* splines) and the relationships between two curves.
|
|
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,30 @@ 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` / `splineFromControlPoints`, and returned by
|
|
20
|
+
* `edge.getCurve`, `profile.listCurves` and `update.curve.reverse` for a spline run). Every method here accepts a spline at
|
|
21
|
+
* compile time, but only the reads backed by the engine's spline math answer
|
|
22
|
+
* for one today. The rest throw `PRECONDITION_FAILED` ("not supported for
|
|
23
|
+
* splines yet") — a typed refusal, never a quietly wrong answer.
|
|
24
|
+
*
|
|
25
|
+
* | Splines | Members |
|
|
26
|
+
* |---|---|
|
|
27
|
+
* | **supported** | {@linkcode PluginGeomQueryCurveApi.getStartPoint}, {@linkcode PluginGeomQueryCurveApi.getEndPoint}, {@linkcode PluginGeomQueryCurveApi.getLength}, {@linkcode PluginGeomQueryCurveApi.getTangent}, {@linkcode PluginGeomQueryCurveApi.listPoints}, {@linkcode PluginGeomQueryCurveApi.getNearestPoint} |
|
|
28
|
+
* | **not yet** | `getMidPoint`, `getChordLength`, `getNormal`, `getProjection`, `getPointAtDistance`, `getParameterAtPoint`, `getCurvature`, `getDistanceToPoint`, `getDistanceAlong`, `listSubdivisions`, `isLinear`, `isOnCurve`, `hasPoint`, `isEqual`, `isOverlapping`, `getCommonPart`, `listIntersections`, `getMergedCurve`, `isContinuous`, `isParallel`, `getShortestGap`, `getDistanceBetween` |
|
|
29
|
+
*
|
|
30
|
+
* {@linkcode PluginGeomQueryCurveApi.isOverlapping} is deliberately in the
|
|
31
|
+
* second row: its line/arc path falls back to structural equality, which would
|
|
32
|
+
* answer a spline pair wrongly rather than not at all.
|
|
33
|
+
*
|
|
34
|
+
* To work around the second row, sample the curve —
|
|
35
|
+
* {@linkcode PluginGeomQueryCurveApi.listPoints} then the ordinary
|
|
36
|
+
* `core.math.vec3` operations — or read a spline brep edge exactly with
|
|
37
|
+
* `core.geom.query.brep.getEdgeCurve`, which returns its degree, control points
|
|
38
|
+
* and knots.
|
|
39
|
+
*
|
|
16
40
|
* Accessed via `snaptrude.core.geom.query.curve`.
|
|
17
41
|
*/
|
|
18
42
|
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
|
|
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 =
|
|
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<
|
|
@@ -29,6 +29,8 @@ export abstract class PluginGeomUpdateContourApi {
|
|
|
29
29
|
* @param contour The contour to offset
|
|
30
30
|
* @param distance Signed offset distance (outward when positive, inward when negative)
|
|
31
31
|
* @returns The offset contour as a NEW {@linkcode ContourHandle}
|
|
32
|
+
* @throws PRECONDITION_FAILED if the outline or a hole has a spline run
|
|
33
|
+
* (splines cannot be offset yet)
|
|
32
34
|
*
|
|
33
35
|
* @examplePrompt Offset this boundary 500mm inward
|
|
34
36
|
* @examplePrompt Shrink this floor outline by half a metre all around
|
|
@@ -28,6 +28,8 @@ export abstract class PluginGeomUpdateProfileApi {
|
|
|
28
28
|
* @param profile The closed profile to offset
|
|
29
29
|
* @param distance Signed offset distance (outward when positive, inward when negative)
|
|
30
30
|
* @returns The offset profile as a NEW {@linkcode ProfileHandle}
|
|
31
|
+
* @throws PRECONDITION_FAILED if the profile has a spline run (splines cannot
|
|
32
|
+
* be offset yet)
|
|
31
33
|
*
|
|
32
34
|
* @examplePrompt Offset this outline 300mm inward
|
|
33
35
|
* @examplePrompt Inset this boundary by a foot all around
|
|
@@ -6,7 +6,7 @@ import type { AnyArenaHandle } from "../../../handles"
|
|
|
6
6
|
import { Handle } from "../../../handles"
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* The
|
|
9
|
+
* The 13 registry-arena handle kinds — the releasable families. Entity-style
|
|
10
10
|
* handles (component / material / underlay / terrain / importJob / comment) are
|
|
11
11
|
* raw engine ids with no arena entry and therefore no lifecycle: passing one to
|
|
12
12
|
* `release` is a silent no-op like any other unknown id.
|
|
@@ -16,6 +16,7 @@ export const ArenaKind = z.enum([
|
|
|
16
16
|
"quat",
|
|
17
17
|
"line",
|
|
18
18
|
"arc",
|
|
19
|
+
"spline",
|
|
19
20
|
"circle",
|
|
20
21
|
"profile",
|
|
21
22
|
"contour",
|
|
@@ -216,7 +217,7 @@ export type PluginHandlesEndScopeArgs = z.infer<typeof PluginHandlesEndScopeArgs
|
|
|
216
217
|
* | Property | Type | Description |
|
|
217
218
|
* |---|---|---|
|
|
218
219
|
* | `resources` | `number` | Live resource-arena entries (profile/contour) |
|
|
219
|
-
* | `values` | `number` | Live value-arena entries (vec3/quat/line/arc/circle) |
|
|
220
|
+
* | `values` | `number` | Live value-arena entries (vec3/quat/line/arc/spline/circle) |
|
|
220
221
|
* | `topology` | `number` | Live topology-arena entries (brep/face/edge/halfedge/vertex) |
|
|
221
222
|
* | `scopes` | `number` | Currently open handle scopes |
|
|
222
223
|
* | `hostHeapUsedBytes` | `number \| null` | Host page `usedJSHeapSize` (null where unsupported) |
|
package/src/api/design/family.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as z from "zod"
|
|
2
2
|
import { PluginApiReturn } from "../../types"
|
|
3
|
-
import { ComponentHandle, Vec3Components } from "../../handles"
|
|
3
|
+
import { BrepHandle, ComponentHandle, Vec3Components } from "../../handles"
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* `snaptrude.design.family.*` — author NATIVE parametric families from a JSON spec.
|
|
@@ -18,15 +18,21 @@ import { ComponentHandle, Vec3Components } from "../../handles"
|
|
|
18
18
|
* getReference() read the spec DSL once — grammar, ops, expressions, example
|
|
19
19
|
* prepare({ bundle }) validate + compile + show a live ghost; nothing committed
|
|
20
20
|
* flex({ values }) re-run at new values; returns the geometry delta
|
|
21
|
-
* place()
|
|
22
|
-
*
|
|
21
|
+
* place({ position }) put it in the model — saves the family as the first instance drops
|
|
22
|
+
* place() save the family, then arm placement — the USER clicks to drop it
|
|
23
|
+
* create({ teamId }) share with a team; a save with nothing placed also drops one instance
|
|
23
24
|
* ```
|
|
24
25
|
*
|
|
26
|
+
* `place` saves the prepared family to the user's personal library, so it
|
|
27
|
+
* survives reload with no extra step; finish on `place`, not on `create`.
|
|
28
|
+
*
|
|
25
29
|
* ## Read getReference() first
|
|
26
30
|
*
|
|
27
31
|
* The spec DSL is a closed expression language with its own op set, coordinate
|
|
28
|
-
* convention (**+Y up, Snaptrude units** — the scene's own unit, 1 SU = 254 mm
|
|
29
|
-
*
|
|
32
|
+
* convention (**+Y up, Snaptrude units** — the scene's own unit, 1 SU = 254 mm,
|
|
33
|
+
* the same unit `core.units.getBabylonType()` names and every geometry API
|
|
34
|
+
* takes; literals inside spec expressions may carry a unit suffix such as
|
|
35
|
+
* `600mm` or `2ft`)
|
|
30
36
|
* and part-naming law. It is deliberately NOT duplicated in these types:
|
|
31
37
|
* {@linkcode PluginDesignFamilyApi.getReference} returns the whole reference,
|
|
32
38
|
* generated from a family that is actually registered in the host, so the
|
|
@@ -41,6 +47,18 @@ import { ComponentHandle, Vec3Components } from "../../handles"
|
|
|
41
47
|
* leaves the previous good draft standing, so it costs nothing but the node you
|
|
42
48
|
* broke. Re-authoring from scratch throws away everything already correct.
|
|
43
49
|
*
|
|
50
|
+
* ## Curved parts are exact
|
|
51
|
+
*
|
|
52
|
+
* A part whose sketch has a curved edge — any `revolve`, or an `extrude` /
|
|
53
|
+
* `sweep` / `loft` with an arc or circle in its profile (or an arc in a sweep
|
|
54
|
+
* path) — is built by the exact geometry kernel, the same one behind curved
|
|
55
|
+
* masses. Straight-edged parts keep the fast mesh builder. `getParameters` on a
|
|
56
|
+
* placed component reports which built each part in `parts[].engine`, and a
|
|
57
|
+
* kernel part carries a `brep`: read it with `core.geom.query.brep.*` and
|
|
58
|
+
* `core.geom.query.face.getSurfaceKind` — the same face-kind check as for a
|
|
59
|
+
* curved mass. If the kernel is unavailable a part falls back to the mesh
|
|
60
|
+
* builder (`engine: "mesh"`) rather than failing the family.
|
|
61
|
+
*
|
|
44
62
|
* Accessed via `snaptrude.design.family`.
|
|
45
63
|
*/
|
|
46
64
|
export abstract class PluginDesignFamilyApi {
|
|
@@ -68,20 +86,25 @@ export abstract class PluginDesignFamilyApi {
|
|
|
68
86
|
|
|
69
87
|
/**
|
|
70
88
|
* Validate, compile and preview a family spec. Nothing is committed to the
|
|
71
|
-
* model or the library — call {@linkcode PluginDesignFamilyApi.place}
|
|
72
|
-
*
|
|
89
|
+
* model or the library — call {@linkcode PluginDesignFamilyApi.place} to put
|
|
90
|
+
* it in the model, which also saves it.
|
|
73
91
|
*
|
|
74
92
|
* Safe to call repeatedly while iterating. On success, check `partCount` and
|
|
75
93
|
* `bbox` against what you intended before treating the family as correct — a
|
|
76
94
|
* facade that built 3 parts, or a 3 m screen reporting 40 m of height, is a
|
|
77
95
|
* visible bug the validator cannot catch.
|
|
78
96
|
*
|
|
97
|
+
* Lengths — the spec's bare numbers, `bbox`, the sheet's `length` values — are
|
|
98
|
+
* Snaptrude units: the same 254 mm unit as the kernel's internal (`"babylon"`)
|
|
99
|
+
* unit. A unit suffix (`600mm`) is legal only inside a spec expression.
|
|
100
|
+
*
|
|
79
101
|
* @param args The spec bundle, as `{ bundle }` or `{ spec }`
|
|
80
102
|
* @returns Build report, or `{ ok: false, errors }` with JSON-pointer paths
|
|
81
103
|
*
|
|
82
104
|
* @examplePrompt Make a louvre screen with adjustable blade count and tilt
|
|
83
105
|
* @examplePrompt Design a curtain wall panel family with 8 bays
|
|
84
106
|
* @examplePrompt Create a railing family I can adjust
|
|
107
|
+
* @examplePrompt Make a pendant lamp family with a domed shade I can resize
|
|
85
108
|
*
|
|
86
109
|
* # Example
|
|
87
110
|
* ```ts
|
|
@@ -147,6 +170,9 @@ export abstract class PluginDesignFamilyApi {
|
|
|
147
170
|
* Put a family into the model — either the prepared draft or any family from
|
|
148
171
|
* {@linkcode PluginDesignFamilyApi.list}.
|
|
149
172
|
*
|
|
173
|
+
* Placing the prepared draft saves it to the user's personal library first,
|
|
174
|
+
* so its instances survive reload.
|
|
175
|
+
*
|
|
150
176
|
* Two modes, chosen by whether you pass `position`:
|
|
151
177
|
*
|
|
152
178
|
* **With `position`** the component is created there and then, undoably. Use
|
|
@@ -195,6 +221,9 @@ export abstract class PluginDesignFamilyApi {
|
|
|
195
221
|
* label the user says, and a Revit-imported family carries parameters that
|
|
196
222
|
* do not drive geometry at all.
|
|
197
223
|
*
|
|
224
|
+
* `length` values are Snaptrude units: the same 254 mm unit as the kernel's
|
|
225
|
+
* internal (`"babylon"`) unit — convert with `core.units.convert` to report.
|
|
226
|
+
*
|
|
198
227
|
* @param args The component to read
|
|
199
228
|
* @returns Its definition, current values, and the parameter sheet
|
|
200
229
|
*
|
|
@@ -220,6 +249,11 @@ export abstract class PluginDesignFamilyApi {
|
|
|
220
249
|
* that does not is accepted and stored (it round-trips to Revit) but nothing
|
|
221
250
|
* visible happens — say so rather than claiming a change the user cannot see.
|
|
222
251
|
*
|
|
252
|
+
* `length` values are Snaptrude units: the same 254 mm unit as the kernel's
|
|
253
|
+
* internal (`"babylon"`) unit — convert the user's number with
|
|
254
|
+
* `core.units.convert` first; a bare `400` is 400 SU, not 400 mm. Kernel part
|
|
255
|
+
* breps read before the edit are stale: re-read `getParameters`.
|
|
256
|
+
*
|
|
223
257
|
* @param args The component and the values to change
|
|
224
258
|
* @returns The values now in effect
|
|
225
259
|
*
|
|
@@ -236,8 +270,11 @@ export abstract class PluginDesignFamilyApi {
|
|
|
236
270
|
): PluginApiReturn<PluginFamilyInstanceParameters>
|
|
237
271
|
|
|
238
272
|
/**
|
|
239
|
-
*
|
|
240
|
-
*
|
|
273
|
+
* Save the prepared bundle to the library — the user's personal library
|
|
274
|
+
* unless `teamId` is given. {@linkcode PluginDesignFamilyApi.place} already
|
|
275
|
+
* saves, so `create` is for sharing with a team. When nothing of the family is
|
|
276
|
+
* in the model yet, one instance is also dropped at the centre of the current
|
|
277
|
+
* view on the active storey (`placed: true`), so a save is never invisible.
|
|
241
278
|
*
|
|
242
279
|
* @param args Optional library name and team scope
|
|
243
280
|
* @returns The catalogued definition's id and version
|
|
@@ -253,6 +290,32 @@ export abstract class PluginDesignFamilyApi {
|
|
|
253
290
|
public abstract create(
|
|
254
291
|
args?: PluginDesignFamilyCreateArgs,
|
|
255
292
|
): PluginApiReturn<PluginFamilyCreateResult>
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Remove a family from the library: its catalog row is archived, so it
|
|
296
|
+
* leaves the Families panel. Placed instances are untouched — in this
|
|
297
|
+
* project and every other — because archived pins keep resolving. Pass
|
|
298
|
+
* `instances: true` to ALSO delete this project's instances in one undoable
|
|
299
|
+
* command; do that only when the user asks for the instances to go.
|
|
300
|
+
*
|
|
301
|
+
* Omit `id` to target the prepared draft. `id` may be a draft id, a saved
|
|
302
|
+
* catalog id, or any family from `list()`.
|
|
303
|
+
*
|
|
304
|
+
* @param args Optional family id, and whether to delete instances too
|
|
305
|
+
* @returns Whether a library row was archived and how many instances were removed
|
|
306
|
+
*
|
|
307
|
+
* @examplePrompt Delete the Louvre Screen family from my library
|
|
308
|
+
* @examplePrompt Get rid of that bollard and every copy of it in here
|
|
309
|
+
*
|
|
310
|
+
* # Example
|
|
311
|
+
* ```ts
|
|
312
|
+
* await snaptrude.design.family.delete({ id: "revit:steel-bollard~bef047" })
|
|
313
|
+
* await snaptrude.design.family.delete({ id: "revit:steel-bollard~bef047", instances: true })
|
|
314
|
+
* ```
|
|
315
|
+
*/
|
|
316
|
+
public abstract delete(
|
|
317
|
+
args?: PluginDesignFamilyDeleteArgs,
|
|
318
|
+
): PluginApiReturn<PluginFamilyDeleteResult>
|
|
256
319
|
}
|
|
257
320
|
|
|
258
321
|
// ---------------------------------------------------------------------------
|
|
@@ -292,7 +355,7 @@ export interface PluginFamilyParameter {
|
|
|
292
355
|
key: string
|
|
293
356
|
label: string
|
|
294
357
|
type: "length" | "integer" | "enum" | "text" | "boolean"
|
|
295
|
-
/** Current value. `length
|
|
358
|
+
/** Current value. `length` (Snaptrude units) and `integer` are numbers; the rest are strings. */
|
|
296
359
|
value: string | number
|
|
297
360
|
default: string | number
|
|
298
361
|
/**
|
|
@@ -328,6 +391,25 @@ export interface PluginFamilyDiagnostic {
|
|
|
328
391
|
hint?: string
|
|
329
392
|
}
|
|
330
393
|
|
|
394
|
+
/**
|
|
395
|
+
* One placed part and which engine built it, from `getParameters`. `"kernel"` —
|
|
396
|
+
* a curved sketch built exactly; `"mesh"` — straight-edged, or the kernel
|
|
397
|
+
* fallback.
|
|
398
|
+
*/
|
|
399
|
+
export interface PluginFamilyPart {
|
|
400
|
+
name: string
|
|
401
|
+
engine: "kernel" | "mesh"
|
|
402
|
+
/**
|
|
403
|
+
* Kernel parts only: the part's exact solid, for `core.geom.query.brep.*` /
|
|
404
|
+
* `core.geom.query.face.getSurfaceKind`. READ-ONLY and PART-LOCAL — in the
|
|
405
|
+
* part's own frame, not where the component sits, so never pass it to a
|
|
406
|
+
* boolean or `design.create.massFromBrep` (a family changes only through
|
|
407
|
+
* `setParameters`). Valid until the next parameter change: re-read
|
|
408
|
+
* `getParameters` after `setParameters`.
|
|
409
|
+
*/
|
|
410
|
+
brep?: BrepHandle
|
|
411
|
+
}
|
|
412
|
+
|
|
331
413
|
/** What `prepare` reports. */
|
|
332
414
|
export interface PluginFamilyPrepareResult {
|
|
333
415
|
/** `false` means the spec was rejected — read `errors`, fix, re-prepare. */
|
|
@@ -429,6 +511,8 @@ export interface PluginFamilyInstanceParameters {
|
|
|
429
511
|
values: Record<string, number | string>
|
|
430
512
|
/** The sheet: what each key means, its bounds, and whether it moves geometry. */
|
|
431
513
|
parameters: PluginFamilyParameter[]
|
|
514
|
+
/** The placed parts; kernel parts carry their exact `brep`. */
|
|
515
|
+
parts?: PluginFamilyPart[]
|
|
432
516
|
/** Present when `getParameters` was asked for a `snapshot`. */
|
|
433
517
|
snapshot?: PluginFamilySnapshot
|
|
434
518
|
}
|
|
@@ -439,6 +523,21 @@ export interface PluginFamilyCreateResult {
|
|
|
439
523
|
definitionId?: string
|
|
440
524
|
version?: number
|
|
441
525
|
guid?: string
|
|
526
|
+
/** True when the save also dropped one instance into the model (nothing was placed yet). */
|
|
527
|
+
placed?: boolean
|
|
528
|
+
/** Host guidance for the caller, e.g. that an instance was placed at the view centre. */
|
|
529
|
+
hint?: string
|
|
530
|
+
error?: string
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/** What `delete` reports. */
|
|
534
|
+
export interface PluginFamilyDeleteResult {
|
|
535
|
+
ok: boolean
|
|
536
|
+
familyId?: string
|
|
537
|
+
/** Instances deleted from the scene (only with `instances: true`), in one undoable command. */
|
|
538
|
+
removedInstances?: number
|
|
539
|
+
/** True when a library row was archived; false for an unsaved draft. */
|
|
540
|
+
archived?: boolean
|
|
442
541
|
error?: string
|
|
443
542
|
}
|
|
444
543
|
|
|
@@ -536,6 +635,20 @@ export const PluginDesignFamilyCreateArgs = z.object({
|
|
|
536
635
|
})
|
|
537
636
|
export type PluginDesignFamilyCreateArgs = z.infer<typeof PluginDesignFamilyCreateArgs>
|
|
538
637
|
|
|
638
|
+
/**
|
|
639
|
+
* Arguments for {@linkcode PluginDesignFamilyApi.delete}.
|
|
640
|
+
*
|
|
641
|
+
* | Property | Type | Description |
|
|
642
|
+
* |---|---|---|
|
|
643
|
+
* | `id` | `string` | Family to remove; omit for the prepared draft |
|
|
644
|
+
* | `instances` | `boolean` | Also delete this project's placed instances; default false |
|
|
645
|
+
*/
|
|
646
|
+
export const PluginDesignFamilyDeleteArgs = z.object({
|
|
647
|
+
id: z.string().optional(),
|
|
648
|
+
instances: z.boolean().optional(),
|
|
649
|
+
})
|
|
650
|
+
export type PluginDesignFamilyDeleteArgs = z.infer<typeof PluginDesignFamilyDeleteArgs>
|
|
651
|
+
|
|
539
652
|
/**
|
|
540
653
|
* Arguments for {@linkcode PluginDesignFamilyApi.place}.
|
|
541
654
|
*
|