Displaying an SVF model in a browser

115 Views Asked by At

Use Design Automation API to convert SVF, I was able to get it to the OSS bucket as output.zip.

Continue using the token and documentId, like the attached HTML that can be executed currently. I would like to view the model in a browser. In addition, since the number of trials is large, I would like to do this without using the ModeDerivative API.

function initializeViewer() {
  const options = {
    env: "AutodeskProduction",
    api: "derivativeV2",
    accessToken: token,
  };

  Autodesk.Viewing.Initializer(options, function () {
    viewer = new Autodesk.Viewing.GuiViewer3D(
      document.getElementById("MyViewerDiv")
    );
    viewer.start();
    Autodesk.Viewing.Document.load(
      `urn:${documentId}`,
      function (doc) {
        const defaultModel = doc.getRoot().getDefaultGeometry();
        viewer.loadDocumentNode(doc, defaultModel);
      },
      function (err) {
        console.error(err);
      }
    );
  });
}

As documentId, documentId=base64Encode("urn:adsk.objects:os.object:mybucket/output.zip")

I tried that, but it didn't work. Does anything else need to be done?

3

There are 3 best solutions below

1
On

We are doing exactly this. We do SVF export using Inventor engine on FDA. That produces zip. Such a zip needs to be moved to the webserver and unarchived there to individual files so they can be server across the http to browser as forge viewer is serving them individually. You can see the setup here https://github.com/autodesk-platform-services/aps-configurator-inventor/blob/master/WebApplication/ClientApp/src/components/forgeView.js

application using it https://inventor-config-demo.autodesk.io/

1
On

To make viewer point to local SVF files (or self-hosted files), use this example:

https://gist.github.com/wallabyway/310bf82d32e3dca2647f66ec84ff4e08#file-index-html

basically point the Viewer to the .svf file, like this:

options = {
    env: "Local",
    isAEC: true,
    urn: "offline-svfs/1/svf/2021.svf"
};
viewer.start(options.urn, options);
1
On

I learned from GitHUb below that we can display an svf file by specifying it as a document. https://github.com/Autodesk-Forge/viewer-javascript-offline.sample We are able to display the svf, by specifying it in the html using the URL of the document through localhost.

var options = {
          'env' : 'Local',
          'document' : './shaver/0.svf'
      };

In the future, I would like to be able to display it from a cloud server instead of localhost. However, I will end this issue here.