Appearance
Storey Layers
Read and toggle a storey's sketch surfaces and imported underlays. Accessed via snaptrude.core.storeys.layers (formerly snaptrude.core.layers).
These are each storey's built-in sketch surfaces (Wall, Rough) and its imported underlays (CAD, PDF, images, terrain, neighbourhood buildings), with ids like ly_5. They are not the layers in the product's Layers panel in the left sidebar; use core.layers for those. They are also not wall/floor construction-assembly material layers, which are a property of the built element.
Reads return plain records and never throw for a missing layer (get and getActive return null, list returns []). update and setActive are not undoable. Storey layers are created only by storey creation and core.io.import.*; delete underlays with core.io.underlay.delete / core.io.terrain.delete. Locking and renaming are not exposed; locked is a read-only status field.
Moved
This API used to live at snaptrude.core.layers, with types named PluginCoreLayer / PluginCoreLayerType. It moved here unchanged apart from the names: core.layers.<method> is now core.storeys.layers.<method>, and the types are PluginCoreStoreyLayer / PluginCoreStoreyLayerType. Calls in the old shape on core.layers (list(storeyId), getActive(storeyId), get / setActive / update(layerId, hidden) with a ly_* id) are still routed here, so plugins built before 0.9.15 keep working; new code should call core.storeys.layers directly.
At a glance
| Method | What it does | Mutates? |
|---|---|---|
list(storeyId, layerType?) | List a storey's storey layers | — |
get(layerId) | One layer by id, or null | — |
getActive(storeyId) | The storey's active sketch surface | — |
setActive(layerId) | Make a layer the storey's active layer | ✓ (not undoable) |
update(layerId, hidden?) | Show/hide a layer (sparse) | ✓ (not undoable) |
Types
PluginCoreStoreyLayerType
The kind of a storey layer: author-drawable kinds ("floor", "wall", "ceiling", "rough", "default") plus read-only imported underlays ("image", "cad", "pdf", "terrain", "buildings").
PluginCoreStoreyLayer
A storey layer on a storey.
| Property | Type | Description |
|---|---|---|
id | string | Stable public layer id (e.g. "ly_5") |
name | string | Display name |
layerType | PluginCoreStoreyLayerType | The layer's kind |
storeyId | string | The stable id of the storey this layer belongs to |
buildingId | string | The stable id of the building this layer belongs to |
hidden | boolean | Whether the layer is hidden |
locked | boolean | Whether the layer is locked against edits |
contentSummary | object | A summary of what the layer holds (see below) |
contentSummary:
| Property | Type | Description |
|---|---|---|
hasFloorplan | boolean | Whether the layer holds drawn floorplan geometry |
pdfCount | number | Number of PDF underlays on the layer |
hasTerrain | boolean | Whether the layer holds terrain |
Functions
list(storeyId, layerType?)
List the storey layers of a storey, optionally filtered to a single layer type.
- Parameters:
storeyId:string— the storey whose layers to readlayerType:PluginCoreStoreyLayerType | undefined— optional layer-type filter
- Returns:
{ layers: PluginCoreStoreyLayer[] }— empty when the storey is missing or has no matching layers.
ts
const { layers } = await snaptrude.core.storeys.layers.list("st_2");
for (const l of layers) console.log(l.name, l.layerType, l.hidden);get(layerId)
Get a single storey layer by id.
- Parameters:
layerId:string— the id of the layer to read
- Returns:
PluginCoreStoreyLayer | null—nullif no layer has that id.
ts
const layer = await snaptrude.core.storeys.layers.get("ly_5");
if (layer) console.log(layer.name, layer.hidden, layer.locked);getActive(storeyId)
Get the active storey layer of a storey — the one new sketch geometry is drawn onto. Paired with setActive.
- Parameters:
storeyId:string— the storey whose active layer to read
- Returns:
PluginCoreStoreyLayer | null—nullif the storey is missing or has no active layer.
ts
const active = await snaptrude.core.storeys.layers.getActive("st_2");
if (active) console.log(active.name);setActive(layerId)
Make a storey layer the active layer of its storey. Paired with getActive. Not undoable.
- Parameters:
layerId:string— the id of the layer to activate
- Returns:
{ layerId: string }— the id of the now-active layer. - Throws: If no layer has the given id.
ts
await snaptrude.core.storeys.layers.setActive("ly_5");update(layerId, hidden?)
A sparse update of a storey layer's visibility — hidden is left unchanged if omitted. This edit is not undoable. Locking and renaming are not exposed: locked is a read-only status here (setting it at runtime does not lock the live meshes or show a padlock in the app until a reload), and a rename cascades to every member mesh's layerName, a corruption hazard.
- Parameters:
layerId:string— the id of the layer to updatehidden:boolean | undefined— new hidden state (unchanged if omitted)
- Returns:
PluginCoreStoreyLayer— the updated layer. - Throws: If no layer has the given id.
ts
const layer = await snaptrude.core.storeys.layers.update("ly_5", true);Errors
Failed calls reject with a typed PluginError — see Error Handling. Conditions specific to this namespace:
| Code | Thrown by | When | details |
|---|---|---|---|
HANDLE_INVALID | setActive, update | No layer has the given id | kind: "layer" |
Reads never throw: get and getActive return null on a miss, list returns [].