Convert CF2 to DXF in C#

CAD applications use CF2 files for creating 2D or 3D drawings. Specifically, we can create and save designs for construction projects such as highways, bridges, and buildings in a CF2 file. In certain cases, we may need to export drawings from CF2 files to DXF documents programmatically. Such conversions allow sharing of drawings in a portable format. In this article, we will learn how to convert a CF2 file to a DXF in C#.

The following topics shall be covered in this article:

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

C# CF2 to DXF Converter – Free Download

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

The Image class of the API is the base class for all types of drawings. The Cf2Image class represents a CF2 image. We can set PageWidth and PageHeight properties using the CadRasterizationOptions class. The DxfOptions class of the API allows specifying the DXF options.

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

PM> Install-Package Aspose.CAD

How to Convert CF2 File to DXF using C#

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

  • Load a CF2 drawing file.
  • Save CF2 as DXF.

Now, let’s see how to perform these steps in C# to convert a CF2 file to a DXF document.

Convert CF2 to DXF Programmatically in C#

Please follow the steps given below to convert a CF2 to a DXF:

  1. Firstly, load an input CF2 file using the Image class.
  2. After that, create an instance of the DxfOptions class.
  3. Finally, call Save() method to save it as a DXF. It takes the output DXF file path and DxfOptions as arguments.

The following code sample shows how to convert a CF2 file to a DXF document using C#.

Export CF2 to DXF with Options in C#

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

  1. Firstly, load an input CF2 file using the Image class.
  2. Next, create an instance of the CadRasterizationOptions class.
  3. Then, specify the page height and width.
  4. Next, create an instance of the DxfOptions class.
  5. After that, set the VectorRasterizationOptions property as CadRasterizationOptions.
  6. Finally, call Save() method to save it as a DXF. It takes the output DXF file path and DxfOptions as arguments.

The following code sample shows how to specify the page height and width while saving a CF2 file as a DXF 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 CF2 drawing file;
  • specify page height and width;
  • define save options;
  • save CF2 as a DXF in C#.

Besides converting a CF2 to a DXF in C#, 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