Layers
Request CAD and PDF layer snapshots, inspect layer details, and update layer visibility from the host.
Layer workflows let the host inspect the current CAD and PDF layer list and control visibility using the identifiers returned by the viewer.
Layer snapshots include normalized visibility plus additive raw details for vector CAD layers when the broker provides them. Existing layer fields stay unchanged.
- Request the current layer state with getLayers and listen for layersSnapshot.
- Use layer.visible as the normalized show/hide boolean.
- Use layer.kind to distinguish vector layers from PDF layers.
- For vector CAD layers, target visibility updates by index. For PDF layers, target by id.
- After every setLayerVisibility request, the viewer responds with a fresh layersSnapshot, even when no target matches.
Use these fields when rendering layer rows or deciding which selector to send back to the viewer.
- visible is the normalized show/hide boolean.
- kind is vector or pdf.
- details.state is the raw vector layer state.
- details.defaultstate is the original or default state.
- details.isplottable is the raw CAD plot flag.
Start by requesting the current snapshot, then use the returned indexes, ids, or names when updating visibility.
Request layers
Listen for layersSnapshot
Hide one vector layer
Show multiple vector layers
Hide by layer name
Hide a PDF layer by id
Show all layers
The viewer responds to getLayers with layersSnapshot. The same response type is also sent after every setLayerVisibility request.
Choose the selector from the layer row returned by layersSnapshot. Visibility requests can update one layer, multiple layers, named layers, PDF layers, or every layer.
- Use index or indexes for vector CAD layers.
- Use id or ids for PDF layers.
- Use name or names when the frontend already has stable layer names.
- Use all when the visibility change should apply to every layer.
- If no target matches, the response still returns the current snapshot.
The host owns the panel state, but the canvas remains the source of truth for the live layer list.
1. Host requests layers
Call getLayers when the CAD panel opens or when the active file changes.
2. Canvas returns layersSnapshot
The viewer responds with a normalized list of layers, including names, ids, visibility, kind, and additive details when available.
3. Host posts visibility updates
Use index for vector CAD layers, id for PDF layers, or all for a global visibility change.
4. Canvas returns the updated snapshot
After setLayerVisibility, the viewer sends layersSnapshot again with the same requestId when available.
This pattern is enough to build a simple layer panel with host-side rendering and viewer-side state.
Use the related pages below when you need the matching block workflow or the full payload reference.
- Blocks: Blocks
- Technical Reference: API References
- CAD Overview: Overview
