How to create a measurement annotation programatically

Another unofficial workaround right now is to manually set the “IT” (intent) property and the “Measure” property on the annotation after you instantiate them.
Please use with caution and test thouroughly before using this in production as it’s not yet officially supported.


const annot = new PolygonAnnotation(...);
annot.IT = 'PolygonDimension';

// For perimeter measurement:
// const annot = new PolyLineAnnotation(...);
// annot.IT = 'PolyLineDimension';

annot.Measure = {
  'scale': '1 in = 1 in',
  'axis': [
    {
      'factor': 0.0138889,
      'unit': 'in',
      'decimalSymbol': '.',
      'thousandsSymbol': ',',
      'display': 'D',
      'precision': 100,
      'unitPrefix': '',
      'unitSuffix': '',
      'unitPosition': 'S',
    },
  ],
  'distance': [
    {
      'factor': 1,
      'unit': 'in',
      'decimalSymbol': '.',
      'thousandsSymbol': ',',
      'display': 'D',
      'precision': 100,
      'unitPrefix': '',
      'unitSuffix': '',
      'unitPosition': 'S',
    },
  ],
  'area': [
    {
      'factor': 1,
      'unit': 'sq in',
      'decimalSymbol': '.',
      'thousandsSymbol': ',',
      'display': 'D',
      'precision': 100,
      'unitPrefix': '',
      'unitSuffix': '',
      'unitPosition': 'S',
    },
  ],
};