ibms-dome/FrontendWebApi/ApiControllers/ModelDerivativeController.cs

56 lines
1.9 KiB
C#
Raw Permalink Normal View History

2022-11-14 09:41:12 +08:00
using Autodesk.Forge.Model;
using Autodesk.Forge;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
namespace FrontendWebApi.ApiControllers
{
public class ModelDerivativeController : ControllerBase //MyBaseApiController<ModelDerivativeController>//Controller
{
/// <summary>
/// Start the translation job for a give bucketKey/objectName
/// </summary>
/// <param name="objModel"></param>
/// <returns></returns>
[HttpPost]
[Route("api/forge/modelderivative/jobs")]
public async Task<dynamic> TranslateObject([FromBody] TranslateObjectModel objModel)
{
dynamic oauth = await OAuthController.GetInternalAsync();
// prepare the payload
List<JobPayloadItem> outputs = new List<JobPayloadItem>()
{
new JobPayloadItem(
JobPayloadItem.TypeEnum.Svf,
new List<JobPayloadItem.ViewsEnum>()
{
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;
}
/// <summary>
/// Model for TranslateObject method
/// </summary>
public class TranslateObjectModel
{
public string bucketKey { get; set; }
public string objectName { get; set; }
}
}
}