using Autodesk.Forge; using Autodesk.Forge.Model; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using System.Collections.Generic; using System.Threading.Tasks; namespace forgeSample.Controllers { [ApiController] public class ModelDerivativeController : ControllerBase { private static IConfiguration _configuration; public ModelDerivativeController(IConfiguration configuration) { _configuration = configuration; } /// /// Start the translation job for a give bucketKey/objectName /// /// /// [HttpPost] [Route("api/forge/modelderivative/jobs")] public async Task TranslateObject([FromBody] TranslateObjectModel objModel) { dynamic oauth = await OAuthController.GetInternalAsync(_configuration); // prepare the payload List outputs = new List() { new JobPayloadItem( JobPayloadItem.TypeEnum.Svf, new List() { JobPayloadItem.ViewsEnum._2d, JobPayloadItem.ViewsEnum._3d }) }; JobPayload job; job = new JobPayload(new JobPayloadInput(objModel.objectName), new JobPayloadOutput(outputs)); // start the translation DerivativesApi derivative = new DerivativesApi(); derivative.Configuration.AccessToken = oauth.access_token; dynamic jobPosted = await derivative.TranslateAsync(job); return jobPosted; } /// /// Model for TranslateObject method /// public class TranslateObjectModel { public string bucketKey { get; set; } public string objectName { get; set; } } } }