Since the launch of our View & Data API technology, developers have been asking if it is possible to use the viewer offline.
For that reason Cyrille created the extract sample that allows you to upload your model to his website and it will let you download a package that contains all the files required for offline viewing.
I grabbed some of Cyrille's code and added it to the View & Data NPM Package, so it offers more flexibility to developers. It is so far exposing just a single method that allows you to download to a target directory on your server the whole directory structure and files required to load the model offline.
Here is what your node.js code may look like if you want to download a model knowing it's URN. You obviously have to use the same credentials that were used to upload and translate that model:
For offline viewing you need to run a local html server, then unzip the lmv-local/version.zip in your client lib folder and reference the css and viewer3d.js (or viewer3d.min.js for production):
1 <link rel="stylesheet" type="text/css" href="lib/lmv-local/v1.2.21/style.css?v=v1.2.21"> 2 <script src="lib/lmv-local/v1.2.21/viewer3D.min.js?v=v1.2.21"></script>
In your JavaScript, load an available viewable path obtained as output of the download:
1 //<div id="viewer-local"></div> in your html 2 3 var viewer = new Autodesk.Viewing.Private.GuiViewer3D( 4 document.getElementById('viewer-local')); 5 6 var options = { 7 docid: viewablePath[0].path, 8 env: 'Local' 9 }; 10 11 Autodesk.Viewing.Initializer (options, function () { 12 13 viewer.initialize(); 14 15 viewer.load(options.docid); 16 });Here is an example of directory structure and files downloaded for a simple model. If you deal with more complex models, the amount of files can be considerably larger:
Comments
You can follow this conversation by subscribing to the comment feed for this post.