4 Dec 2017

Setting the Measure command units from API in the Forge Viewer

    Here is a question that came up from a customer recently: How do I set programmatically the units used by default by the Measure command? 

    The Measure extension exposes a number of methods that offer some features to JavaScript applications using the Forge Viewer. Unfortunately you won't find them detailed in the public documentation yet. After looking at the code, I found the following tip:

var measureExtension = viewer.getExtension('Autodesk.Measure')

// pick from available values:
// 'decimal-ft'
// 'ft-and-fractional-in'
// 'ft-and-decimal-in'
// 'decimal-in'
// 'fractional-in'
// 'm'
// 'cm'
// 'mm'
// 'm-and-cm'

measureExtension.setUnits('m')

Above snippet will set the units to meters. Refer to the exhaustive list in comments to set other units.

Related Article