13 Sep 2019

Forge ♥ Visual Studio Code

Forge Tools for Visual Studio Code

Forge services can be accessed in various different ways: from your own code, using 3rd party HTTP clients, or via custom web front-ends (like https://oss-manager.autodesk.io or https://da-manager.autodesk.io). Now, if you're a fan of Visual Studio Code like myself, you can access Forge directly from your IDE!

Setting Things Up

It's probably not a big surprise that we're gonna need Visual Studio Code. If you don't have it installed, head over to https://code.visualstudio.com and get the latest stable build from there.

In Visual Studio Code, switch to the Extensions sidebar (Shift+Command+X or Ctrl+Shift+X), search for our extension - Autodesk Forge Tools - and install it.

Installing the extension

On certain platforms you may be asked to reload Visual Studio Code after the extension has been installed. Make sure to do that before moving to the next part.

In order for the extension to be able to access Forge, it needs to have at least one set of Forge application credentials. If you don't have one yet, check out this tutorial: https://forge.autodesk.com/en/docs/oauth/v2/tutorials/create-app. The extension can be configured with one or more "Forge Environments", where each environment defines a title, client ID, client secret, and a region ("US" or "EMEA") to be used for all Forge calls. In Visual Studio Code, open the extension settings, add a new JSON property called autodesk.forge.environments, and set it to an array of one or more JSON objects, each with properties title, clientId, clientSecret, and region. Btw. the editor provides auto-complete for all settings, so don't be afraid to make use of it!

Configure the extension.

And we're done! Now, when you click the Forge icon in the sidebar, you should be presented with your Data Management buckets and objects (if you have any), Design Automation bundles, activities, etc. Also, if you've configured more than one Forge environment, you can switch between them using the status bar at the bottom.

Browsing the Forge content.

If you're getting an error when listing app bundles or activities, make sure that the Forge application credentials you're using has access to the Design Automation v3 APIs.

"Data & Derivatives" Tree

The first tree in the Forge sidebar panel is called Data & Derivatives, and it helps you navigate and manipulate your buckets, objects, and their derivatives. Most of the available operations are accessible either by right-clicking individual nodes in the tree, or from the "command palette" (Cmd+Shift+P or Ctrl+Shift+P). Here's a couple of examples of what you can do:

  • Create new bucket, either by clicking the plus sign next to the Data & Derivatives title, or by calling the "Create Bucket" command
  • Upload new file, either by right-clicking a bucket and choosing "Upload Object", or by calling the "Upload Object" command
    • Note: the upload is resumable - if it fails or gets cancelled, you can upload the file later, and -  assuming that the bucket name, object name, and file content is still the same - the upload will resume from where you left off
  • Translate an object for viewing on the web (and inside Visual Studio Code) by right-clicking its tree object and choosing "Translate Object"
    • Note: if the object is already translated, you can use this action to force the conversion process again (for example, when you upload a new version of the same model with the same name)
  • Preview 2D/3D derivative in a new tab within Visual Studio Code
  • View scene tree or properties of derivatives
  • Delete/copy/rename objects
  • Generate signed URLs

"Design Automation" Tree

The second tree in the Forge sidebar panel is called Design Automation, and it gives you access to Design Automation v3 app bundles and activities, both your own and those shared with everyone. As with the data & derivatives, all the relevant operations are available either by right-clicking individual tree nodes, or by typing in command names in the command palette. Note that the command palette supports "fuzzy search" which means that you can type in "upd bun" and the palette will narrow down the list of available commands to "Forge Design Automation: Update App Bundle" and "Forge Design Automation: Update App Bundle Alias". Here's a couple of examples of commands you have at your disposal:

  • Create a new app bundle by right-clicking the "Owned App Bundles" node and choosing "Create App Bundle"
  • Create a new app bundle version by right-clicking on an existing app bundle and choosing "Update App Bundle"
  • Create app bundle aliases and link them to specific versions
  • Create a new activity by right-clicking the "Owned Activities" node and choosing "Create Activity"
    • In this case, a new Visual Studio Code tab will open with a form with all required fields for the activity, and also pre-populating dropdowns with available engines, app bundles, etc.
  • Create a new activity version by right-clicking an existing activity and choosing "Update Activity"
  • Start a new work item


If you run into any problems with the extension, or if you're missing a feature you can't live without, let us know! Either drop us a note on the marketplace page, or even better, report an issue, feature request, or submit a pull request to the github repo.

Related Article