Search code examples
autodesk-forge

Vertically aligned toolbar with some standard tool


is it possible to create a vertically aligned toolbar with some custom tools (for example measure tools) and remove them from the standard viewer toolbar?

TIA Alder


Solution

  • Yes, you can create another toolbar instance and make it vertical:

    const toolbar = new Autodesk.Viewing.UI.ToolBar('myCustomToolbar', { alignVertically: true });
    viewer.container.appendChild(toolbar.container);
    

    See this gist for more details.

    And you can also remove buttons from the standard toolbar using the Viewer API, for example:

    viewer.toolbar.getControl('modelTools').removeControl('toolbar-sectionTool');
    

    Of course, you have to know the IDs of the controls you want to remove. You can find those by inspecting the toolbar during runtime with commands like viewer.toolbar._controls or viewer.toolbar.getControl('foo')._controls.