Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This Gist contains code snippets related to conversion STL files to BMP format using Aspose.CAD Cloud SDK for .NET
This Gist contains code snippets related to conversion STL files to BMP format using Aspose.CAD Cloud SDK for .NET
// For complete examples and data files, please go to https://github.com/aspose-cad-cloud/aspose-cad-cloud-dotnet
// Get client credentials from https://dashboard.aspose.cloud/
string clientSecret = "d757548a9f2558c39c2feebdf85b4c44";
string clientID = "4db2f826-bf9c-42e7-8b2a-8cbca2d15553";
// create an object of CADApi
CadApi cadApi = new CadApi(clientSecret,clientID);
// name of input FBSTL file
String inputFileName = "galeon.stl";
// resultant file format
String newFormat = "bmp";
// name of resultant file
String newFileName = "Converted.bmp";
try
{
// create an instance of
BmpOptionsDTO bmpOptionsDTO = new BmpOptionsDTO();
// create an instance of PostDrawingBmp class while providing input
// STL file name and BmpOptionsDTO objects as argument
var response = new PostDrawingBmpRequest(inputFileName, bmpOptionsDTO);
// initiate the conversion operation
var responseStream = cadApi.PostDrawingBmp(response);
saveToDisk(responseStream, @"C:\Users\shahbnay\Downloads\" + newFileName);
}catch (Exception ex)
{
Console.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
}
// custom method to save Stream content as file object
static void saveToDisk(Stream responseStream, String resultantFile)
{
var fileStream = File.Create(resultantFile);
responseStream.Seek(0, SeekOrigin.Begin);
responseStream.CopyTo(fileStream);
fileStream.Close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment