Skip to content

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 ​

MethodWhat it doesMutates?
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.

PropertyTypeDescription
idstringStable public layer id (e.g. "ly_5")
namestringDisplay name
layerTypePluginCoreStoreyLayerTypeThe layer's kind
storeyIdstringThe stable id of the storey this layer belongs to
buildingIdstringThe stable id of the building this layer belongs to
hiddenbooleanWhether the layer is hidden
lockedbooleanWhether the layer is locked against edits
contentSummaryobjectA summary of what the layer holds (see below)

contentSummary:

PropertyTypeDescription
hasFloorplanbooleanWhether the layer holds drawn floorplan geometry
pdfCountnumberNumber of PDF underlays on the layer
hasTerrainbooleanWhether 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 read
    • layerType: 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 — null if 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 — null if 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 update
    • hidden: 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:

CodeThrown byWhendetails
HANDLE_INVALIDsetActive, updateNo layer has the given idkind: "layer"

Reads never throw: get and getActive return null on a miss, list returns [].