Warm tip: This article is reproduced from stackoverflow.com, please click
autodesk-forge autodesk-model-derivative autodesk-viewer autodesk-data-management

Markups

发布于 2020-04-13 09:29:05

I am using markup extension to draw on my viewer, after drawing, on selection of markup event, can I get its center coordinates of current selection or any coordinates inside of it? if not, at least can I get dbId behind current selection?

Thanks in advance

Questioner
A DEv
Viewed
41
Eason Kang 2020-02-05 10:38

Yelp~ it's the case, and see also:

// Get the markup's position in browser pixel space. the (0,0) is top left
Markup#getClientPosition()
// Get the markup's bounding rect in browser pixel space.

Markup#getClientSize()
// get the markup's bounding rect in browser pixel space, including the stroke width

Markup#getBoundingRect()

BTW, to obtain dbId within the markup boundary, you can do this:

  1. Get markup's BoundingRect in browser's pixel space
  2. Convert coordinates of the rect's vertices into viewer's 3d space via Viewer3D#clientToWorld
  3. Do bounding box collision to find out intersected mesh for the dbId, see here for the example: https://forge.autodesk.com/blog/custom-window-selection-forge-viewer-simpler-extension