Skip to content

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

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

PropertyTypeDescription
idstringStable public layer id (e.g. "ly_5")
namestringDisplay name
layerTypePluginCoreLayerTypeThe 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 drawing layers of a storey, optionally filtered to a single layer type.

  • Parameters:
    • storeyId: string — the storey whose layers to read
    • layerType: 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 | nullnull if 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 | nullnull if 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 update
    • hidden: 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:

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

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