简体   繁体   中英

Default model & measurement units in Autodesk Forge Viewer3D

Is there any way to globally set measure units and precision in Viewer3D? We do following steps after extension is loaded:

onExtensionLoaded(e) {
    if (e.extensionId === 'Autodesk.Measure') {
        const ext = this.viewer.getExtension('Autodesk.Measure');
        ext.snapper.setSnapToPixel(true);
        ext.sharedMeasureConfig.units = 'm';
        ext.sharedMeasureConfig.precision = 3;
        ext.measureTool.setUnits('m');
    }
    ...
}

We are not successful with predefining measure unit in Calibration dialog to meters. Also call:

ext.calibrationTool.getCurrentUnits();

Returns inches.

After investigation we found this magic line of code, where the zero index in combobox is selected:

CalibrationPanel.js:

this.unitList = new avp.OptionDropDown("Unit type", this.tbody, unitNames, 0, null, { paddingLeft: 0, paddingRight: 15});

We have not found any way to globally set units in Viewer3D. Are we missing anything?

Thanks for help.

There is no global way to obtain the info. you wanted since the measure tool now is a viewer extension. So, please use the following functions instead:

  • For units: ext.getUnits()
  • For precision: ext.getPrecision()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM