简体   繁体   中英

Cannot load SVF2 model in Autodesk Forge Viewer

I just tried out the SVF2 public beta but couldn't get the model to load in the Viewer. I believe the model was translated successfully since the manifest returned has:

"name": "XXXX_ARC.nwd",
"progress": "complete",
"outputType": "svf2",
"status": "success"

However, when I tried to load the model in Viewer, it would fail on this line:

theViewer.loadModel(svfURL, onItemLoadSuccess, onItemLoadFail);

The svfURL is something like this:

https://cdn.derivative.autodesk.com/modeldata/file/urn:adsk.fluent:fs.file:autodesk-360-translation-storage-prod/*MyURN*/output/otg_files/0/output/0/otg_model.json

And the errors I got from Chrome browser: 403 GET errors . Seems like I don't have privilege to access the model?

Is there some additional setting I need to do?

Additional Info:
I have setup the Viewer environment as follows:

var options = {
    env: 'MD20ProdUS',
    api: 'D3S',
    getAccessToken: getForgeToken
};

var documentId = 'urn:' + urn;

Autodesk.Viewing.Initializer(options, function onInitialized() {
    var htmlDiv = document.getElementById('forgeViewer');
    var config3d = {
      extensions: ['ToolbarExtension', 'HandleSelectionExtension', .....a few extensions ],
      loaderExtensions: { svf: "Autodesk.MemoryLimited" }
    };
    
    theViewer = new Autodesk.Viewing.GuiViewer3D(htmlDiv, config3d);
    var startedCode = theViewer.start();
    if (startedCode > 0) {
        console.error('Failed to create a Viewer: WebGL not supported.');
        return;
    }
    Autodesk.Viewing.Document.load(documentId, onDocumentLoadSuccess, onDocumentLoadFailure);
});

I have also tried removing the config3d when creating the viewer but it still returned the same messages. The code got into onDocumentLoadSuccess but failed at theViewer.loadModel(svfURL, onItemLoadSuccess, onItemLoadFail); , jumping into onItemLoadFail .

Because you mention mainly the viewer not loading the SVF2, I can suspect that maybe you have not specified the correct Viewer environment.

Here is some sample code, and pay attention to the options where you have to set env and API:

 var viewer; var options = { // These are the SVF2 viewing settings during public beta env: 'MD20ProdUS', // or MD20ProdEU (for EMEA) api: 'D3S', getAccessToken: getForgeToken }; var documentId = 'urn:' + getUrlParameter('urn'); // Run this when the page is loaded Autodesk.Viewing.Initializer(options, function onInitialized() { // Find the element where the 3d viewer will live. var htmlElement = document.getElementById('MyViewerDiv'); if (htmlElement) { // Create and start the viewer in that element viewer = new Autodesk.Viewing.GuiViewer3D(htmlElement); viewer.start(); // Load the document into the viewer. Autodesk.Viewing.Document.load(documentId, onDocumentLoadSuccess, onDocumentLoadFailure); } });

I am facing the same problem.

  1. Although the model has been converted to SVF2 format, my cloud credits are being used up . An excerpt from the manifest:

     "name": "7085-33cc-9464.rvt", "progress": "complete", "outputType": "svf2", "status": "success"
  2. No matter with which settings, only the SVF format is loaded in the viewer. I don't get an error message from the viewer, everything works as before, except that SVF is still loaded and not SVF2. Viewer init options:

     const viewerEnv = await this.initialize({ //env: dbModel.env, env: "MD20ProdEU", api: "D3S", //accessToken: "", });

Not sure if this has been solved on a separate thread, but the issue was probably that acmSessionId was not set in the options for loadModel() - seehttps://forge.autodesk.com/blog/403-error-when-trying-view-svf2

function onDocumentLoadSuccess(doc) {
  let items = doc.getRoot().search({
    'type': 'geometry',
    'role': '3d'
  }, true)

  let url = doc.getViewablePath(items[0])

  viewer.loadModel(url, { acmSessionId: doc.getAcmSessionId(url) })
}

The best thing is to just use loadDocumentNode() instead of loadModel()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM