Request

Response

    Autodesk.Viewing.Extensions
    Version 8 preview
    This page documents a preview of the Viewer SDK v8. APIs and content can still change before the final release.

    MeasureExtension

    Provides UI controls to perform distance and angle measurements for 2D and 3D models.

    The extension id is: Autodesk.Measure

    Examples

    viewer.loadExtension('Autodesk.Measure')
    

    Methods

    Load the measure extension.

    Returns

    typedescription
    boolean True if measure extension is loaded successfully.

    unload()

    Unload the measure extension.

    Returns

    typedescription
    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”, “sft”, “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

    typedescription
    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”, “sft”, “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

    typedescription
    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
    * Required

    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

    typedescription
    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.
    * Required

    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.
    * Required

    isFreeMeasureMode()

    Checks whether measuring can be performed from non snapped locations.

    Returns

    typedescription
    boolean true is users can measure from any location.