Appearance
Layers
Read and toggle the drawing/reference layers of a storey. Accessed via snaptrude.core.layers.
These are the drawing/reference layers shown in the storey's Layers panel — the surfaces you sketch on and the imported underlays (CAD, PDF, images, terrain). They are 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 []). v1 exposes reads plus a visibility toggle and the active-layer switch; update and setActive are not undoable. Locking, creating, deleting, and renaming layers are intentionally not part of this contract — locked is a read-only status field.
At a glance
| Method | What it does | Mutates? |
|---|---|---|
list(storeyId, layerType?) | List a storey's drawing layers | — |
get(layerId) | One layer by id, or null | — |
getActive(storeyId) | The storey's active drawing layer | — |
setActive(layerId) | Make a layer the storey's active layer | ✓ (not undoable) |
update(layerId, hidden?) | Show/hide a layer (sparse) | ✓ (not undoable) |
Types
PluginCoreLayerType
The kind of a drawing layer: author-drawable kinds ("floor", "wall", "ceiling", "rough", "default") plus read-only imported underlays ("image", "cad", "pdf", "terrain", "buildings").
PluginCoreLayer
A drawing/reference layer on a storey.
| Property | Type | Description |
|---|---|---|
id | string | Stable public layer id (e.g. "ly_5") |
name | string | Display name |
layerType | PluginCoreLayerType | 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 drawing layers of a storey, optionally filtered to a single layer type.
- Parameters:
storeyId:string— the storey whose layers to readlayerType:PluginCoreLayerType | undefined— optional layer-type filter
- Returns:
{ layers: PluginCoreLayer[] }— empty when the storey is missing or has no matching layers.
ts
const { layers } = await snaptrude.core.layers.list("st_2");
for (const l of layers) console.log(l.name, l.layerType, l.hidden);get(layerId)
Get a single drawing layer by id.
- Parameters:
layerId:string— the id of the layer to read
- Returns:
PluginCoreLayer | null—nullif no layer has that id.
ts
const layer = await snaptrude.core.layers.get("ly_5");
if (layer) console.log(layer.name, layer.hidden, layer.locked);getActive(storeyId)
Get the active drawing 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:
PluginCoreLayer | null—nullif the storey is missing or has no active layer.
ts
const active = await snaptrude.core.layers.getActive("st_2");
if (active) console.log(active.name);setActive(layerId)
Make a drawing 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.layers.setActive("ly_5");update(layerId, hidden?)
A sparse update of a drawing layer's visibility — hidden is left unchanged if omitted. Routes through the same path as clicking the eye in the Layers panel. This edit is not undoable. (Lock and rename are not exposed — a rename cascades to every member mesh and is a corruption hazard, and the layer lock flag doesn't take effect until reload.)
- Parameters:
layerId:string— the id of the layer to updatehidden:boolean | undefined— new hidden state (unchanged if omitted)
- Returns:
PluginCoreLayer— the updated layer. - Throws: If no layer has the given id.
ts
const layer = await snaptrude.core.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 [].