Blocks
Request lightweight block lists, selected block details, attributes, and CAD block visibility updates.
getBlocks returns a lightweight block list for table, sidebar, and selection UI.
When a user selects a block from that list, request index-based details or attributes without reloading the drawing.
- getBlocks returns blocksSnapshot with index, name, visible, selected, and hasAttribute.
- getBlockDetails returns blockDetailsSnapshot with details, insert data, bounds, dimensions, area, and attributes.
- getBlockAttributes returns blockAttributesSnapshot with only the selected block attributes.
- Send setBlockVisibility using all, index, indexes, name, or names.
Use getBlocks as the initial data source for a fast block list. The response intentionally does not include details.
Use the returned index when the operator clicks a row, opens a details panel, or needs attributes for one or more blocks.
- requestId is optional but recommended for matching responses to requests.
- getBlockDetails and getBlockAttributes support index and indexes only.
- If no block matches, the canvas returns an empty payload.blocks array.
Keep list and detail requests separate. This keeps block panels responsive on large drawings and avoids moving heavy geometry data until the user asks for it.
- getBlocks returns blocksSnapshot as a lightweight list only, with no details.
- getBlockDetails returns blockDetailsSnapshot with index-based details plus attributes.
- getBlockAttributes returns blockAttributesSnapshot with index-based attributes only.
- setBlockVisibility is the visibility command for all blocks or selected block indexes/names.
These examples show the intended request order: load the list first, then request detail or attributes for the selected block index.
1. Request the lightweight list
2. Render the list response
3. Request details for a selected block
Request details for several indexes
Request attributes only
Hide blocks by index
Show every block
The host requests the lightweight block collection, renders it in its own UI, and requests details only for selected blocks.
1. Host requests blocks
Call getBlocks when the CAD block panel opens or the active file changes.
2. Canvas returns blocksSnapshot
The canvas responds with the current block list and visibility state for the active document.
3. Host requests selected block data
When a user selects a block row, send getBlockDetails or getBlockAttributes with the block index.
4. Canvas returns selected block data
Detail requests return blockDetailsSnapshot or blockAttributesSnapshot with a blocks array.
5. Host posts visibility updates
Use block names or indexes from the snapshot when toggling host-side controls.
This pattern gives you a standalone block panel with lazy detail requests for selected rows.
blocksSnapshot is intentionally small. Detail and attribute payloads are returned separately so list UIs stay fast.
blockDetailsSnapshot includes the block state, styling, insert transform, computed bounds, and attributes returned by the CAD canvas. If a request matches no blocks, payload.blocks is an empty array.
A blockDetailsSnapshot response wraps the requested blocks with request and active-file metadata.
- type: Always blockDetailsSnapshot for a getBlockDetails response.
- payload.requestId: Echoes the requestId supplied by the host, when provided.
- payload.fileId, payload.fileIndex, payload.fileName: Identify the active file that produced the response.
- payload.blocks: Array of matching blocks. It can be empty when no requested index exists.
- block.index, block.name: The block identifier and display name used by the viewer.
- block.details.state, defaultstate: Current and default visibility/state values from the CAD block record.
- block.details.color, defaultcolor: Current and default block colors, usually as hex strings when available.
- block.details.fillstyle, defaultfillstyle, hatchstyle: Fill and hatch styling values when the source drawing exposes them.
- block.details.overridecolor, overridefill: Whether color or fill is overridden from its default style.
- block.details.selected, listed, drawn, mouseon: Viewer/runtime flags for selection, list inclusion, draw state, and hover state.
- block.details.hasAttribute: True when the block has attribute rows.
- block.details.fold: Fold/grouping value returned by the CAD canvas.
- block.details.insert: Insert reference data, including handle values, insertion position, rotation, scale, blockref, raw extents, and value type.
- block.details.bounds: Computed block bounds in canvas coordinates, including min/max coordinates, width, height, and area.
- block.attributes: Attribute rows for the block. Each row includes name, value, and blockref when available.
Use the related pages below when you need the matching layer workflow or the full payload reference.
- Layers: Layers
- Technical Reference: API References
- CAD Overview: Overview
