Adding a context menu command to objects in the Forge Viewer

I’ve been spending quite a bit of time working on our “Dasher 360” prototype, recently. Which is, of course, based on the Forge Viewer.

A simple – but handy – feature I added today is to add a context menu item to be displayed when objects are selected – and right-clicked – inside the Viewer. In my case I wanted to prototype a possible workflow for a “Send to HoloLens” capability: the feature itself isn’t ready (that’s what you might call an extreme understatement), but I thought I’d add the menu item in preparation for something being implemented.

Here’s a simple extension written in TypeScript that shows how you can add a context menu using the registerContextMenuCallback() method. The same approach will work just as well in JavaScript, of course.

/// <reference path=’../../../../../typings/lmv-client/lmv-client.d.ts’ />

 

export default class ContextMenuExtension extends Autodesk.Viewing.Extension {

  constructor(viewer:…

Read more

Leave a Comment