Message API/docs/components/cad/api

API References

Technical reference for CAD layer and block snapshot/visibility messages.

Snapshot Requests

Use these messages to fetch the current CAD structure from the active file.

  • getLayers: Requests the current layer snapshot.
  • getBlocks: Requests the current block snapshot.
type GetLayersMessage = {
  type: 'getLayers';
  payload?: { requestId?: string };
};

type GetBlocksMessage = {
  type: 'getBlocks';
  payload?: { requestId?: string };
};
Snapshot Requests

Visibility Updates

Both visibility messages require a `visible` flag and support multiple target selectors so the host can address one or many items at once.

  • setLayerVisibility: Targets layers by `all`, `index`, `indexes`, `id`, `ids`, `name`, or `names`.
  • setBlockVisibility: Targets blocks by `all`, `index`, `indexes`, `name`, or `names`.
type SetLayerVisibilityMessage = {
  type: 'setLayerVisibility';
  payload: {
    requestId?: string;
    visible: boolean;
    all?: boolean;
    index?: number;
    indexes?: number[];
    id?: string | number;
    ids?: Array<string | number>;
    name?: string;
    names?: string[];
  };
};

type SetBlockVisibilityMessage = {
  type: 'setBlockVisibility';
  payload: {
    requestId?: string;
    visible: boolean;
    all?: boolean;
    index?: number;
    indexes?: number[];
    name?: string;
    names?: string[];
  };
};
Visibility Updates

Viewer Responses

The viewer returns normalized snapshot payloads that can be rendered directly by the host.

type LayerSnapshotPayload = {
  requestId?: string;
  fileId?: string;
  fileIndex?: number;
  fileName?: string;
  layers: Array<{
    index?: number;
    id?: string | number;
    name?: string;
    color?: string;
    visible: boolean;
    kind: 'pdf' | 'vector';
  }>;
};

type BlockSnapshotPayload = {
  requestId?: string;
  fileId?: string;
  fileIndex?: number;
  fileName?: string;
  blocks: Array<{
    index?: number;
    name?: string;
    visible: boolean;
    selected?: boolean;
    hasAttribute?: boolean;
  }>;
};
Viewer Responses