Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Has the ViewingApplication constructor been removed from the AD Viewer API?

After leaving my Autodesk extension alone for a few weeks, my initialization code is failing to create a ViewingApplication.

In my browser's js console, I can see that the Autodesk.Viewing object contains many objects, but it no longer contains any ViewingApplication. The Viewer API documentation still includes ViewingApplication.

Autodesk.Viewing.Initializer(options, function onInitialized(){
    viewerApp = new Autodesk.Viewing.ViewingApplication('MyViewerDiv');
    var config3d = {
      extensions: ['WharfExtension']
    };
    viewerApp.registerViewer(viewerApp.k3D, Autodesk.Viewing.Private.GuiViewer3D, config3d);
    var model = 'urn:' + defaultModel;
    viewerApp.loadDocument(model, onDocumentLoadSuccess, onDocumentLoadFailure);
});

My browser says, "Uncaught TypeError: Autodesk.Viewing.ViewingApplication is not a constructor," and I am inclined to agree?

EDIT: It works as expected from my coworker's machine, so apparently it is not a problem with the API. I am serving the page from a web server on my machine.

EDIT2: Solved. Thanks, Petr. I was including the new, non-backwards-compatible version of the API without realizing it. Autodesk describes how to create this behavior in the new version in their Migration Guide v6 to v7.

like image 695
PMuren Avatar asked Nov 17 '25 23:11

PMuren


1 Answers

The viewer team has recently released new major version which is not backwards compatible.

Make sure that you're importing the viewer3d.js/viewer3d.min.js file with the expected major version. For example, if you've built your application against version 6 APIs, you should be using the following script tag:

<script src="https://developer.api.autodesk.com/modelderivative/v2/viewers/6.*/viewer3D.min.js"></script>
like image 85
Petr Broz Avatar answered Nov 20 '25 14:11

Petr Broz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!