Summary:

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

But

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

then read on ...

 

Introduction:

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...

diagram-four-steps

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...
{
    "autodesk.forge.environments":[
        {"title":"#DA4CAD",
        "clientId":"123xxxxxxxxxABC",
        "clientSecret":"876xxxXYZ",
        "region":"US"
        }
    ],
}
  • download this sample DWG "whiskey-drinks.dwg" from here:

https://autodesk.blogs.com/between_the_lines/2016/04/engineers-guide-to-drinks-in-3d-dwg.html 

 

Now..

The Four Steps

1. Upload 'whiskey-drinks.dwg' to folder 'autocadtest'

2. Create an empty destination file - say, 'Result.pdf', and get it's 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

uploadFile

  • create a new bucket called "autocadtest", by clicking the + button, and name it.
  • right click your new autocadtest folder, 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

make-empty

  • right click autocadtest -> 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

runjob

  • 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:

result-pdf

 

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: 

https://github.com/petrbroz/vscode-forge-tools

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:
https://forge.autodesk.com/blog/forge-visual-studio-code
https://forge.autodesk.com/blog/simple-introduction-design-automation-inventor
https://forge.autodesk.com/blog/deploying-design-automation-visual-studio

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:
https://forge.autodesk.com/en/docs/design-automation/v3/code_samples/code_samples/ 

Posted by

Michael Beale

Autodesk

Michael Beale works for Autodesk Cloud Rendering team and focuses on client/server mashups that make the web-browser appear super-powered.  Starting with Autodesk Homestyler, then LMV-viewer, Prooflab and more recently a Stereo-Panorama service with webVR.

Developer Advocate, Autodesk

Petr is a senior developer advocate at Autodesk. He has been developing some of the company’s web applications and services since 2011, and now he aims to help others build amazing, creative solutions using these tools, especially using Autodesk Forge APIs. Petr’s technical focus areas include everything around web and cloud, 3D graphics, and all kinds of "non-real reality".

Related Posts