Skip to content

mpospisil/workflow-node.js-view.and.data.api

 
 

Repository files navigation

Note: This repo is also used by our tutorial material. If you are following instructions from our tutorial, please ignore the instructions below.

Autodesk View and Data API Node.js Basic Sample

build status

Description

This sample demonstrates how to view a model in a web application with the Autodesk View & Data API. This web application implements a basic Node.js server and JavaScript/HTML5 client. It does not demonstrate how to upload a model to the Autodesk server for translation. See instructions below on how to prepare a model to be consumed in this sample.

Dependencies

Install Node.js on your machine and clone this repo. Download the project dependencies using npm before launching the app by running the following command in the project root directory:

npm install

This will install the following node.js modules in the project:

  • express
  • request
  • serve-favicon

As said, this sample does not include the workflow of uploading models to the server. It depends on other workflow samples to upload models and retrieve the model URNs, as explained in the Setup/Usage Instructions.

Setup/Usage Instructions

  • Apply for your own credentials (API keys) from developer.autodesk.com
  • From the sample root folder, rename or copy the ./credentials_.js file into ./credentials.js
    • Windows
      copy credentials_.js credentials.js 
      
    • OSX/Linux
      cp credentials_.js credentials.js  
      
  • Replace the placeholders with your own keys in credentials.js, line #23 and #24
    client_id: process.env.CONSUMERKEY || '<replace with your consumer key>',
    
    client_secret: process.env.CONSUMERSECRET || '<replace with your consumer secret>',
    
  • Upload one of your models to your account and get its URN using another workflow sample, for example:
  • Copy the URN which was generated in the previous step in file /www/index.js at line #18
    Note: the URN needs to be base64 encoded as mentioned here under "Step 6: Register Your Data with the Viewing Services"
    var defaultUrn = '<replace with your encoded urn>';
    
  • Run the server from the Node.js console, by running the following command:
    node server.js
    
  • Connect to you local server using a WebGL-compatible browser: http://localhost:3000/

This sample can also work with the Autodesk staging server (vs. production) or using someone else's credentials as long you can get a valid token. By default, the project is setup with the production server, and use your own credentials. If you are interested in a different setup, see the Options below.

Options

You can work with production or staging Autodesk View and Data environments. By default, the project is set up with the production server.

  • Instructions to setup this sample to use the Autodesk View & Data staging server are here

You can also use someone else's credentials to view models using this sample.

  • Instructions to set up this sample using someone else's credentials are available here

License

That samples are licensed under the terms of the MIT License. Please see the LICENSE file for full details.

Written by

Written by Philippe Leefsma, Autodesk Developer Network.

About

A demo with the usage of viewer client in Node.JS

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 82.0%
  • HTML 18.0%