简体   繁体   中英

Customizing Drawing tool in Autodesk Forge Viewer throws error

I am using the Autodesk Forge Viewer API to render the AutoCAD drawing files on the web page. It is working perfectly. Then I followed the below tutorial to provide markup/annotation support on the viewer.

https://developer.api.autodesk.com/viewingservice/v1/viewers/docs/tutorial-feature_markup.html

Though I am able to get different drawing tools to work as expected, the customizing the color of the markup is throwing an error.

vm.onColorChange = function (e) {

        var styleAttributes = ['stroke-color'];
        var nsu = Autodesk.Viewing.Extensions.Markups.Core.Utils;
        var styleObject = nsu.createStyle(styleAttributes, vm.markupsExtension.viewer);

        var selectedColor = $('#sel-colors').val();
        styleObject['stroke-color'] = selectedColor;

        vm.markupsExtension.setStyle(styleObject);
    };

When I debugged the code on the developer tool, the below line in the 'Markups.js' is throwing the error 'getStrokeWidth' is undefined.

在此处输入图片说明

I am using the Forge viewer version 6. Is there anything changed for customizing the drawing tool with the latest version of the viewer or is the tutorial still relevant for the current version.

The second argument to pass in to Markups.Core.Utils.createStyle should be the current active Markup tool object, not the Viewer itself:

var markupExt = Viewer.getExtension("Autodesk.Viewing.Markups ore");
var styleObj = Autodesk.Viewing.Extensions.Markups.Core.Utils.createStyle([...], markupExt)

That bit of the tutorial is incorrect and will be rectified soon.

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