Search code examples
autodesk-forgeautodesk-viewerautodesk

How do I create a dashed line markup in the forge viewer?


Is there a way to set the style of a polyline markup to show as a dashed line in the Autodesk.Viewing.MarkupsCore extension of the forge viewer?

I tried to use markup.setStyle({ 'stroke-dasharray': "5,5" }) but that throws an undefined error.


Solution

  • Not sure about the built-in markups but you can definitely use a dashed line when defining your custom markup type. If you follow this tutorial, and the sample code that it links to, you can add the following line to your custom markup's updateStyle method:

    avemcu.setAttributeToMarkupSvg(shape, 'stroke-dasharray', '5,5');
    

    And you get something like this:

    enter image description here