How to create a measurement annotation programatically

Hi,

I’d like to create measurement annotations programatically from a dataset.

So far, I can create polylines or polygons annotations without any problem from the PolylineAnnotation / PolygonAnnotation class.

The doc specifies that one annotation is a measurement annotation if it contains a Measure property.

How should I set this property to end with a consistent annotation that will be processed as a Measure ?

Thanks

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Hi,

At the moment the measurement annotations can only be instantiated through UI. You could try instantiating the measurement annotation create tools and call mouse methods on the tool if it is an option for you.

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',
    },
  ],
};