.NET SDK for Design Automation v3 API, for more information, please visit official documentation
For clients with straightforward needs one high level API client is provided in DesignAutomationClient. For clients with more varied needs the following low level API classes are provided: ActivitiesApi, AppBundlesApi, EnginesApi, ForgeAppsApi, HealthApi, SharesApi, WorkItemsApi.
- .NET 8 or later
- A registered app on the Forge Developer Portal.
- Autodesk.Forge.Core assembly which provides services such as:
- Acquisition of 2 legged oauth token (and refreshing it when it expires)
- Preconfigurated resiliency patterns (e.g. retry) using Polly
The change log for the SDK can be found here.
Contributions are welcome! Please open a Pull Request.
Please ask questions on StackOverflow with tag autodesk-designautomation
tag. If it turns out that you may have found a bug, please open an issue
To use the API you must instantiate one of the API classes and configure it with the valid forge credentials. You can do this in 2 ways:
- By using dependency injection and configuration providers (PREFERRED)
- By directly creating instances of one of API classes and the Autodesk.Forge.Core.ForgeConfiguration class and setting is properites
There are 2 classes that you can use to configure the API:
-
Autodesk.Forge.Core.ForgeConfiguration - Allows the configuration of Forge client credentials and alternative authentication service endpoint (default is https://developer.api.autodesk.com/authentication/v2/token)
-
Autodesk.Forge.DesignAutomation.Configuration- Allows the configuration of non-default API endpoint (default is https://developer.api.autodesk.com/da/us-east/).
This SDK integrates with the .netcore configuration system. You can configure the above values via any configuration provider (e.g. appsettings.json
or environment variables).
For example to set the Forge credentials you could define the following environment variables:
Forge__ClientId=<your client id>
Forge__ClientSecret=<your client secret>
or the following in your appsettings.json
:
{
"Forge": {
"ClientId" : "<your client id>",
"ClientSecret" : "<your client secret>"
}
}
or using environment variables with ForgeAlternativeConfigurationExtensions
:
FORGE_CLIENT_ID=<your client id>
FORGE_CLIENT_SECRET=<your client secret>
Starting with version 4.3 you can also configure multiple ClientId/ClientSecret pairs as follows:
{
"Forge": {
"ClientId": "<default clientId>"
"ClientSecret" : "<default clientSecret>"
"Agents": {
"agent1": {
"ClientId": "<clientId of agent1>"
"ClientSecret" : "<clientSecret of agent1>"
},
"agent2": {
"ClientId": "<clientId of agent2>"
"ClientSecret" : "<clientSecret of agent2>"
}
},
...
}
These credentials are used when you create a named DesignAutomationClient
via DesignAutomationFactory.CreateClient(string name) where name
should match the name of the agent in configuration.
Please visit Learn Forge tutorial.
First you must add Autodesk.Forge.DesignAutomation services. This is usually done in ConfigureServices(...)
method of your Startup class. More information
NOTE: This example assumes that you are building an Asp.Net Core web api or website. If you want to use dependency injection in a console app then follow this example.
using Autodesk.Forge.DesignAutomation;
using Autodesk.Forge.DesignAutomation.Model;
...
public void ConfigureServices(IServiceCollection services)
{
services.AddDesignAutomation(this.Configuration);
}
Then you can use any of the API classes or interfaces in a constructor:
using Autodesk.Forge.DesignAutomation;
...
public class SomeApiController : ControllerBase
{
public SomeApiController(IWorkItemsApi forgeApi)
{
//use forgeApi here
}
using Autodesk.Forge.DesignAutomation;
using System.Net.Http;
using System.Threading.Tasks;
using Autodesk.Forge.Core;
internal class Program
{
public static void Main(string[] args)
{
var service =
new ForgeService(
new HttpClient(
new ForgeHandler(Microsoft.Extensions.Options.Options.Create(new ForgeConfiguration()
{
ClientId = "<your client id>",
ClientSecret = "<your client secret>"
}))
{
InnerHandler = new HttpClientHandler()
})
);
var forgeApi = new WorkItemsApi(service);
}
}
Using Semantic Version scheme following the pattern of x.y.z.
:
x
: MAJOR version when you make incompatible changes,y
: MINOR version when you add functionality in a backwards-compatible manner, andz
: PATCH version when you make backwards-compatible bug fixes.
Generated with swagger-codegen.
dotnet build Autodesk.Forge.DesignAutomation.sln
dotnet test Autodesk.Forge.DesignAutomation.sln
This sample is licensed under the terms of the Apache License 2.0. Please see the LICENSE file for full details.