autodesk-viewerautodesk

How to set default initialization tool in Autodesk Viewer when loading a model?


Upon initiating the model within the viewer (utilizing viewer version 7.95), the preset tool activated by default is the orbit tool, I want to alter this to the pan tool, just exec viewer.toolController.activateTool("pan") when loading a model could throw an error because toolController's not avaliable.


Solution

  • viewer.addEventListener(Autodesk.Viewing.GEOMETRY_LOADED_EVENT, async () => {
       viewer.toolController.activateTool("pan")
    })
    

    In my testing TOOLBAR_CREATED_EVENT didn't work, so we have to rely on GEOMETRY_LOADED_EVENT.