Search code examples
autodesk-forgeautodeskforgeautodesk-viewer

Error in add measure core extension in the viewer


I tried add the measure extension in my viewer and it broke.Javascript error image

Others extensions works as well but only measure broke... Extensions declarations image


Solution

  • This error means that the extension expects a model to be loaded, so you should use the Autodesk.Viewing.OBJECT_TREE_CREATED_EVENT and call viewer.loadExtension('Autodesk.Measure') in your event handler. Take a look at this blog post for more details about viewer events.

    By the way I would recommend not to use the ViewingApplication but directly the Viewer, as described in the Basic Viewer tutorial. The ViewingApplication uses the same API is the background but encapsulate the Viewer and is less explicit. Also it will attempts to load all extensions at start, which may cause issue like the one you are facing.

    The measure extension is loaded by default on my side, so why is it that you want to explicitly load it yourself?