Skip to content

Instantly share code, notes, and snippets.

@aspose-cloud
Last active November 1, 2021 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-cloud/d461d3a8cc9b171927f114ecb4e5d6c5 to your computer and use it in GitHub Desktop.
Save aspose-cloud/d461d3a8cc9b171927f114ecb4e5d6c5 to your computer and use it in GitHub Desktop.
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