Convert OBJ to WMF in C#

OBJ files are used by CAD software for 2D and 3D drawings.We are able to create and save designs in the OBJ format, which is especially useful for building, bridge, and highway projects.In some cases, it may be necessary to programatically export drawings from OBJ files to WMF documents.With these conversions, drawings can be shared in a portable format.In this article, we will learn “how to convert a OBJ file to a WMF in C#.”

The following topics shall be covered in this article:

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

C# OBJ to WMF Converter – Free Download

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

The Image class of the API is the base class for all types of drawings. The ObjImage class represents a OBJ image. We can set PageWidth and PageHeight properties using the CadRasterizationOptions class. The WmfOptions class of the API allows specifying the WMF options.

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

PM> Install-Package Aspose.CAD

How to Convert OBJ File to WMF using C#

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

  • Load a OBJ drawing file.
  • Save OBJ as WMF.

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

Convert OBJ to WMF Programmatically in C#

Please follow the steps given below to convert a OBJ to a WMF:

  1. To begin, load an input OBJ file by utilizing the Image class.
  2. After that, create an instance of the class “WmfOptions.”
  3. Finally, save it as a WMF by calling the Save() method. It takes as its arguments the WmfOptions and the path to the output WMF file.

The following code sample shows how to convert a OBJ file to a WMF document using C#.

Export OBJ to WMF with Options in C#

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

  1. To begin, load an input OBJ file by utilizing the Image class.
  2. Next, make a case of the class “CadRasterizationOptions.”
  3. Next, specify the page’s width and height.
  4. Create an instance of the class “WmfOptions” after that.
  5. After that, replace “VectorRasterizationOptions” with “CadRasterizationOptions” as the property’s value.
  6. Finally, save it as a WMF by calling the Save() method. It takes as its arguments the WmfOptions and the path to the output WMF file.

The following code sample shows how to specify the page height and width while saving a OBJ file as a WMF 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 OBJ drawing file that already exists;
  • specify the page’s width and height;
  • define options for saving;
  • in C#, save the OBJ as a WMF.

OBJ files are used by Wavefront’s Advanced Visualizer application to define and store the geometric objects. Backward and forward transmission of geometric data is made possible through OBJ files. Both polygonal geometry like points, lines, texture vertices, faces and free-form geometry (curves and surfaces) are supported by OBJ format. This format does not support animation or information related to light and position of scenes. Besides converting a OBJ to a WMF 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