0

I referenced http://autodeskviewer.com/viewers/latest/docs/tutorial-feature_markup.html , Philippe leefsma and Augusto tutorials. There is some difficulty in implementing style attributes in markup. Could you suggest on fixing it. enter image description here

moonwalker7
  • 1,122
  • 3
  • 11
  • 29
nishan
  • 1
  • 2
  • Which version of the viewer and markup are you using? Augusto's tutorial is only working for viewer built-in markups after v2.16 viewer. If you're still using the old version markups in this blog (https://forge.autodesk.com/cloud_and_mobile/2016/02/playing-with-the-new-view-data-markup-api.html), please replace it by the built-in one. – Eason Kang Oct 05 '17 at 05:17
  • The extension is loaded as viewer.loadExtension('Autodesk.Viewing.MarkupsCore').then(function(markupsExt){ markup = markupsExt; }); I could draw shapes and switch tools but I could not figure out changing style attributes. I referred to this https://developer.api.autodesk.com/viewingservice/v1/viewers/docs/tutorial-feature_markup.html Please suggest anything to change style attributes – nishan Oct 05 '17 at 09:32
  • Please check your viewer version is correct via typing `LMV_VIEWER_VERSION`. If you're using the right version of Viewer and Markups, there should be no issue to change markup styles. – Eason Kang Oct 05 '17 at 10:19
  • Many thanks for the prompt reply. You folks were very helpful :) – nishan Oct 05 '17 at 12:15
  • To create a new style for svg element, I used utils of markup. `var nsu = Autodesk.Viewing.Extensions.Markups.Core.Utils;nsu.createStyle(['fill'],markup.viewer);` Am I doing correct else is there alternative to create new style for markup – nishan Oct 13 '17 at 05:29
  • I have updated my answer below. Please check it, thanks. – Eason Kang Oct 16 '17 at 04:09

2 Answers2

3

Please accept our sincere apologies for the delay, we have a backlog in the queue.

I found there something changed in the MarkupCore shipped with the recent viewer. This documentation http://autodeskviewer.com/viewers/latest/docs/tutorial-feature_markup.html you're looking is too old to reflect those changes. Plase use following code snippet:

// Confiurate styles
var styleAttributes = ['stroke-width', 'stroke-color', 'stroke-opacity'];
var nsu = Autodesk.Viewing.Extensions.Markups.Core.Utils;
var styleObject = nsu.createStyle(styleAttributes, markupExt);
styleObject['stroke-width'] = 10;

// Set style up
markupExt.setStyle(styleObject);

The 2nd parameter of the createStyle is the loaded instance of the MarkupCore extension, it's not viewer anymore. Hope it helps.

Eason Kang
  • 6,155
  • 1
  • 7
  • 24
0

Take a look at my latest sample. The source code is available at Viewing.Extension.Markup2D and the live demo is here. No issue to change markup styles.

Felipe
  • 4,325
  • 1
  • 14
  • 19
  • I appreciate your quick reply. I suppose that should suffice my requirement. let me fix and update. Thanks a lot! :) – nishan Oct 05 '17 at 12:12
  • To create a new style for svg element, I used utils of markup. `var nsu = Autodesk.Viewing.Extensions.Markups.Core.Utils;nsu.createSty‌​le(['fill'],markup.v‌​iewer);` Am I doing correct else is there alternative to create new style for markup – nishan Oct 13 '17 at 06:30
  • the source code is not available anymore, can you give a look? – Guilherme Flores Oct 20 '20 at 14:20
  • I'm not working as adsk advocate anymore, most likely no one else will answer your comment. Also that code is now deprecated, if you use the current version of the viewer you will have to rework it, alternatively contact adsk support so someone else can dig it for you ;) good luck – Felipe Oct 20 '20 at 14:32