Authorisation and translation via console application: Command line tool demonstrating the authorisation and translation process using a Node.js console application
Note: For using this sample, you need a valid oAuth credential.
Visit this page for instructions to get on-board.
This sample exercises the Node.js engine as a command line utility to demonstrate the Forge OAuth application authorisation process and most of the Forge Services API such as Model Derivative, Bim360, Viewer, …
Demonstrates the use of the Autodesk Forge API using a Node.js console application. Supports both 2 legged and 3 legged protocols.
npm install
Set 2 environment variables FORGE_CLIENT_ID / FORGE_CLIENT_SECRET
Mac OSX/Linux (Terminal)
export FORGE_CLIENT_ID=<<YOUR FORGE CLIENT ID>>
export FORGE_CLIENT_SECRET=<<YOUR FORGE CLIENT SECRET>>
Windows (use Node.js command line from Start menu)
set FORGE_CLIENT_ID=<<YOUR FORGE CLIENT ID>>
set FORGE_CLIENT_SECRET=<<YOUR FORGE CLIENT SECRET>>
If you only want to use Model Derivative, Data Management/OSS, Design Automation, Reality Capture - you can stop here
Set an environment variable PORT (This is for running either BIM360 API or the Viewer)
Mac OSX/Linux (Terminal)
export PORT=<<YOUR PORT NUMBER>>
Windows (use Node.js command line from Start menu)
set PORT=<<YOUR PORT NUMBER>>
Windows (use Node.js command line from Start menu)
export FORGE_CALLBACK=<<YOUR FORGE CALLBACK URL>>
set FORGE_CALLBACK=<<YOUR FORGE CALLBACK URL>>
Note: If you do not want to set environement variables, edit the forge.js file and replace the placeholders by the values listed above.
The utility provides help information for the commands and arguments. Use the —help option to access it.
Here are few examples (click ► to expand):
bash
# Do authorization.
node forge.js 2legged
# Create a bucket. Bucket name must be lower case and valid characters.
node forge.js buckets-new my_bucket_name
# Upload a model.
node forge.js objects-put Au.obj
# Register the model to get it translated.
node forge.js objects-translate Au.obj
# Wait until the translation completes.
# Translation is complete when it reaches 'success - 100%'
node forge.js objects-progress Au.obj
# Create an HTML page with your URN and a read-only access token to view the SVF.
node forge.js html urn:adsk.objects:os.object:my_bucket_name/Au.obj ./bubbles/Au.obj.html
# Create an HTML page with your URN and a read-only access token to view the OTG version.
node forge.js html urn:adsk.objects:os.object:my_bucket_name/Au.obj ./bubbles/Au.obj.html --otg
# Start local server and load the HTML page.
open http://localhost:$PORT/Au.obj.html & http-server ./bubbles/
bash
# Do authorization/authentication.
node forge.js 3legged auto
# Get the list of Hubs.
node forge.js hubs
# Get the list of projects.
node forge.js projects $hubid
# Get the entire project data tree.
node forge.js projects-tree $hubid $projectid -f
# Refresh the access token
node forge.js 3legged-refresh
# Create an HTML page with your URN and a read-only access token to view the SVF.
node forge.js html $versionid ./bubbles/output.html
# Create an HTML page with your URN and a read-only access token to view the OTG version.
node forge.js html $versionid ./bubbles/output.html --otg
# Start local server and load the HTML page.
open http://localhost:$PORT/Au.obj.html & http-server ./bubbles/
Note your access token, bucket name and other information are saved in the data folder to be used as default values by the utility, but you can
edit them as you wish.
Forge provides a service to extract CAD design file information into what Autodesk engineers calls a Bubble. The SVF Bubble is a collection of files (pack files for mesh, images for tecxtures, json for manifest and metadata) and is the default output “format” for the Model Derivative API, and consumed by the Viewer.
Recently, the Autodesk engineers refined the process to make a lightweight Bubble for AEC/BIM outputs, called OTG. While it was designed for AEC/BIM, OTG would still work for our scenarios but not guarantee on the reduction ratio compared to SVF. The Viewer also supports OTG natively, and would nicely switch to OTG with no code change other than the initializer configuration.
OTG uses a de-duplication process of meshes. So think of a wall as a cube. And many walls are just a cube that is squished and rotated into place. So imagine all walls of a building represented by a single cube with many transforms. This saves storage space (data transfer). BUT…. It also significantly improves render performance, with GPU instancing. You send a single cube mesh to the GPU and thousands of tiny transforms as a single draw-call, thus drawing signicantly more triangles per frame.
Similar to the cube primative for walls, the same thing happens for Re-Bar and hand-rails, it’s mostly de-duplication of a ‘cylindrical primitive’.
OTG (centered at the origin) can theoretically measure a 20km stretch at 4.6 micron precision, which is just equivalent to the limit of 32 bit float precision. Currently, OTG uses a single double precision offset for each model.
Linear designs or geospatial models are yet to be validated with OTG. We are looking for feedback.
Documentation:
Tutorials:
Blogs:
OTG:
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