MeasureExtension
new MeasureExtension(viewer, options)
Provides UI controls to perform distance and angle measurements for 2D and 3D models.
The extension id is: Autodesk.Measure
Parameters
viewer* | Viewer instance |
options* object | Configurations for the extension |
Examples
viewer.loadExtension('Autodesk.Measure')
Methods
load()
Load the measure extension.
Returns
type | description |
---|---|
boolean | True if measure extension is loaded successfully. |
unload()
Unload the measure extension.
Returns
type | description |
---|---|
boolean | True if measure extension is unloaded successfully. |
getMeasurement(unitType, precision)
Get the current measurement in the measure tool.
Parameters
unitType string | Either: “decimal-ft”, “ft”, “ft-and-decimal-in”, “decimal-in”, “fractional-in”, “m”, “cm”, “mm” or “m-and-cm”. |
precision number | precision index (0: 0, 1: 0.1, 2: 0.01, 3: 0.001, 4: 0.0001, 5: 0.00001). When units type is “ft”, “in” or “fractional-in”, then the precisions are 0: 1, 1: 1/2, 2: 1/4, 3: 1/8, 4: 1/16, 5: 1/32, 6: 1/64. |
Returns
type | description |
---|---|
object, null | Object with properties of the current measurement, or null. |
getMeasurementList(unitType, precision)
Get a list of all the measurements that are currently on the screen.
Parameters
unitType string | Either: “decimal-ft”, “ft”, “ft-and-decimal-in”, “decimal-in”, “fractional-in”, “m”, “cm”, “mm” or “m-and-cm”. |
precision number | precision index (0: 0, 1: 0.1, 2: 0.01, 3: 0.001, 4: 0.0001, 5: 0.00001). When units type is “ft”, “in” or “fractional-in”, then the precisions are 0: 1, 1: 1/2, 2: 1/4, 3: 1/8, 4: 1/16, 5: 1/32, 6: 1/64. |
Returns
type | description |
---|---|
Array.<object> | An array of measurement objects with properties of the measurement. |
setMeasurements(measurements)
Restores existing measurements. The measurements
object should be generated by either the getMeasurementList or the getMeasurement methods.
Parameters
measurements* Array.<object>, object | An array of measurement objects |
activate(mode, type)
Activates the tool and UI to start measuring.
Parameters
mode string | Either ‘distance’, ‘angle’, ‘area’ (2D only), ‘arc’ (2D only), ‘calibrate’ or ‘custom’. Default is ‘distance’. |
type string | Custom measurement type. Required when mode is ‘custom’. |
deactivate()
Deactivates measuring tool and UI.
Returns
type | description |
---|---|
boolean |
setIsolateMeasure(enable)
When enabled, the Viewer will only render model parts that are included in measurements.
Parameters
enable* boolean | true to render only nodes being measured. |
deleteAllMeasurements()
Delete all measurements.
deleteCurrentMeasurement()
Deletes the selected measurement.
setFreeMeasureMode(allow, useLastViewport)
Enable measuring on non snapped locations.
Parameters
allow* boolean | true to allow measuring on non snapped locations, otherwise false; |
useLastViewport* boolean | override the free measurement’s viewport with a previously created measurement’s viewport. |
isFreeMeasureMode()
Checks whether measuring can be performed from non snapped locations.
Returns
type | description |
---|---|
boolean | true is users can measure from any location. |