0

I have downloaded the content of .svf file using https://github.com/petrbroz/forge-convert-utils to my local machine. then I am trying to load the .svf file to forge viewer in this way.

const MODEL_URL = './models/model1/output.svf';
Autodesk.Viewing.Initializer({ env: 'Local' }, async function () {
const viewer = new Autodesk.Viewing.GuiViewer3D(document.getElementById('preview'));
viewer.start(MODEL_URL);
});

async function download() {
        debugger;
        await fetch('/api/download');
    }
download()

The models folder is in the root folder. I am getting a popup msg like this. enter image description here

What is the reason for this? And how can I overcome this? Thanks, in advance.

Randi
  • 639
  • 2
  • 6
  • 23

1 Answers1

0

Note that based on your code snippet, the models folder should be placed in the same folder as the HTML page, for example:

node_modules/
wwwroot/
    models/
        model1/
            ...
            output.svf
    index.html
server.js

Here's a simple HTML page that will work with the folder structure above:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="https://developer.api.autodesk.com/modelderivative/v2/viewers/7.*/style.css">
    <script src="https://developer.api.autodesk.com/modelderivative/v2/viewers/7.*/viewer3D.js"></script>
    <style>
        body { margin: 0 }
        #preview { position: absolute; inset: 0; }
    </style>
</head>

<body>
    <div id="preview"></div>
    <script>
        Autodesk.Viewing.Initializer({ env: 'Local' }, function () {
            const viewer = new Autodesk.Viewing.GuiViewer3D(document.getElementById('preview'));
            viewer.start('./models/model1/output.svf');
        });
    </script>
</body>

</html>
Petr Broz
  • 8,891
  • 2
  • 15
  • 24
  • This worked fine with Android Assets folder. I copied Models folder and html file into android internal storage from Asset folder but getting this error [chromium] [INFO:CONSOLE(67256)] "Error while processing SVF: {"url":"file:///storage/emulated/0/Android/data/com.companyname.testautodeskforge/files/Models/Model1/Content/output.svf","httpStatus":0,"httpStatusText":"","data":{"url":"file:///storage/emulated/0/Android/data/com.companyname.testautodeskforge/files/Models/Model1/Content/output.svf"}}", source: https://developer.api.autodesk.com/modelderivative/v2/viewers/7.*/viewer3D.js (67256) – Randi Mar 07 '23 at 10:46
  • That error isn't saying much unfortunately. Can you confirm whether the SVF URL (`file:///storage/emulated/0/Android/data/com.companyname.testautodeskforge/files/Models/Model1/Content/output.svf`) is in fact accessible from your app? – Petr Broz Mar 07 '23 at 15:53
  • It is acessible from the app. I tried like this FileInputStream fIS = new FileInputStream(new File(System.IO.Path.Combine(Application.Context.GetExternalFilesDir("").AbsolutePath, "Models", "Model1/Content/output.svf"))); System.Console.WriteLine("Input stream-----------------------" + fIS.Available()); And it returned 2700 bytes. – Randi Mar 10 '23 at 12:33
  • Please note that the `viewer.loadModel` method relies on the SVF file being accessible via HTTP. Instead of using `FileInputStream`, check whether the SVF file is accessible using an HTTP client. – Petr Broz Mar 10 '23 at 13:12
  • I am using `viewer.start` not `viewer.loadModel` – Randi Mar 13 '23 at 02:44
  • Same thing. `viewer.start` just calls `viewer.loadModel` internally. – Petr Broz Mar 14 '23 at 09:36