@snaptrude/plugin-core 0.9.10 → 0.9.12
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 +27 -0
- package/api-manifest.json +108 -409
- package/dist/api/design/create/grids.d.ts +132 -0
- package/dist/api/design/create/grids.d.ts.map +1 -0
- package/dist/api/design/create/index.d.ts +109 -1
- package/dist/api/design/create/index.d.ts.map +1 -1
- package/dist/api/design/family.d.ts +561 -0
- package/dist/api/design/family.d.ts.map +1 -0
- package/dist/api/design/grids.d.ts +237 -0
- package/dist/api/design/grids.d.ts.map +1 -0
- package/dist/api/design/index.d.ts +9 -0
- package/dist/api/design/index.d.ts.map +1 -1
- package/dist/api/design/query/grids.d.ts +287 -0
- package/dist/api/design/query/grids.d.ts.map +1 -0
- package/dist/api/design/query/index.d.ts +36 -0
- package/dist/api/design/query/index.d.ts.map +1 -1
- package/dist/api/design/update/index.d.ts +74 -0
- package/dist/api/design/update/index.d.ts.map +1 -1
- package/dist/index.cjs +2230 -1967
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2199 -1970
- package/dist/index.js.map +1 -1
- package/package.json +13 -13
- package/src/api/design/create/grids.ts +137 -0
- package/src/api/design/create/index.ts +131 -0
- package/src/api/design/family.ts +591 -0
- package/src/api/design/grids.ts +237 -0
- package/src/api/design/index.ts +10 -0
- package/src/api/design/query/grids.ts +197 -0
- package/src/api/design/query/index.ts +29 -0
- package/src/api/design/update/index.ts +53 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@snaptrude/plugin-core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -16,17 +16,6 @@
|
|
|
16
16
|
"publishConfig": {
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
|
-
"scripts": {
|
|
20
|
-
"check-types": "tsc --noEmit",
|
|
21
|
-
"build": "tsup --clean",
|
|
22
|
-
"dev": "tsup --watch",
|
|
23
|
-
"clean-dist": "rm -rf dist",
|
|
24
|
-
"test": "node --test test/*.test.mjs",
|
|
25
|
-
"generate:manifest": "node scripts/generate-manifest.mjs",
|
|
26
|
-
"generate:manifest:check": "node scripts/generate-manifest.mjs --check",
|
|
27
|
-
"generate:manifest:all": "node scripts/generate-manifest.mjs --all",
|
|
28
|
-
"generate:manifest:all:check": "node scripts/generate-manifest.mjs --all --check"
|
|
29
|
-
},
|
|
30
19
|
"devDependencies": {
|
|
31
20
|
"ts-morph": "^28.0.0",
|
|
32
21
|
"tsup": "^8.5.1",
|
|
@@ -37,5 +26,16 @@
|
|
|
37
26
|
},
|
|
38
27
|
"peerDependencies": {
|
|
39
28
|
"zod": "^3.25.0 || ^4.0.0"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"check-types": "tsc --noEmit",
|
|
32
|
+
"build": "tsup --clean",
|
|
33
|
+
"dev": "tsup --watch",
|
|
34
|
+
"clean-dist": "rm -rf dist",
|
|
35
|
+
"test": "node --test test/*.test.mjs",
|
|
36
|
+
"generate:manifest": "node scripts/generate-manifest.mjs",
|
|
37
|
+
"generate:manifest:check": "node scripts/generate-manifest.mjs --check",
|
|
38
|
+
"generate:manifest:all": "node scripts/generate-manifest.mjs --all",
|
|
39
|
+
"generate:manifest:all:check": "node scripts/generate-manifest.mjs --all --check"
|
|
40
40
|
}
|
|
41
|
-
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { ComponentHandle, CurveHandle, Vec3Handle } from "../../../handles"
|
|
3
|
+
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
// Shared grid style vocabulary
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Grid line style (mirrors the engine `LineMode` values verbatim — the same
|
|
10
|
+
* vocabulary as {@linkcode PluginReferenceLineStyle}).
|
|
11
|
+
*/
|
|
12
|
+
export const PluginGridLineStyle = z.enum(["SOLID", "DASHED", "DOT_DASH"])
|
|
13
|
+
export type PluginGridLineStyle = z.infer<typeof PluginGridLineStyle>
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Optional visual styling shared by every grid creator (and reused as the
|
|
17
|
+
* patch shape by `design.update.grid`). All fields optional; engine defaults
|
|
18
|
+
* apply when omitted.
|
|
19
|
+
*
|
|
20
|
+
* | Property | Type | Description |
|
|
21
|
+
* |---|---|---|
|
|
22
|
+
* | `style` | {@linkcode PluginGridLineStyle}? | Line style |
|
|
23
|
+
* | `weight` | `number`? | Line weight (> 0) |
|
|
24
|
+
* | `color` | `string`? | Line color as a `#rrggbb` hex string |
|
|
25
|
+
* | `showStart` | `boolean`? | Show the start-end tag bubble |
|
|
26
|
+
* | `showEnd` | `boolean`? | Show the end-end tag bubble |
|
|
27
|
+
*/
|
|
28
|
+
export const PluginGridStyleOptions = z.object({
|
|
29
|
+
style: PluginGridLineStyle.optional(),
|
|
30
|
+
weight: z.number().positive().optional(),
|
|
31
|
+
color: z
|
|
32
|
+
.string()
|
|
33
|
+
.regex(/^#[0-9a-fA-F]{6}$/, "color must be a #rrggbb hex string")
|
|
34
|
+
.optional(),
|
|
35
|
+
showStart: z.boolean().optional(),
|
|
36
|
+
showEnd: z.boolean().optional(),
|
|
37
|
+
})
|
|
38
|
+
export type PluginGridStyleOptions = z.infer<typeof PluginGridStyleOptions>
|
|
39
|
+
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
// create.grid — free rectangular grid
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Arguments for {@linkcode PluginDesignCreateApi.grid}.
|
|
46
|
+
*
|
|
47
|
+
* | Property | Type | Description |
|
|
48
|
+
* |---|---|---|
|
|
49
|
+
* | `linesX` | `number` | Line count of the first family (integer ≥ 1) |
|
|
50
|
+
* | `linesY` | `number` | Line count of the second family (integer ≥ 1) |
|
|
51
|
+
* | `spacingX` | `number` | Spacing of the first family (Snaptrude units, > 0) |
|
|
52
|
+
* | `spacingY` | `number` | Spacing of the second family (Snaptrude units, > 0) |
|
|
53
|
+
* | `angle` | `number`? | Rotation in degrees, CCW about +Y (default 0) |
|
|
54
|
+
* | `center` | {@linkcode Vec3Handle}? | Placement centre; defaults to the native viewport-centre behavior |
|
|
55
|
+
* | …style | {@linkcode PluginGridStyleOptions} | Optional line styling |
|
|
56
|
+
*/
|
|
57
|
+
export const PluginDesignCreateGridArgs = z
|
|
58
|
+
.object({
|
|
59
|
+
linesX: z.number().int().min(1),
|
|
60
|
+
linesY: z.number().int().min(1),
|
|
61
|
+
spacingX: z.number().positive().finite(),
|
|
62
|
+
spacingY: z.number().positive().finite(),
|
|
63
|
+
angle: z.number().finite().optional(),
|
|
64
|
+
center: Vec3Handle.optional(),
|
|
65
|
+
})
|
|
66
|
+
.merge(PluginGridStyleOptions)
|
|
67
|
+
export type PluginDesignCreateGridArgs = z.infer<typeof PluginDesignCreateGridArgs>
|
|
68
|
+
|
|
69
|
+
// ---------------------------------------------------------------------------
|
|
70
|
+
// create.gridFromCurve — single-curve grid
|
|
71
|
+
// ---------------------------------------------------------------------------
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Arguments for {@linkcode PluginDesignCreateApi.gridFromCurve}.
|
|
75
|
+
*
|
|
76
|
+
* | Property | Type | Description |
|
|
77
|
+
* |---|---|---|
|
|
78
|
+
* | `curve` | {@linkcode CurveHandle} | The grid line's geometry — a line or arc (circles are rejected) |
|
|
79
|
+
* | `tag` | `string`? | The line's grid tag (defaults to the draw tool's next tag) |
|
|
80
|
+
* | …style | {@linkcode PluginGridStyleOptions} | Optional line styling |
|
|
81
|
+
*/
|
|
82
|
+
export const PluginDesignCreateGridFromCurveArgs = z
|
|
83
|
+
.object({
|
|
84
|
+
curve: CurveHandle,
|
|
85
|
+
tag: z.string().min(1).optional(),
|
|
86
|
+
})
|
|
87
|
+
.merge(PluginGridStyleOptions)
|
|
88
|
+
export type PluginDesignCreateGridFromCurveArgs = z.infer<
|
|
89
|
+
typeof PluginDesignCreateGridFromCurveArgs
|
|
90
|
+
>
|
|
91
|
+
|
|
92
|
+
// ---------------------------------------------------------------------------
|
|
93
|
+
// create.gridsFromMasses — fitted grids
|
|
94
|
+
// ---------------------------------------------------------------------------
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Arguments for {@linkcode PluginDesignCreateApi.gridsFromMasses}.
|
|
98
|
+
*
|
|
99
|
+
* | Property | Type | Description |
|
|
100
|
+
* |---|---|---|
|
|
101
|
+
* | `masses` | {@linkcode ComponentHandle}`[]` | Masses whose footprints seat the grids |
|
|
102
|
+
* | `spacingX` | `number` | First-family spacing (Snaptrude units, > 0) |
|
|
103
|
+
* | `spacingY` | `number` | Second-family spacing (Snaptrude units, > 0) |
|
|
104
|
+
* | …style | {@linkcode PluginGridStyleOptions} | Optional line styling |
|
|
105
|
+
*/
|
|
106
|
+
export const PluginDesignCreateGridsFromMassesArgs = z
|
|
107
|
+
.object({
|
|
108
|
+
masses: z.array(ComponentHandle).min(1),
|
|
109
|
+
spacingX: z.number().positive().finite(),
|
|
110
|
+
spacingY: z.number().positive().finite(),
|
|
111
|
+
})
|
|
112
|
+
.merge(PluginGridStyleOptions)
|
|
113
|
+
export type PluginDesignCreateGridsFromMassesArgs = z.infer<
|
|
114
|
+
typeof PluginDesignCreateGridsFromMassesArgs
|
|
115
|
+
>
|
|
116
|
+
|
|
117
|
+
// ---------------------------------------------------------------------------
|
|
118
|
+
// create.columnsFromGrids — columns at line intersections
|
|
119
|
+
// ---------------------------------------------------------------------------
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Arguments for {@linkcode PluginDesignCreateApi.columnsFromGrids}.
|
|
123
|
+
*
|
|
124
|
+
* | Property | Type | Description |
|
|
125
|
+
* |---|---|---|
|
|
126
|
+
* | `grids` | {@linkcode ComponentHandle}`[]` | Grid groups whose line intersections seat the columns |
|
|
127
|
+
* | `width` | `number` | Column width (Snaptrude units, > 0) |
|
|
128
|
+
* | `depth` | `number` | Column depth (Snaptrude units, > 0) |
|
|
129
|
+
*/
|
|
130
|
+
export const PluginDesignCreateColumnsFromGridsArgs = z.object({
|
|
131
|
+
grids: z.array(ComponentHandle).min(1),
|
|
132
|
+
width: z.number().positive().finite(),
|
|
133
|
+
depth: z.number().positive().finite(),
|
|
134
|
+
})
|
|
135
|
+
export type PluginDesignCreateColumnsFromGridsArgs = z.infer<
|
|
136
|
+
typeof PluginDesignCreateColumnsFromGridsArgs
|
|
137
|
+
>
|
|
@@ -4,9 +4,11 @@ import {
|
|
|
4
4
|
BrepHandle,
|
|
5
5
|
ComponentHandle,
|
|
6
6
|
ContourHandle,
|
|
7
|
+
CurveHandle,
|
|
7
8
|
ProfileHandle,
|
|
8
9
|
Vec3Handle,
|
|
9
10
|
} from "../../../handles"
|
|
11
|
+
import { PluginGridStyleOptions } from "./grids"
|
|
10
12
|
import {
|
|
11
13
|
PluginSpaceType,
|
|
12
14
|
PluginMassType,
|
|
@@ -628,6 +630,134 @@ export abstract class PluginDesignCreateApi {
|
|
|
628
630
|
gridTag?: string,
|
|
629
631
|
): PluginApiReturn<ComponentHandle[]>
|
|
630
632
|
|
|
633
|
+
/**
|
|
634
|
+
* Create a free rectangular **structural grid** — one grid group with two
|
|
635
|
+
* perpendicular line families (`linesX` lines spaced `spacingX` apart, and
|
|
636
|
+
* `linesY` lines spaced `spacingY` apart) on the active storey. One undoable
|
|
637
|
+
* creation.
|
|
638
|
+
*
|
|
639
|
+
* Units: spacings in Snaptrude units; `angle` in degrees (CCW about +Y,
|
|
640
|
+
* default 0). Without `center` the grid is centred on the current viewport
|
|
641
|
+
* (the native tool's behavior) — pass `center` for deterministic placement.
|
|
642
|
+
*
|
|
643
|
+
* @param linesX - Line count of the first family (integer ≥ 1)
|
|
644
|
+
* @param linesY - Line count of the second family (integer ≥ 1)
|
|
645
|
+
* @param spacingX - First-family spacing (Snaptrude units, > 0)
|
|
646
|
+
* @param spacingY - Second-family spacing (Snaptrude units, > 0)
|
|
647
|
+
* @param options - `angle`, `center`, and {@linkcode PluginGridStyleOptions}
|
|
648
|
+
* @returns the created grid group's {@linkcode ComponentHandle}
|
|
649
|
+
*
|
|
650
|
+
* @examplePrompt Create a 5 by 8 structural grid with 6 metre spacing
|
|
651
|
+
* @examplePrompt Add a column grid rotated 30 degrees
|
|
652
|
+
* @examplePrompt Set up a structural grid at the site origin
|
|
653
|
+
*
|
|
654
|
+
* # Example
|
|
655
|
+
* ```ts
|
|
656
|
+
* const centre = await snaptrude.core.math.vec3.new(0, 0, 0)
|
|
657
|
+
* const grid = await snaptrude.design.create.grid(5, 8, 6, 6, { center: centre })
|
|
658
|
+
* ```
|
|
659
|
+
*/
|
|
660
|
+
public abstract grid(
|
|
661
|
+
linesX: number,
|
|
662
|
+
linesY: number,
|
|
663
|
+
spacingX: number,
|
|
664
|
+
spacingY: number,
|
|
665
|
+
options?: {
|
|
666
|
+
angle?: number
|
|
667
|
+
center?: Vec3Handle
|
|
668
|
+
} & PluginGridStyleOptions,
|
|
669
|
+
): PluginApiReturn<ComponentHandle>
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Create a **structural grid from a single curve** — one grid group holding
|
|
673
|
+
* one wing with one line (the draw tool's output). The curve may be a line
|
|
674
|
+
* or an arc; circles are rejected with `VALIDATION`. Undoable.
|
|
675
|
+
*
|
|
676
|
+
* @param curve - The grid line's geometry ({@linkcode CurveHandle}, world space)
|
|
677
|
+
* @param options - `tag` (defaults to the draw tool's next tag) and
|
|
678
|
+
* {@linkcode PluginGridStyleOptions}
|
|
679
|
+
* @returns the created grid group's {@linkcode ComponentHandle}
|
|
680
|
+
*
|
|
681
|
+
* @examplePrompt Draw a grid line from A to B
|
|
682
|
+
* @examplePrompt Add a curved grid line through these points
|
|
683
|
+
* @examplePrompt Create grid line "C" along this wall
|
|
684
|
+
*
|
|
685
|
+
* # Example
|
|
686
|
+
* ```ts
|
|
687
|
+
* const { vec3 } = snaptrude.core.math
|
|
688
|
+
* const from = await vec3.new(0, 0, 0)
|
|
689
|
+
* const to = await vec3.new(30, 0, 0)
|
|
690
|
+
* const curve = await snaptrude.core.geom.create.line(from, to)
|
|
691
|
+
* const grid = await snaptrude.design.create.gridFromCurve(curve, { tag: "A" })
|
|
692
|
+
* ```
|
|
693
|
+
*/
|
|
694
|
+
public abstract gridFromCurve(
|
|
695
|
+
curve: CurveHandle,
|
|
696
|
+
options?: {
|
|
697
|
+
tag?: string
|
|
698
|
+
} & PluginGridStyleOptions,
|
|
699
|
+
): PluginApiReturn<ComponentHandle>
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* Generate **structural grids fitted to mass footprints** — one grid group
|
|
703
|
+
* per footprint cluster, with counts and orientation derived from each
|
|
704
|
+
* footprint's geometry and the given spacings. All created groups commit as
|
|
705
|
+
* ONE undoable unit.
|
|
706
|
+
*
|
|
707
|
+
* Lenient like the native tool: masses without an extractable footprint
|
|
708
|
+
* (no B-rep, degenerate top face) are skipped; throws `VALIDATION` only when
|
|
709
|
+
* NONE of the given masses yields a footprint.
|
|
710
|
+
*
|
|
711
|
+
* @param masses - Masses whose footprints seat the grids
|
|
712
|
+
* @param spacingX - First-family spacing (Snaptrude units, > 0)
|
|
713
|
+
* @param spacingY - Second-family spacing (Snaptrude units, > 0)
|
|
714
|
+
* @param options - {@linkcode PluginGridStyleOptions}
|
|
715
|
+
* @returns the created grid groups' {@linkcode ComponentHandle}`[]`
|
|
716
|
+
*
|
|
717
|
+
* @examplePrompt Generate grids for the selected masses
|
|
718
|
+
* @examplePrompt Auto-generate a 6m structural grid on this building
|
|
719
|
+
* @examplePrompt Fit column grids to every mass on this storey
|
|
720
|
+
*
|
|
721
|
+
* # Example
|
|
722
|
+
* ```ts
|
|
723
|
+
* const masses = await snaptrude.design.query.listMasses({ storeys: [1] })
|
|
724
|
+
* const grids = await snaptrude.design.create.gridsFromMasses(masses, 6, 6)
|
|
725
|
+
* ```
|
|
726
|
+
*/
|
|
727
|
+
public abstract gridsFromMasses(
|
|
728
|
+
masses: ComponentHandle[],
|
|
729
|
+
spacingX: number,
|
|
730
|
+
spacingY: number,
|
|
731
|
+
options?: PluginGridStyleOptions,
|
|
732
|
+
): PluginApiReturn<ComponentHandle[]>
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* Create **columns at every grid-line intersection** of the given grid
|
|
736
|
+
* groups, sized `width` × `depth` and oriented to the grid axes, on the
|
|
737
|
+
* grids' storey. All columns commit as ONE undoable unit.
|
|
738
|
+
*
|
|
739
|
+
* @param grids - Grid groups whose intersections seat the columns
|
|
740
|
+
* @param width - Column width (Snaptrude units, > 0)
|
|
741
|
+
* @param depth - Column depth (Snaptrude units, > 0)
|
|
742
|
+
* @returns the created columns' {@linkcode ComponentHandle}`[]`
|
|
743
|
+
* @throws `VALIDATION` when an id does not resolve to a grid group;
|
|
744
|
+
* `OPERATION_FAILED` when the grids have no line intersections
|
|
745
|
+
*
|
|
746
|
+
* @examplePrompt Generate columns on this grid
|
|
747
|
+
* @examplePrompt Place 450mm square columns at every grid intersection
|
|
748
|
+
*
|
|
749
|
+
* # Example
|
|
750
|
+
* ```ts
|
|
751
|
+
* const grids = await snaptrude.design.query.listGrids()
|
|
752
|
+
* const columns = await snaptrude.design.create.columnsFromGrids(grids, 0.45, 0.45)
|
|
753
|
+
* ```
|
|
754
|
+
*/
|
|
755
|
+
public abstract columnsFromGrids(
|
|
756
|
+
grids: ComponentHandle[],
|
|
757
|
+
width: number,
|
|
758
|
+
depth: number,
|
|
759
|
+
): PluginApiReturn<ComponentHandle[]>
|
|
760
|
+
|
|
631
761
|
/**
|
|
632
762
|
* Place a **furniture** item from the project library at a world position.
|
|
633
763
|
*
|
|
@@ -1821,3 +1951,4 @@ export type PluginCreateSpaceItem = z.infer<typeof PluginCreateSpaceItem>
|
|
|
1821
1951
|
|
|
1822
1952
|
export * from "./opening-fields"
|
|
1823
1953
|
export * from "./bulk-items"
|
|
1954
|
+
export * from "./grids"
|