@snaptrude/plugin-core 0.0.6 → 0.0.7
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/dist/api/entity/index.d.ts +5 -0
- package/dist/api/entity/index.d.ts.map +1 -1
- package/dist/api/entity/referenceLine.d.ts +259 -0
- package/dist/api/entity/referenceLine.d.ts.map +1 -0
- package/dist/api/entity/space.d.ts +252 -5
- package/dist/api/entity/space.d.ts.map +1 -1
- package/dist/api/units/index.d.ts +9 -0
- package/dist/api/units/index.d.ts.map +1 -1
- package/dist/index.cjs +226 -91
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +211 -90
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/api/entity/index.ts +5 -0
- package/src/api/entity/referenceLine.ts +215 -0
- package/src/api/entity/space.ts +231 -8
- package/src/api/units/index.ts +9 -0
- package/tsup.config.ts +0 -1
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { PluginApiReturn } from "../../types"
|
|
3
|
+
import { PProfile } from "../core/geom/profile"
|
|
4
|
+
import { PCurve } from "../core/geom/curve"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Reference line management — create, query, and delete reference lines.
|
|
8
|
+
*
|
|
9
|
+
* A **reference line** is a 2D guide line (or arc) in the Snaptrude scene,
|
|
10
|
+
* typically used for grid lines and alignment guides. Reference lines
|
|
11
|
+
* carry properties such as grid tags, labels, and line styles.
|
|
12
|
+
*
|
|
13
|
+
* All methods are **host API calls** that return Promises and support
|
|
14
|
+
* undo/redo via Snaptrude's command system.
|
|
15
|
+
*
|
|
16
|
+
* Accessed via `snaptrude.entity.referenceLine`.
|
|
17
|
+
*/
|
|
18
|
+
export abstract class PluginReferenceLineApi {
|
|
19
|
+
constructor() {}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Create multiple reference lines from a profile.
|
|
23
|
+
*
|
|
24
|
+
* Each {@linkcode PCurve} in the given {@linkcode PProfile} becomes
|
|
25
|
+
* a separate reference line. Uses `ReferenceLineConstructor.createFromProfile`
|
|
26
|
+
* internally.
|
|
27
|
+
*
|
|
28
|
+
* @param args - An object containing:
|
|
29
|
+
* - {@linkcode PluginReferenceLineCreateMultiArgs.profile args.profile} — A
|
|
30
|
+
* {@linkcode PProfile} whose curves define the reference lines to create
|
|
31
|
+
* @returns A {@linkcode PluginReferenceLineCreateMultiResult} with the
|
|
32
|
+
* `referenceLineIds` of the created reference lines
|
|
33
|
+
* @throws If reference line creation fails
|
|
34
|
+
*
|
|
35
|
+
* # Example
|
|
36
|
+
* ```ts
|
|
37
|
+
* const { vec3 } = snaptrude.core.math
|
|
38
|
+
*
|
|
39
|
+
* const l1 = snaptrude.core.geom.line.new(vec3.new(0, 0, 0), vec3.new(10, 0, 0))
|
|
40
|
+
* const l2 = snaptrude.core.geom.line.new(vec3.new(10, 0, 0), vec3.new(10, 0, 10))
|
|
41
|
+
* const profile = snaptrude.core.geom.profile.new([l1, l2])
|
|
42
|
+
*
|
|
43
|
+
* const { referenceLineIds } = await snaptrude.entity.referenceLine.createMulti({
|
|
44
|
+
* profile,
|
|
45
|
+
* })
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
public abstract createMulti(
|
|
49
|
+
args: PluginReferenceLineCreateMultiArgs
|
|
50
|
+
): PluginApiReturn<PluginReferenceLineCreateMultiResult>
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Get properties of a reference line by its ID.
|
|
54
|
+
*
|
|
55
|
+
* Only the properties listed in {@linkcode PluginReferenceLineGetArgs.properties
|
|
56
|
+
* args.properties} are returned — unlisted properties will be `undefined`
|
|
57
|
+
* in the result.
|
|
58
|
+
*
|
|
59
|
+
* @param args - An object containing:
|
|
60
|
+
* - {@linkcode PluginReferenceLineGetArgs.referenceLineId args.referenceLineId} —
|
|
61
|
+
* The unique reference line ID
|
|
62
|
+
* - {@linkcode PluginReferenceLineGetArgs.properties args.properties} — Array of
|
|
63
|
+
* property names to retrieve. See {@linkcode PluginReferenceLineGetProperty}.
|
|
64
|
+
* @returns A partial {@linkcode PluginReferenceLineGetResult} containing only the
|
|
65
|
+
* requested properties
|
|
66
|
+
* @throws If the reference line does not exist
|
|
67
|
+
*
|
|
68
|
+
* # Example
|
|
69
|
+
* ```ts
|
|
70
|
+
* const result = await snaptrude.entity.referenceLine.get({
|
|
71
|
+
* referenceLineId: "some-ref-line-id",
|
|
72
|
+
* properties: ["curve"],
|
|
73
|
+
* })
|
|
74
|
+
* console.log(result.curve) // PCurve
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
public abstract get(
|
|
78
|
+
args: PluginReferenceLineGetArgs
|
|
79
|
+
): PluginApiReturn<PluginReferenceLineGetResult>
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Get the IDs of all reference lines in the current project.
|
|
83
|
+
*
|
|
84
|
+
* Returns every reference line across all stories.
|
|
85
|
+
* Use the returned IDs with {@linkcode PluginReferenceLineApi.get} to query
|
|
86
|
+
* individual reference line properties.
|
|
87
|
+
*
|
|
88
|
+
* @returns A {@linkcode PluginReferenceLineGetAllResult} with a
|
|
89
|
+
* `referenceLineIds` array
|
|
90
|
+
*
|
|
91
|
+
* # Example
|
|
92
|
+
* ```ts
|
|
93
|
+
* const { referenceLineIds } = await snaptrude.entity.referenceLine.getAll()
|
|
94
|
+
* console.log(`Project has ${referenceLineIds.length} reference lines`)
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
public abstract getAll(): PluginApiReturn<PluginReferenceLineGetAllResult>
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Delete a reference line by its ID.
|
|
101
|
+
*
|
|
102
|
+
* Permanently removes the reference line and its associated mesh from
|
|
103
|
+
* the scene. This operation is undoable via Snaptrude's command system.
|
|
104
|
+
*
|
|
105
|
+
* @param args - An object containing:
|
|
106
|
+
* - {@linkcode PluginReferenceLineDeleteArgs.referenceLineId args.referenceLineId} —
|
|
107
|
+
* The unique reference line ID to delete
|
|
108
|
+
* @throws If the reference line does not exist
|
|
109
|
+
*
|
|
110
|
+
* # Example
|
|
111
|
+
* ```ts
|
|
112
|
+
* await snaptrude.entity.referenceLine.delete({
|
|
113
|
+
* referenceLineId: "some-ref-line-id",
|
|
114
|
+
* })
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
public abstract delete(
|
|
118
|
+
args: PluginReferenceLineDeleteArgs
|
|
119
|
+
): PluginApiReturn<PluginReferenceLineDeleteResult>
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Arguments for {@linkcode PluginReferenceLineApi.createMulti}.
|
|
124
|
+
*
|
|
125
|
+
* | Property | Type | Description |
|
|
126
|
+
* |---|---|---|
|
|
127
|
+
* | `profile` | {@linkcode PProfile} | Profile whose curves define reference lines |
|
|
128
|
+
*/
|
|
129
|
+
export const PluginReferenceLineCreateMultiArgs = z.object({
|
|
130
|
+
profile: PProfile,
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
export type PluginReferenceLineCreateMultiArgs = z.infer<typeof PluginReferenceLineCreateMultiArgs>
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Result of {@linkcode PluginReferenceLineApi.createMulti}.
|
|
137
|
+
*
|
|
138
|
+
* | Property | Type | Description |
|
|
139
|
+
* |---|---|---|
|
|
140
|
+
* | `referenceLineIds` | `string[]` | IDs of the created reference lines |
|
|
141
|
+
*/
|
|
142
|
+
export const PluginReferenceLineCreateMultiResult = z.object({
|
|
143
|
+
referenceLineIds: z.array(z.string()),
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
export type PluginReferenceLineCreateMultiResult = z.infer<typeof PluginReferenceLineCreateMultiResult>
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Available properties that can be queried on a reference line.
|
|
150
|
+
*
|
|
151
|
+
* | Value | Return Type | Description |
|
|
152
|
+
* |---|---|---|
|
|
153
|
+
* | `"curve"` | {@linkcode PCurve} | The curve geometry of the reference line |
|
|
154
|
+
*/
|
|
155
|
+
export const PluginReferenceLineGetProperty = z.enum([
|
|
156
|
+
"curve",
|
|
157
|
+
])
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Arguments for {@linkcode PluginReferenceLineApi.get}.
|
|
161
|
+
*
|
|
162
|
+
* | Property | Type | Description |
|
|
163
|
+
* |---|---|---|
|
|
164
|
+
* | `referenceLineId` | `string` | The reference line ID to query |
|
|
165
|
+
* | `properties` | {@linkcode PluginReferenceLineGetProperty}`[]` | Properties to retrieve |
|
|
166
|
+
*/
|
|
167
|
+
export const PluginReferenceLineGetArgs = z.object({
|
|
168
|
+
referenceLineId: z.string(),
|
|
169
|
+
properties: z.array(PluginReferenceLineGetProperty),
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
export type PluginReferenceLineGetArgs = z.infer<typeof PluginReferenceLineGetArgs>
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Result of {@linkcode PluginReferenceLineApi.get}.
|
|
176
|
+
*
|
|
177
|
+
* A partial object — only the properties that were requested in
|
|
178
|
+
* {@linkcode PluginReferenceLineGetArgs.properties} will be present.
|
|
179
|
+
*/
|
|
180
|
+
export const PluginReferenceLineGetResult = z
|
|
181
|
+
.object({
|
|
182
|
+
curve: PCurve,
|
|
183
|
+
})
|
|
184
|
+
.partial()
|
|
185
|
+
|
|
186
|
+
export type PluginReferenceLineGetResult = z.infer<typeof PluginReferenceLineGetResult>
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Result of {@linkcode PluginReferenceLineApi.getAll}.
|
|
190
|
+
*
|
|
191
|
+
* | Property | Type | Description |
|
|
192
|
+
* |---|---|---|
|
|
193
|
+
* | `referenceLineIds` | `string[]` | IDs of all reference lines in the project |
|
|
194
|
+
*/
|
|
195
|
+
export const PluginReferenceLineGetAllResult = z.object({
|
|
196
|
+
referenceLineIds: z.array(z.string()),
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
export type PluginReferenceLineGetAllResult = z.infer<typeof PluginReferenceLineGetAllResult>
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Arguments for {@linkcode PluginReferenceLineApi.delete}.
|
|
203
|
+
*
|
|
204
|
+
* | Property | Type | Description |
|
|
205
|
+
* |---|---|---|
|
|
206
|
+
* | `referenceLineId` | `string` | The reference line ID to delete |
|
|
207
|
+
*/
|
|
208
|
+
export const PluginReferenceLineDeleteArgs = z.object({
|
|
209
|
+
referenceLineId: z.string(),
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
export type PluginReferenceLineDeleteArgs = z.infer<typeof PluginReferenceLineDeleteArgs>
|
|
213
|
+
|
|
214
|
+
/** Result type for {@linkcode PluginReferenceLineApi.delete} — returns nothing on success. */
|
|
215
|
+
export type PluginReferenceLineDeleteResult = void
|
package/src/api/entity/space.ts
CHANGED
|
@@ -165,6 +165,38 @@ export abstract class PluginSpaceApi {
|
|
|
165
165
|
public abstract delete({
|
|
166
166
|
spaceId,
|
|
167
167
|
}: PluginSpaceDeleteArgs): PluginApiReturn<PluginSpaceDeleteResult>
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Update properties of a space by its ID.
|
|
171
|
+
*
|
|
172
|
+
* Only the properties provided in {@linkcode PluginSpaceUpdateArgs.properties
|
|
173
|
+
* args.properties} will be updated — omitted properties remain unchanged.
|
|
174
|
+
* This operation is undoable via Snaptrude's command system.
|
|
175
|
+
*
|
|
176
|
+
* @param args - An object containing:
|
|
177
|
+
* - {@linkcode PluginSpaceUpdateArgs.spaceId args.spaceId} — The unique space ID
|
|
178
|
+
* to update
|
|
179
|
+
* - {@linkcode PluginSpaceUpdateArgs.properties args.properties} — Key/value pairs
|
|
180
|
+
* of properties to update. See {@linkcode PluginSpaceUpdateArgs} for supported fields.
|
|
181
|
+
* @returns A {@linkcode PluginSpaceUpdateResult} echoing back the `spaceId` and
|
|
182
|
+
* the updated property values
|
|
183
|
+
* @throws If the space does not exist or the component is not a space/mass
|
|
184
|
+
*
|
|
185
|
+
* # Example
|
|
186
|
+
* ```ts
|
|
187
|
+
* const result = await snaptrude.entity.space.update({
|
|
188
|
+
* spaceId: "some-space-id",
|
|
189
|
+
* properties: {
|
|
190
|
+
* room_type: "Kitchen",
|
|
191
|
+
* massType: "Room",
|
|
192
|
+
* departmentId: "CORE",
|
|
193
|
+
* },
|
|
194
|
+
* })
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
public abstract update(
|
|
198
|
+
args: PluginSpaceUpdateArgs
|
|
199
|
+
): PluginApiReturn<PluginSpaceUpdateResult>
|
|
168
200
|
}
|
|
169
201
|
|
|
170
202
|
/**
|
|
@@ -184,7 +216,9 @@ export const PluginSpaceCreateRectangularArgs = z.object({
|
|
|
184
216
|
}),
|
|
185
217
|
})
|
|
186
218
|
|
|
187
|
-
export type PluginSpaceCreateRectangularArgs = z.infer<
|
|
219
|
+
export type PluginSpaceCreateRectangularArgs = z.infer<
|
|
220
|
+
typeof PluginSpaceCreateRectangularArgs
|
|
221
|
+
>
|
|
188
222
|
|
|
189
223
|
/**
|
|
190
224
|
* Result of {@linkcode PluginSpaceApi.createRectangular}.
|
|
@@ -197,7 +231,9 @@ export const PluginSpaceCreateRectangularResult = z.object({
|
|
|
197
231
|
spaceId: z.string(),
|
|
198
232
|
})
|
|
199
233
|
|
|
200
|
-
export type PluginSpaceCreateRectangularResult = z.infer<
|
|
234
|
+
export type PluginSpaceCreateRectangularResult = z.infer<
|
|
235
|
+
typeof PluginSpaceCreateRectangularResult
|
|
236
|
+
>
|
|
201
237
|
|
|
202
238
|
/**
|
|
203
239
|
* Arguments for {@linkcode PluginSpaceApi.createFromProfile}.
|
|
@@ -214,7 +250,9 @@ export const PluginSpaceCreateFromProfileArgs = z.object({
|
|
|
214
250
|
position: PVec3,
|
|
215
251
|
})
|
|
216
252
|
|
|
217
|
-
export type PluginSpaceCreateFromProfileArgs = z.infer<
|
|
253
|
+
export type PluginSpaceCreateFromProfileArgs = z.infer<
|
|
254
|
+
typeof PluginSpaceCreateFromProfileArgs
|
|
255
|
+
>
|
|
218
256
|
|
|
219
257
|
/**
|
|
220
258
|
* Result of {@linkcode PluginSpaceApi.createFromProfile}.
|
|
@@ -227,35 +265,72 @@ export const PluginSpaceCreateFromProfileResult = z.object({
|
|
|
227
265
|
spaceId: z.string(),
|
|
228
266
|
})
|
|
229
267
|
|
|
230
|
-
export type PluginSpaceCreateFromProfileResult = z.infer<
|
|
268
|
+
export type PluginSpaceCreateFromProfileResult = z.infer<
|
|
269
|
+
typeof PluginSpaceCreateFromProfileResult
|
|
270
|
+
>
|
|
231
271
|
|
|
232
272
|
/**
|
|
233
273
|
* Available properties that can be queried on a space.
|
|
234
274
|
*
|
|
275
|
+
* **Basic:**
|
|
235
276
|
* | Value | Return Type | Description |
|
|
236
277
|
* |---|---|---|
|
|
237
278
|
* | `"id"` | `string` | Unique space identifier |
|
|
238
279
|
* | `"type"` | `string` | Component type |
|
|
239
280
|
* | `"room_type"` | `string` | Room type classification |
|
|
240
281
|
* | `"name"` | `string` | Display name of the space |
|
|
241
|
-
*
|
|
242
|
-
*
|
|
282
|
+
*
|
|
283
|
+
* **Derived from parametric data:**
|
|
284
|
+
* | Value | Return Type | Description |
|
|
285
|
+
* |---|---|---|
|
|
286
|
+
* | `"area"` | `number` | Bottom face area (from `areas_bottomFace`) |
|
|
287
|
+
* | `"breadth"` | `number` | Breadth dimension |
|
|
288
|
+
* | `"depth"` | `number` | Depth dimension |
|
|
289
|
+
* | `"height"` | `number` | Height dimension |
|
|
290
|
+
* | `"massType"` | `string \| null` | Mass type classification |
|
|
291
|
+
* | `"spaceType"` | `string \| null` | Space type classification (Room, Balcony, etc.) |
|
|
292
|
+
* | `"storey"` | `number \| null` | Story the space belongs to |
|
|
293
|
+
* | `"departmentId"` | `string \| null` | Assigned department ID |
|
|
294
|
+
* | `"departmentName"` | `string` | Assigned department name |
|
|
295
|
+
* | `"departmentColor"` | `string` | Assigned department color (hex/CSS) |
|
|
296
|
+
*
|
|
297
|
+
* **Derived from mesh:**
|
|
298
|
+
* | Value | Return Type | Description |
|
|
299
|
+
* |---|---|---|
|
|
243
300
|
* | `"position"` | {@linkcode PVec3} | Local position relative to parent |
|
|
244
301
|
* | `"absolutePosition"` | {@linkcode PVec3} | Absolute position in the scene |
|
|
245
302
|
* | `"rotation"` | {@linkcode PVec3} | Euler rotation angles (radians) |
|
|
246
303
|
* | `"rotationQuaternion"` | {@linkcode PQuat} \| `null` | Quaternion rotation, or `null` if unset |
|
|
304
|
+
*
|
|
305
|
+
* **Derived from brep:**
|
|
306
|
+
* | Value | Return Type | Description |
|
|
307
|
+
* |---|---|---|
|
|
308
|
+
* | `"planPoints"` | {@linkcode PVec3}`[]` | Bottom outer profile points in world space with `y = 0` (2D plan). No closing duplicate point. |
|
|
247
309
|
*/
|
|
248
310
|
export const PluginSpaceGetProperty = z.enum([
|
|
311
|
+
// Basic
|
|
249
312
|
"id",
|
|
250
313
|
"type",
|
|
251
314
|
"room_type",
|
|
252
315
|
"name",
|
|
316
|
+
// Derived from parametric data
|
|
253
317
|
"area",
|
|
254
|
-
"
|
|
318
|
+
"breadth",
|
|
319
|
+
"depth",
|
|
320
|
+
"height",
|
|
321
|
+
"massType",
|
|
322
|
+
"spaceType",
|
|
323
|
+
"storey",
|
|
324
|
+
"departmentId",
|
|
325
|
+
"departmentName",
|
|
326
|
+
"departmentColor",
|
|
327
|
+
// Derived from mesh
|
|
255
328
|
"position",
|
|
256
329
|
"absolutePosition",
|
|
257
330
|
"rotation",
|
|
258
331
|
"rotationQuaternion",
|
|
332
|
+
// Derived from brep
|
|
333
|
+
"planPoints",
|
|
259
334
|
])
|
|
260
335
|
|
|
261
336
|
/**
|
|
@@ -273,6 +348,33 @@ export const PluginSpaceGetArgs = z.object({
|
|
|
273
348
|
|
|
274
349
|
export type PluginSpaceGetArgs = z.infer<typeof PluginSpaceGetArgs>
|
|
275
350
|
|
|
351
|
+
/**
|
|
352
|
+
* Supported space type values.
|
|
353
|
+
*
|
|
354
|
+
* Mirrors the internal `SpaceType` enum from `spaceType.types.ts`.
|
|
355
|
+
*
|
|
356
|
+
* | Value | Description |
|
|
357
|
+
* |---|---|
|
|
358
|
+
* | `"Room"` | Standard room |
|
|
359
|
+
* | `"Program Block"` | Program/department block |
|
|
360
|
+
* | `"Balcony"` | Balcony space |
|
|
361
|
+
* | `"Road"` | Road |
|
|
362
|
+
* | `"Garden"` | Garden area |
|
|
363
|
+
* | `"Deck"` | Deck |
|
|
364
|
+
* | `"Pool"` | Pool |
|
|
365
|
+
* | `"Walkway"` | Walkway |
|
|
366
|
+
*/
|
|
367
|
+
export const PluginSpaceType = z.enum([
|
|
368
|
+
"Room",
|
|
369
|
+
"Program Block",
|
|
370
|
+
"Balcony",
|
|
371
|
+
"Road",
|
|
372
|
+
"Garden",
|
|
373
|
+
"Deck",
|
|
374
|
+
"Pool",
|
|
375
|
+
"Walkway",
|
|
376
|
+
])
|
|
377
|
+
|
|
276
378
|
/**
|
|
277
379
|
* Result of {@linkcode PluginSpaceApi.get}.
|
|
278
380
|
*
|
|
@@ -281,16 +383,29 @@ export type PluginSpaceGetArgs = z.infer<typeof PluginSpaceGetArgs>
|
|
|
281
383
|
*/
|
|
282
384
|
export const PluginSpaceGetResult = z
|
|
283
385
|
.object({
|
|
386
|
+
// Basic
|
|
284
387
|
id: z.string(),
|
|
285
388
|
type: z.string(),
|
|
286
389
|
room_type: z.string(),
|
|
287
390
|
name: z.string(),
|
|
391
|
+
// Derived from parametric data
|
|
288
392
|
area: z.number(),
|
|
289
|
-
|
|
393
|
+
breadth: z.number(),
|
|
394
|
+
depth: z.number(),
|
|
395
|
+
height: z.number(),
|
|
396
|
+
massType: z.string().nullable(),
|
|
397
|
+
spaceType: PluginSpaceType.nullable(),
|
|
398
|
+
storey: z.number().nullable(),
|
|
399
|
+
departmentId: z.string().nullable(),
|
|
400
|
+
departmentName: z.string(),
|
|
401
|
+
departmentColor: z.string(),
|
|
402
|
+
// Derived from mesh
|
|
290
403
|
position: PVec3,
|
|
291
404
|
absolutePosition: PVec3,
|
|
292
405
|
rotation: PVec3,
|
|
293
406
|
rotationQuaternion: PQuat.nullable(),
|
|
407
|
+
// Derived from brep
|
|
408
|
+
planPoints: z.array(PVec3),
|
|
294
409
|
})
|
|
295
410
|
.partial()
|
|
296
411
|
|
|
@@ -324,3 +439,111 @@ export type PluginSpaceDeleteArgs = z.infer<typeof PluginSpaceDeleteArgs>
|
|
|
324
439
|
|
|
325
440
|
/** Result type for {@linkcode PluginSpaceApi.delete} — returns nothing on success. */
|
|
326
441
|
export type PluginSpaceDeleteResult = void
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Supported mass type values for {@linkcode PluginSpaceUpdateArgs.properties.massType}.
|
|
445
|
+
*
|
|
446
|
+
* Mirrors the internal `MASS_TYPES` enum.
|
|
447
|
+
*
|
|
448
|
+
* | Value | Description |
|
|
449
|
+
* |---|---|
|
|
450
|
+
* | `"Plinth"` | Plinth mass |
|
|
451
|
+
* | `"Void"` | Void/cut-out |
|
|
452
|
+
* | `"Pergola"` | Pergola structure |
|
|
453
|
+
* | `"Furniture"` | Furniture element |
|
|
454
|
+
* | `"Facade element"` | Facade element |
|
|
455
|
+
* | `"Generic mass"` | Generic mass |
|
|
456
|
+
* | `"Room"` | Room (default for spaces) |
|
|
457
|
+
* | `"Department"` | Department block |
|
|
458
|
+
* | `"Building"` | Building envelope |
|
|
459
|
+
* | `"Revit Import"` | Imported from Revit |
|
|
460
|
+
* | `"Mass"` | Generic mass type |
|
|
461
|
+
* | `"Site"` | Site object |
|
|
462
|
+
*/
|
|
463
|
+
export const PluginMassType = z.enum([
|
|
464
|
+
"Plinth",
|
|
465
|
+
"Void",
|
|
466
|
+
"Pergola",
|
|
467
|
+
"Furniture",
|
|
468
|
+
"Facade element",
|
|
469
|
+
"Generic mass",
|
|
470
|
+
"Room",
|
|
471
|
+
"Department",
|
|
472
|
+
"Building",
|
|
473
|
+
"Revit Import",
|
|
474
|
+
"Mass",
|
|
475
|
+
"Site",
|
|
476
|
+
])
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Well-known (built-in) department IDs.
|
|
480
|
+
*
|
|
481
|
+
* | Value | Department |
|
|
482
|
+
* |---|---|
|
|
483
|
+
* | `"DEFAULT"` | Default department |
|
|
484
|
+
* | `"SITE"` | Site department |
|
|
485
|
+
* | `"ENVELOPE"` | Envelope department |
|
|
486
|
+
* | `"CORE"` | Core department |
|
|
487
|
+
*/
|
|
488
|
+
export const PluginWellKnownDepartmentId = z.enum([
|
|
489
|
+
"DEFAULT",
|
|
490
|
+
"SITE",
|
|
491
|
+
"ENVELOPE",
|
|
492
|
+
"CORE",
|
|
493
|
+
])
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* Accepted department ID values — either a {@linkcode PluginWellKnownDepartmentId}
|
|
497
|
+
* or a UUID string for custom (user-created) departments.
|
|
498
|
+
*/
|
|
499
|
+
export const PluginDepartmentId = z.union([
|
|
500
|
+
PluginWellKnownDepartmentId,
|
|
501
|
+
z.uuid(),
|
|
502
|
+
])
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Arguments for {@linkcode PluginSpaceApi.update}.
|
|
506
|
+
*
|
|
507
|
+
* | Property | Type | Description |
|
|
508
|
+
* |---|---|---|
|
|
509
|
+
* | `spaceId` | `string` | The space ID to update |
|
|
510
|
+
* | `properties` | `object` | Key/value pairs of properties to update (all optional) |
|
|
511
|
+
* | `properties.room_type` | `string?` | New room type label |
|
|
512
|
+
* | `properties.massType` | {@linkcode PluginMassType}`?` | New mass type |
|
|
513
|
+
* | `properties.departmentId` | {@linkcode PluginDepartmentId}`?` | New department ID |
|
|
514
|
+
*/
|
|
515
|
+
export const PluginSpaceUpdateArgs = z.object({
|
|
516
|
+
spaceId: z.string(),
|
|
517
|
+
properties: z.object({
|
|
518
|
+
room_type: z.string().optional(),
|
|
519
|
+
massType: PluginMassType.optional(),
|
|
520
|
+
spaceType: PluginSpaceType.optional(),
|
|
521
|
+
departmentId: PluginDepartmentId.optional(),
|
|
522
|
+
}),
|
|
523
|
+
})
|
|
524
|
+
|
|
525
|
+
export type PluginSpaceUpdateArgs = z.infer<typeof PluginSpaceUpdateArgs>
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Result of {@linkcode PluginSpaceApi.update}.
|
|
529
|
+
*
|
|
530
|
+
* Echoes back the `spaceId` and the values of properties that were updated.
|
|
531
|
+
* Properties that were not included in the update request will be `undefined`.
|
|
532
|
+
*
|
|
533
|
+
* | Property | Type | Description |
|
|
534
|
+
* |---|---|---|
|
|
535
|
+
* | `spaceId` | `string` | The space ID that was updated |
|
|
536
|
+
* | `room_type` | `string?` | Updated room type (if changed) |
|
|
537
|
+
* | `massType` | `string?` | Updated mass type (if changed) |
|
|
538
|
+
* | `spaceType` | `string?` | Updated space type (if changed) |
|
|
539
|
+
* | `departmentId` | `string \| null?` | Updated department ID (if changed) |
|
|
540
|
+
*/
|
|
541
|
+
export const PluginSpaceUpdateResult = z.object({
|
|
542
|
+
spaceId: z.string(),
|
|
543
|
+
room_type: z.string().optional(),
|
|
544
|
+
massType: z.string().optional(),
|
|
545
|
+
spaceType: z.string().optional(),
|
|
546
|
+
departmentId: z.string().nullable().optional(),
|
|
547
|
+
})
|
|
548
|
+
|
|
549
|
+
export type PluginSpaceUpdateResult = z.infer<typeof PluginSpaceUpdateResult>
|
package/src/api/units/index.ts
CHANGED
|
@@ -25,6 +25,8 @@ export abstract class PluginUnitsApi {
|
|
|
25
25
|
* to convert from. See {@linkcode PUnitType} for supported values.
|
|
26
26
|
* - {@linkcode PluginUnitsConvertFromArgs.value args.value} — The numeric
|
|
27
27
|
* value in the source unit
|
|
28
|
+
* - {@linkcode PluginUnitsConvertFromArgs.degree args.degree} — (Optional)
|
|
29
|
+
* Degree of the unit: 1 for length, 2 for area, 3 for volume. Defaults to 1
|
|
28
30
|
* @returns A {@linkcode PluginUnitsConvertFromResult} containing the converted
|
|
29
31
|
* `value` in Babylon units
|
|
30
32
|
*
|
|
@@ -53,6 +55,8 @@ export abstract class PluginUnitsApi {
|
|
|
53
55
|
* to convert to. See {@linkcode PUnitType} for supported values.
|
|
54
56
|
* - {@linkcode PluginUnitsConvertToArgs.value args.value} — The numeric
|
|
55
57
|
* value in Babylon units
|
|
58
|
+
* - {@linkcode PluginUnitsConvertToArgs.degree args.degree} — (Optional)
|
|
59
|
+
* Degree of the unit: 1 for length, 2 for area, 3 for volume. Defaults to 1
|
|
56
60
|
* @returns A {@linkcode PluginUnitsConvertToResult} containing the converted
|
|
57
61
|
* `value` in the target unit
|
|
58
62
|
*
|
|
@@ -66,6 +70,7 @@ export abstract class PluginUnitsApi {
|
|
|
66
70
|
* const areaInMeters = await snaptrude.units.convertTo({
|
|
67
71
|
* unit: "meters",
|
|
68
72
|
* value: info.area!,
|
|
73
|
+
* degree: 2,
|
|
69
74
|
* })
|
|
70
75
|
* ```
|
|
71
76
|
*/
|
|
@@ -104,10 +109,12 @@ export type PUnitType = z.infer<typeof PUnitType>
|
|
|
104
109
|
* |---|---|---|
|
|
105
110
|
* | `unit` | {@linkcode PUnitType} | Source real-world unit |
|
|
106
111
|
* | `value` | `number` | Numeric value in the source unit |
|
|
112
|
+
* | `degree` | `1 \| 2 \| 3` | (Optional) Degree of the unit (e.g. 1 for length, 2 for area, 3 for volume). Defaults to 1 |
|
|
107
113
|
*/
|
|
108
114
|
export const PluginUnitsConvertFromArgs = z.object({
|
|
109
115
|
unit: PUnitType,
|
|
110
116
|
value: z.number(),
|
|
117
|
+
degree: z.number().int().min(1).max(3).optional(),
|
|
111
118
|
})
|
|
112
119
|
|
|
113
120
|
export type PluginUnitsConvertFromArgs = z.infer<typeof PluginUnitsConvertFromArgs>
|
|
@@ -132,10 +139,12 @@ export type PluginUnitsConvertFromResult = z.infer<typeof PluginUnitsConvertFrom
|
|
|
132
139
|
* |---|---|---|
|
|
133
140
|
* | `unit` | {@linkcode PUnitType} | Target real-world unit |
|
|
134
141
|
* | `value` | `number` | Numeric value in Babylon units |
|
|
142
|
+
* | `degree` | `1 \| 2 \| 3` | (Optional) Degree of the unit (e.g. 1 for length, 2 for area, 3 for volume). Defaults to 1 |
|
|
135
143
|
*/
|
|
136
144
|
export const PluginUnitsConvertToArgs = z.object({
|
|
137
145
|
unit: PUnitType,
|
|
138
146
|
value: z.number(),
|
|
147
|
+
degree: z.number().int().min(1).max(3).optional(),
|
|
139
148
|
})
|
|
140
149
|
|
|
141
150
|
export type PluginUnitsConvertToArgs = z.infer<typeof PluginUnitsConvertToArgs>
|