Search code examples
autodesk-forgeforge

Autodesk forge viewer get AEC model data with svf path


We use Autodesk forge viewer with React js. We open model with path of saved svf.

I want to add AEC.LevelsExtension and AEC.MinimapExtension. It works correctly when i get Aec modelData with models urn, but i need to get it with svf path. Who can help me to find a solution how can i do it?

I open the model with this code

const Autodesk = window.Autodesk;
const options = {env: 'Local'};
const config3d = {
  extensions: ["Autodesk.AEC.LevelsExtension"],
};

const url = window.location.search;

const init_div = document.getElementById('init_div');
const viewer = new Autodesk.Viewing.Private.GuiViewer3D(init_div, config3d);
const svf_path = `/${url.replace('?', 'storage/').rece(/%20/g, ' ')}`;


Autodesk.Viewing.Initializer(options, () => {
  viewer.start(svf_path, options);
}); 

Solution

  • Please check this blog here https://forge.autodesk.com/blog/consume-aec-data-svfs-your-own-server. It shows a clear walk path, please have a try:

    1. Save the manifest of the model somewhere, and override the getItem function:

      Autodesk.Viewing.endpoint.getItemApi=(endpoint, derivativeUrn, api)=>{ return 'Your svf folder url'+decodeURIComponent( derivativeUrn.split('Resource')[1]) }

    2. Construct Document object yourself

      const viewerDocument = new Autodesk.Viewing.Document(manifestJsonObject);

    3. Call download AEC model data before loading model

      viewerDocument.downloadAecModelData();

    Afterward, you can use the AEC related extensions as usual.