Note: For using this sample, you need a valid oAuth credential for the translation / extraction portion. Visit this page for instructions to get on-board.
The extract.autodesk.io server exercises and demonstrates the Autodesk Forge API authorization, translation, viewing processes mentioned in the Quick Start guide. It also demonstrates how to extract the 'bubbles' files from the Autodesk server for storing and viewing them locally.
In order to make use of this sample, you need to register your consumer and secret keys:
- https://developer.autodesk.com > My Apps
This provides the credentials to supply to the http requests to the Autodesk server endpoints.
This sample is dependent on the server part on Node.js and couple of Node.js extensions which would update/install automatically via 'npm':
This sample is dependent of Node.js and few Node.js extensions which would update/install automatically via 'npm'.
- Node.js - built on Chrome's JavaScript runtime for easily building fast, scalable network applications. You can get Node.js from here
This sample is also dependent on the client side on couple of javascript library which would update/install automatically via 'bower':
-
flow.js - A JavaScript library providing multiple simultaneous, stable, fault-tolerant and resumable/restartable file uploads via the HTML5 File API.
-
Bootstrap - Bootstrap is the most popular HTML, CSS, and JS framework for developing responsive, mobile first projects on the web.
-
Download and install Node.js (that will install npm as well)
-
Download this repo anywhere you want (the server will need to write files, so make sure you install in a location where you have write permission, at least the 'tmp', 'data' and '/www/extracted' folders)
-
Execute 'npm install', this command will download and install the required node modules automatically for you.
npm install
-
Install your credential keys:
Use system environment variables (This is actually the option you need to use for the tests suite which runs on Travis-CI). Replace keys placeholder xxx with your own keys.* Windows<br /> ``` set FORGE_CLIENT_ID=xxx set FORGE_CLIENT_SECRET=xxx [set PORT=<port>] node start.js ``` * OSX/Linux<br /> ``` [sudo] [PORT=<port>] FORGE_CLIENT_ID=xxx FORGE_CLIENT_SECRET=xxx node start.js ```
Note: the port argument can be omitted and default to port 80. If port 80 is already in use by another application (like Skype, or IIS, or Apache, ...), you can use any other free port such as 8000, 3000, etc... But in the next section you would need to specify the port to use, i.e. http://localhost[:port]/ -
There is an issue in the FORGE SDK which needs to be fixed - in the meantime, please do teh following:
After npm install, go to /node_modules/forge-apis/src/
https://github.com/Autodesk-Forge/forge-api-nodejs-client/blob/master/src/ApiClient.js#L350
and change code like this:if (accepts.length > 0) { headers['Accept'] = accepts.join(','); for ( var i =0 ; i < accepts.length ; i++ ) { if ( accepts [i] === 'application/octet-stream' ) requestParams.encoding = null; } } if ( headerParams ['Accept-Encoding'] == 'gzip, deflate' ) requestParams.encoding = null; _this.debug('request params were', requestParams);
Translating files / Extracting 'bubbles'
- Start your favorite browser supporting HTML5 and WEBGL and browse to http://localhost/.
Note: In case you use a different port above do not forget to include it in the URL. I.e. http://localhost:3000/. - Drag'n Drop your files into the 'Drop area' or browse for individual files or grab files for your dropbox, box or google drive account. Tips: start with the main file in your file has dependencies.
- Select the master file. The master is the file that Forge will load to trigger translation.
- Once all files are uploaded on your local server, press the 'Submit my project' button to translate your file(s).
- After the translation completed successfully, move your mouse over the project thumbnail at the bottom of the page ('View submitted Projects' tab) and press the 'Explore' button.
- On the new page, you should review your model and if you're happy with what you see, you can request to download the 'bubbles' from the server. Sometimes the process can take a long time, so you can register to be notified by email when the process completed and get a direct link on the resulting zip file.
- This step needs to be done only once per machine. Setup Node.js http-server server.
npm install http-server -g
- Unzip the project zip file into a folder.
- Execute the index.bat or ./index depending of your OS, or follow instructions below
a. Start your local node http-server server.
b. Start your favorite browser supporting HTML5 and WEBGL and browse to http://localhost:8080/[sudo] http-server <myfolder>
- This step needs to be done only once per machine. Download and install PHP 5.4+ on your computer.
- Unzip the project zip file into a folder.
- Start your local PHP http server.
cd <myfolder> php -S localhost:8000
- Start your favorite browser supporting HTML5 and WEBGL and browse to http://localhost:8000/
- This step needs to be done only once per machine. Download and install Python on your computer.
- Unzip the project zip file into a folder.
- Start your local Python http server.
cd <myfolder> # with Python 2.x python -m SimpleHTTPServer # with Python 3.x+ python -m http-server
- Start your favorite browser supporting HTML5 and WEBGL and browse to http://localhost:8000/
- This step needs to be done only once per machine. Download and install Ruby on your computer.
- Unzip the project zip file into a folder.
- Start your local Ruby http server.
cd <myfolder> ruby -r webrick -e "s = WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => Dir.pwd); trap('INT') { s.shutdown }; s.start"
- Start your favorite browser supporting HTML5 and WEBGL and browse to http://localhost:8000/
On Windows only: simply copy the Python directory on your CD, and launch the server via a script when your application wants to show a LMV result. Make sure to set the PATH to point to your CD Python location to avoid errors. On OSX, Linux: Python is already installed, so you can use the default Python on these OS.
Usage:
cd <my sample directory>
python -m SimpleHTTPServer [port]
On all platform you may install the http-server utility. http-server is a simple, zero-configuration command-line http server. It is powerful enough for production usage, but it's simple and hackable enough to be used for testing, local development, and learning.
To install http-server, go on your node.js console and enter the following command:
npm install http-server -g
Usage:
cd <my sample directory>
http-server [path] [options]
[path] defaults to ./public if the folder exists, and ./ otherwise.
This sample is licensed under the terms of the MIT License. Please see the LICENSE file for full details.
Cyrille Fauvel
Forge Partner Development
http://developer.autodesk.com/
http://around-the-corner.typepad.com