Convert IFC to PNG in C#

IFC file format provides interoperability between different software applications In certain cases, we may need to export drawings from IFC files to PNG documents programmatically. Such conversions allow sharing of drawings in a portable format.

The following topics shall be covered in this article:

  1. C# IFC to PNG Converter – Free Download
  2. Steps to Convert IFC File to PNG Document
  3. Convert IFC to PNG Programmatically
  4. Export IFC to PNG with Options

C# IFC to PNG Converter – Free Download

To convert a IFC file to a PNG document, we will be using the Aspose.CAD for .NET API. It allows creating, editing, and manipulating IFC files and several other file formats.

The API’s base class for all types of drawings is the Image class. A IFC image is represented by the IfcImage class. The CadRasterizationOptions class allows us to modify the [PageWidth] and [PageHeight] properties.The PNG options can be specified using the API’s PngOptions class.

Please either download the DLL of the API or install it using NuGet.

PM> Install-Package Aspose.CAD

How to Convert IFC File to PNG using C#

We can easily convert a IFC file to a PNG document using Aspose.CAD for .NET by following the steps given below:

  • Load a IFC drawing file.
  • Save IFC as PNG.

Steps in C# to convert a IFC file to a PNG document.

Convert IFC to PNG Programmatically in C#

Steps given below to convert a IFC to a PNG:

  1. Load an input IFC file using the Image class.
  2. Create an instance of the PngOptions class.
  3. Call Save() method to save it as a PNG. It takes the output PNG file path and PngOptions as arguments.

The following code sample shows how to convert a IFC file to a PNG document using C#.

Export IFC to PNG with Options in C#

We can specify PNG save options while converting a IFC file to a PNG document by following the steps given below:

  1. Load an input IFC file using the Image class.
  2. Create an instance of the CadRasterizationOptions class.
  3. Specify the page height and width.
  4. Create an instance of the PngOptions class.
  5. Set the VectorRasterizationOptions property as CadRasterizationOptions.
  6. Call Save() method to save it as a PNG. It takes the output PNG file path and PngOptions as arguments.

The following code sample shows how to specify the page height and width while saving a IFC file as a PNG document using C#.

Get Free Temporary License

You can get a free temporary license to try the library without evaluation limitations.

Conclusion

In this article, we have learned how to:

  • load an existing IFC drawing file;
  • specify page height and width;
  • define save options;
  • save IFC as a PNG in C#.

PNG is short for Portable Network Graphic, a type of raster image file. PNG files, which use the .png extension, can handle 16 million colors — which definitely sets them apart from most file types. You can learn more about Aspose.CAD for .NET API using the documentation. In case of any ambiguity, please feel free to contact us on our free support forum.

See Also