Search code examples
autodesk-forgeautodesk-viewerautodesk

Possibility of opening an extension within another extension in Autodesk Forge


Is it possible to open a custom extension thorough another custom extension ?

I tried but I get issues at the time of "Autodesk.Viewing.UI.DockingPanel.call" not sure whether I have done it properly or it is possible at all .

My use case :

I need to create a report, which contains some additional data that needed to enter at runtime plus a screenshot of the current view.( for this i have one extension).

Above extension need to open through markup extension so I can add annotation and save the screenshot. Cheers

edit

is it possible to add a custom extension to a core extension as well ?

viewer.loadExtension("Autodesk.Viewing.MarkupsGui").then(function (extension_)
{
    viewer.loadExtension('CreateNcrExtension');
});

This actually doesn't work . No error but wont load as well


Solution

  • Loading extensions from another extension is common, and usually done in your extension's load method. The load and unload methods can be async, so you can do something like this:

    class MyAwesomeExtension extends Autodesk.Viewing.Extension {
        // ...
        async load() {
            await this.viewer.loadExtension('Autodesk.Viewing.MarkupsCore');
            return true;
        }
        // ...
    }