1

I am working on an app that needs to calculate measures like areas and length etc. Lucky today by using Autodesk Forge viewer we can do that. I had looked into this blog post [enter link description here][1] and as well to the docs [enter link description here][2] [1]: https://aps.autodesk.com/blog/fast-pdf-viewingmarkup-inside-forge-viewer [2]: https://aps.autodesk.com/en/docs/viewer/v7/reference/Extensions/MeasureExtension/

I am looking for a way to insert the measure values into my database, where I can view it again when I want or reload the page (not lose it) similarly with Markup with callouts and text.

Lastly, I am wondering about how much does it costs to translate the pdfs files using Forge?

thanks

Abed Aarabi
  • 51
  • 1
  • 5

1 Answers1

1

You can retrieve the array with objects related with the measurements done with the line:

NOP_VIEWER.getExtension('Autodesk.Measure').measureTool.getMeasurementList()

You can store the result in your DB, together with viewstate and additional info such as urn and viewable guide.

To restore it, you can first activate the tool

NOP_VIEWER.getExtension('Autodesk.Measure').activate()

Then set the measurement list using the values you read from the DB

NOP_VIEWER.getExtension('Autodesk.Measure').measureTool.setMeasurements(listMeasurements)

Where listMeasurements will be something like:

var listMeasurements = [
{
  angle: "0.0 °",
  arc: "0.0 mm",
  area: "0.0 mm²",
  deltaX: "1569.7 mm",
  deltaY: "6463.7 mm",
  deltaZ: "162.0 mm",
  distance: "6653.6 mm",
  from: "Vertex",
  location: "X: 0.0 mm\nY: 0.0 mm\nZ: 0.0 mm",
  picks: [
   {intersection: {x:43.5168342590332,y:-60.37924575805664,z: 8.858267784118652}, modelId: 2, viewportIndex2d: null, snapNode: 2587},
   {intersection: {x: 38.367037573210276,y: -39.17272345572108,z: 8.32677173614502}, modelId: 2, viewportIndex2d: null, snapNode: 3521}
  ],
  precision: 1,
  text: "",
  to: "Vertex",
  type: "Distance",
  unitType: "mm"
 }
]

Now, you can deactivate it with one line of code

NOP_VIEWER.getExtension('Autodesk.Measure').deactivate()
  • Instead of using NOP_VIEWER, refer to your viewer instance through the variable defined in your code
João Martins
  • 388
  • 3
  • 10
  • 1
    Thanks João, may I ask if Forge pdf viewer is FREE? As I know Forge Viewer has supported to load native PDF/DWG directly, without translation. Since it is native, ALSO I managed to load the locally without access token! – Abed Aarabi Feb 04 '23 at 10:07
  • Hey Abed, there's no charge for using Viewer library. The charge is for translating [supported formats](https://aps.autodesk.com/en/docs/model-derivative/v2/developers_guide/supported-translations/) into SVF(2) that Viewer uses. Just note that the viewer assets (JavaScript, CSS, images, etc.) cannot be downloaded and custom-served. We have local support for [PDF/DWF](https://aps.autodesk.com/blog/dwf-and-pdf-support-forge-viewer) and [GLTF](https://aps.autodesk.com/blog/gltf-20-support-forge-viewer) without translation – João Martins Feb 06 '23 at 12:38
  • Thank a lot, may I ask if there is any event for accessing the measure button in the viewer bar! I am using `Autodesk.Viewing.MeasureCommon.Events.etc..` to access the contents inner measure extension. Bur I couldn't fine event for the measurement bar button! – Abed Aarabi Feb 06 '23 at 13:22