Reputation: 2621
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.
Upvotes: 0
Views: 226
Reputation: 5342
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.
Upvotes: 1