2

There are some tool button avalible in navigation toolbar Forge viewer. So I want hide only "zoom tool" button and "first person tool" button from the tool bar.

I am able to remove zoom tool button from the tool bar using below code :

var navTool = this.viewer.toolbar.getControl('navTools'); navTool.removeControl('toolbar-zoomTool');

But I am not able to remove "First Person" tool button from the navigation tool bar.

Can anyone help me on this problem?

  • Have you tried `navTool.removeControl('toolbar-firstPersonTool')`?? – Eason Kang Mar 18 '18 at 07:01
  • You probably need to listen to Autodesk.Viewing.EXTENSION_LOADED_EVENT and wait for the right extension to load and create that control before being able to actually remove it. – Felipe Mar 19 '18 at 11:57
  • Thanks! I handled " Autodesk.Viewing.EXTENSION_LOADED_EVENT" and removed 'toolbar-firstPersonTool' from toolbar. Now It is working. – Amit Mandal Mar 19 '18 at 15:08

1 Answers1

6

Here is a more accurate answer on how to remove that specific control:

const onExtensionLoaded = (e) => {

  if (e.extensionId === 'Autodesk.BimWalk') {

    const navTools = viewer.toolbar.getControl('navTools')

    navTools.removeControl('toolbar-bimWalkTool')

    viewer.removeEventListener(
      Autodesk.Viewing.EXTENSION_LOADED_EVENT,
      onExtensionLoaded)
  }
}

viewer.addEventListener(
  Autodesk.Viewing.EXTENSION_LOADED_EVENT,
  onExtensionLoaded)

viewer.start()
Felipe
  • 4,325
  • 1
  • 14
  • 19
  • 1
    This answer works, but now the extension id has been changed to 'Autodesk.BimWalk' and the control to 'toolbar-bimWalkTool'. – AN00 Aug 27 '20 at 10:21