12 Feb 2020

Beginners guide to Design Automation with Visual Studio Code


This is a quick 'no code required' introduction to Design Automation.

We are going to walk through the process of converting a DWG with 5 sheets, into a single PDF, using Design Automation in the cloud.   We'll do it without any code, just your DWG file and 'Visual Studio Code' 

Once you've got the basics, you can do the same with your Revit, Inventor or Max files - Too Easy!


UPDATE:  Video recording from Virtual Accelerator:  Click Here


Who this is for:

- If you are a desktop plugin developer (for Autocad, Revit, etc), and don't want to deal with REST/HTTP 

- If you are a web-developer and don't have a Microsoft VStudio C# DLL plugin dev environment setup


...you still want to try out the fundamentals of Design Automation ! 

then read on ...



We will take a whiskey.DWG file and convert it to a result.PDF file, using Design Automation for AutoCad ... in the easiest way possible!  

We'll do it in four steps - here's a diagram...


The Design Automation service provides ten build-in recipe's ( we actually call them 'Shared Activities' ).  

They are 10 pre-build DLLs, sitting in the cloud, that you can use.  These DLLs perform a function on your DWG, RVT, FBX, Max, Inventor files, and output some special result.

One of those pre-build DLLs "AutoCAD.PlotToPDF+Prod", knows how to take a DWG file, and output a single PDF, containing all the DWG's sheets. 

We are going to try run it... with "no code", just Visual Studio Code and the Forge Plugin.  

Let's get started...

  • Install Visual Studio Code (VS-Code for short)
  • Add the extension plugin "Forge" (CTRL+SHIFT+P, select "install extension", search Forge)
  • Generate a Forge Key/Secret (make sure to add 'Model Derivative' and 'Design Automation' APIs )
  • Open the VS-Code settings.json file (CTRL+SHIFT+P, select "Open Settings") and add this json to it...
  • download this sample DWG "whiskey-drinks.dwg" from here:




The Four Steps

1. Upload 'whiskey-drinks.dwg' to one of your buckets

2. Create an empty destination file - say, 'Result.pdf', and get its signed URN.

3. Create a "new work item", fill in the fields and run it.

4. download the result.pdf and view it


Step 1: upload your input file


  • if you don't have any buckets, create one by clicking the + button (be careful, the name must be globally unique!)
  • right click your bucket, and select Upload Object
  • locate your local copy of the 'whisky-drinks.dwg' file and select it, to upload.

wait for the file to appear in the list



Step 2: Prepare your output file


  • right click on the same bucket, and select Create Empty Object
  • now type result.pdf in the "enter object Name" input field, select application/octet-stream
  • now, right click on result.pdf and select Generate Signed URL
  • choose readwrite
  • finally, click Copy URL to Clipboard and paste the destination URL in a blank text file somewhere safe.

You've now created an empty destination file, that Design Automation will PUT the PDF data into.


Step 3: Create and Run the Job


  • under the Design Automation left pane, expand "Shared Activities" and scroll to AutoCAD.PlotToPDF+Prod near the bottom
  • now, right click AutoCAD.PlotToPDF+Prod, and select 'Create WorkItem"
  • In the table, fill in the two URL fields with signed URLs generated from whiskey-drinks.dwg and result.pdf
  • Important: Change the Verb POST to a PUT, otherwise the job will fail (see above gif video)
  • Now, click the blue "Run" button, to kick off the job on Design Automation.

After a 5 seconds, you should get a Success message (Look for 'work item: succeeded').  If so... "wahoo", you did it !


Step 4: Download and view your shiny new PDF !

  • Right click on result.pdf and download to you local computer
  • Finally, double-click the pdf file to view the result.pdf

And here's the result:



You should see the PDF file containing the contents of our original DWG file. 


You have successfully deployed a DLL plugin, to Design Automation with your input DWG file, to get a result...

Well done!  

No need to create a DLL, or wrestle with Postman, thanks to Visual Studio Code and PetrBroz's awesome Forge Plugin.

For more details on the plugin, or any feature-requests, please check out the GitHub repo here: 


If you have idea's for other 'recipe's you would like to see listed in the public list, send your requests to the same place (for now).

Find us on twitter: @micbeale and @petrbroz


More advanced Examples:

Now that you've got the hang of it, why not try coding your own custom DLL, or maybe automate the HTTP requests in your own server.  Here are some next step guides from PetrBroz, that might help...

Design Automation with Visual Studio Blog posts:

Web Configurators:
- Sketch Walls: https://github.com/Autodesk-Forge/forge-sketchit-revit
- Resize Doors & Windows: https://github.com/Autodesk-Forge/forge-createfamily-revit

Lots More Samples:

Related Article