API References
Technical reference for CAD layer and block snapshot/visibility messages.
Use getBlocks for the list view. Use the returned block indexes to request details or attributes only when needed.
- getLayers: Requests the current layer snapshot.
- getBlocks: Requests the lightweight block list for table or sidebar UI.
- getBlockDetails: Requests details and attributes for one block index or multiple indexes.
- getBlockAttributes: Requests attributes only for one block index or multiple indexes.
Both visibility messages require a visible flag and support multiple target selectors so the host can address one or many items at once. After setLayerVisibility, the viewer sends layersSnapshot again with the current layer state.
- setLayerVisibility: Targets layers by all, index, indexes, id, ids, name, or names.
- setBlockVisibility: Targets blocks by all, index, indexes, name, or names.
The canvas returns a lightweight block list separately from selected block detail and attribute payloads. Detail and attribute lookups always return a blocks array, even when no block matches.
blockDetailsSnapshot returns the selected block records plus request and file metadata. Every matching block includes details and attributes.
- type: Message type returned by the canvas. For block details, this is blockDetailsSnapshot.
- payload.requestId: Optional request correlation value echoed from getBlockDetails.
- payload.fileId, payload.fileIndex, payload.fileName: Active file metadata for the snapshot.
- payload.blocks: Matching block records. The array is empty when no requested index matches.
- block.index, block.name: Block index and name at the wrapper level for quick list/detail matching.
- details.index, details.name: Block index and name repeated inside the raw detail object.
- details.state, details.defaultstate: Current and default CAD block state values.
- details.defaultcolor, details.color: Default and current colors. Values are hex strings when supplied by the canvas.
- details.fillstyle, details.defaultfillstyle, details.hatchstyle: Fill and hatch style values, or null when unavailable.
- details.overridecolor, details.overridefill: Flags indicating whether current style values override defaults.
- details.selected, details.listed, details.drawn, details.mouseon: Viewer flags for current UI/list/draw/hover state.
- details.hasAttribute: True when the block has attribute data.
- details.fold: Fold/group value returned by the viewer.
- details.insert.blockhandleLow, blockhandleHigh: CAD handle values for the inserted block reference.
- details.insert.insertX, insertY, insertZ: Insert position values in drawing coordinates.
- details.insert.insertRot: Insert rotation value.
- details.insert.insertscaleX, insertscaleY, insertscaleZ: Insert scale values for each axis.
- details.insert.blockref: Referenced block index/id for the insert.
- details.insert.MinX, MinY, MaxX, MaxY: Raw insert extents returned by the canvas.
- details.insert.type: Numeric representation used for insert values, such as float.
- details.bounds.minX, minY, maxX, maxY: Computed block bounds in canvas coordinates.
- details.bounds.width, height, area: Computed block dimensions and area.
- attributes[].name, attributes[].value, attributes[].blockref: Attribute tag name, value, and owning block reference.
Use these events when wiring a block list to a details panel.
