Message API/docs/components/measurement/api

API References

Technical references for measurement tool identifiers.

Message Structure

Measurement tools use the standard toolControl message structure for commands sent from the host to the viewer.

// 1. Tool Activation
iframeEl.contentWindow.postMessage({
  type: 'toolControl',
  payload: { group: 'measurement', action: 'MEASURE_LENGTH' }
}, '*');

// 2. Persistence Commands
iframeEl.contentWindow.postMessage({ type: 'saveAnnotations' }, '*');
iframeEl.contentWindow.postMessage({ 
  type: 'deleteAnnotation', 
  payload: { uniqueId: 'guid-here' } 
}, '*');
iframeEl.contentWindow.postMessage({ 
  type: 'setAutoSave', 
  payload: { enabled: true } 
}, '*');

// 3. Reset/Clear
iframeEl.contentWindow.postMessage({
  type: 'toolControl',
  payload: { command: 'clear' }
}, '*');

// 4. Data Extraction
iframeEl.contentWindow.postMessage({
  type: 'getAnnotationData',
  payload: { filter: 'all', requestId: 'req-001' }
}, '*');

// 5. Continuous count-point mode
iframeEl.contentWindow.postMessage({
  type: 'insertCountPointMode',
  payload: {
    enabled: true,
    guid: 'COUNT-ANNOTATION-GUID',
    requestId: 'count-mode-on-001'
  }
}, '*');
Message Structure

Event Interfaces

TypeScript definitions for measurement-related event payloads emitted by the viewer.

interface AnnotationCreatedPayload {
  guid: string;
  dbUniqueID?: string | number;
  data: {
    DimText?: string;
    Tool?: string;
    ViewName?: string;
    [key: string]: any;
  };
}

interface AnnotationSelectedPayload {
  guid: string;
  dbUniqueID?: string | number;
  data: {
    DimText?: string;
    Tool?: string;
    ViewName?: string;
    [key: string]: any;
  };
}

interface SaveAnnotationsCompletePayload {
  success: boolean;
  requestId?: string;
  [key: string]: any;
}

interface AnnotationDeletedPayload {
  guid: string;
  dbUniqueID?: string | number | null;
}

interface InsertCountPointModePayload {
  enabled: boolean;
  guid: string;
  requestId?: string;
}
Event Interfaces

Tool Identifiers

Available action IDs for the measurement group.

Measurement Tool IDs

const measurementToolIds = [
  'MEASURE_LENGTH',
  'MEASURE_AREA',
  'MEASURE_PATH',
  'MEASURE_ARC',
  'MEASURE_ANGLE_CCLOCKWISE',
  'MEASURE_RECTANGULAR_AREA',
  'COUNT',
  'SNAP',
];