STL which has several backronyms like “Standard Triangle Language” and “Standard Tessellation Language” is a native file format to the stereolithography CAD software. The STL files describe only the surface geometry of a three-dimensional object without color, texture, or other attributes. In order to view the STL file, you need to use either of the following applications (i.e. Microsoft 3D Viewer, Microsoft Print 3D, IMSI TurboCAD Pro, GOM Inspect, etc). Some of these applications have license costs associated with them and if the recipient is on a mobile device, it gets quite difficult to view these files and provide quick feedback. So a quick and viable solution is to convert them to raster image formats such as BMP. Now lets discuss the conversion STL to BMP in C# using REST API.
CAD Files Processing API
Aspose.CAD Cloud is our REST-based API offering the capabilities to scale, rotate, flip, edit CAD drawings, or even export AutoCAD drawings to other supported formats, such as images (BMP, PNG, JPG), and fixed layout (PDF as a vector and as a raster). For further details, please visit supported file formats. Since the API is developed as per REST architecture, so we can incorporate it in desktop, mobile, web, and cloud-based applications.
To further facilitate our customers, we have created programming language-specific SDKs so that you get all the features/capabilities within your favorite programming language. This article will emphasize the utilization of Aspose.CAD Cloud SDK for .NET. Now in order to use the SDK, we need to first install it over the system. For related details, please visit How to install Aspose.Cloud SDKs.
STL to BMP in C#
Please follow the instructions below to convert STL files already available in Cloud and save the resultant BMP in Cloud storage. The PostDrawingBmp is used for conversion operations.
- Firstly, create an instance of File.Createclass while passing ClientID and ClientSecret details as arguments
- Secondly, create an object of BmpOptionsDTO class where we can provide properties for conversion operations
- Thirdly, create an instance of PostDrawingBmpRequest class by providing input STL filename and BmpOptionsDTO object as arguments
- Now call PostDrawingBmp(…) method to initiate the conversion operation
- Finally, save Stream instance as file using File.Create object
The sample files used in the above example can be downloaded from galeon.stl and converted.bmp.
Convert STL to BMP using cURL
Owing to the REST architecture of our APIs, they can easily be accessed via cURL commands on any platform. However a pre-requisite is to generate JWT access token based on ClientID and Client Secret details specified over Aspose.Cloud dashboard. Please execute the following command to generate JWT token.
curl -v "https://api.aspose.cloud/connect/token" \ -X POST \ -d "grant_type=client_credentials&client_id=4ccf1790-accc-41e9-8d18-a78dbb2ed1aa&client_secret=caac6e3d4a4724b2feb53f4e460eade3" \ -H "Content-Type: application/x-www-form-urlencoded" \ -H "Accept: application/json"
For further details, you may consider visiting How to Obtain JWT token using a Client ID and Client Secret key.
Now that we have got the JWT token, please execute the following command to convert STL file to BMP format and save the output on specified location.
curl -X GET "https://api.aspose.cloud/v3.0/cad/galeon.stl/saveAs/bmp" \ -H "accept: application/json" \ -H "authorization: Bearer <JWT Token>" \ -o Converted.bmp
We have discussed some very simple steps on how STL files can be converted to BMP raster image without using any 3rd party component. Also, the whole conversion operation has been performed in the Cloud without putting load on lcoal system. As our SDKs are developed under MIT license, so the complete source code can be downloaded from GitHub. If you encounter any issue or you have any related query, please feel free to contact us via free product support forum.
We also recommend visiting following links to learn about