Skip to content

Design Automation Sample in C#: C# sample to demonstrate custom Activities and AppPackages creation

License

Notifications You must be signed in to change notification settings

Autodesk-Forge/design.automation-.net-custom.activity.sample

Repository files navigation

Design Automation API for AutoCAD - Create custom Activity and AppBundle

.NET odata Design Automation visual studio License

Description

This is C# sample to demonstrate custom Activities and AppBundle creation. This is the most common use case that the Design Automation API can run the custom command (defined in the custom package) in the cloud. This sample uses v3, for the v2 sample, please check design.automation.v2 branch

Thumbnail

thumbnail

Industry Background

  • To batch extract layers list and blocks list from the AutoCAD drawing by web services, instead of running plugin in local AutoCAD.

Setup

Dependencies

  • Download and install Visual Studio. In the latest test, Visual Studio version is 2017.
  • Download and install AutoCAD SDK. In the latest test with this sample, AutoCAD version is 2018.

Prerequisites

  1. Forge Account: Learn how to create a Forge Account, activate subscription and create an app at this tutorial. Make sure to select the service Design Automation.
  2. Make a note with the credentials (client id and client secret) of the app.

Running locally

  1. Build project CrxApp. It is better to test with local AutoCAD to verify the process. Steps:
  • Open AutoCAD (in the latest test, the version of AutoCAD is 2018)
  • Open demo drawing. Run command "netload", select the binary dll of CrxApp. Allow AutoCAD to load it.
  • Run command "test", select demo json file. Specify a output folder.
  • Finally the blocks name list and layers name list will dumped out.
  1. Open project Client. Restore the packages of the project by NuGet. The simplest way is
  • VS2012: Projects tab >> Enable NuGet Package Restore. Then right click the project>>"Manage NuGet Packages for Solution" >> "Restore" (top right of dialog)
  • VS2013/VS2015/2017: right click the project>>"Manage NuGet Packages for Solution" >> "Restore" (top right of dialog)
  1. Put your Forge credentials into an appsettings.user.json like this
{
    "Forge": {
        "ClientId" : "<your client id>",
        "ClientSecret" : "<your client secret>"
    }
}
  1. Add your friendly name for your app.
  2. Replace the upload URL with your own.
  3. Run project Client, you will see a status in the console: thumbnail
  4. if everything works well, the result zip file and the report files will be downloaded to MyDocuments. In zip file, blocks list and layers list are available.
  5. if there is any error with the process of work item, check the report file what error is indicated.

Troubleshooting

  • if any problem when building the project CrxApp, check if the NET Framework of project is compatible with that of AutoCAD References. e.g. with AutoCAD 2018 references, the NET Framework is 4.6.1

Known Issues

  • as of writing, Design Automation of Forge is released with version 2. Odata is used with .NET project. In futher version, OData might not be used.

Further Reading

License

These samples are licensed under the terms of the MIT License. Please see the LICENSE file for full details.

##Written by

Jonathan Miao & Albert Szilvasy

About

Design Automation Sample in C#: C# sample to demonstrate custom Activities and AppPackages creation

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages