'How can I upload a model to the viewer by refering to a file?
I initialize the viewer using this example https://forge.autodesk.com/en/docs/viewer/v7/developers_guide/viewer_basics/initialization/
But I do not load models immediately, only by an external event in the system (for example, pressing a button).
Question: how can I upload a model to the viewer by referring to a file (a local path or a path to my server) after initializing the viewer from the example?
Solution 1:[1]
As you can read in the next chapter, you must upload your files using DataManagement API and then translate them using ModelDerivative API to load them in the viewer : Load a model
If you want to load your models only after an external event, call the load function only when you want :
mybutton.addEventListener('click', ()=> {
Autodesk.Viewing.Document.load(documentId, onDocumentLoadSuccess, onDocumentLoadFailure);
})
Solution 2:[2]
I'd suggest that you look at the Simple Viewer tutorial. It guides you through the implementation of a simple Forge app where you can upload/translate/view designs during runtime.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | AlexAR |
Solution 2 | Petr Broz |