Convert SVG to OBJ in C#

Drawings in 2D or 3D are produced using CAD software using SVG files. In particular, we are able to generate and preserve plans for construction projects like roads, bridges, and buildings in an SVG file. In some circumstances, we might need to programmatically export drawings from SVG files to OBJ documents. Drawings may be shared in a portable format thanks to these adaptations. Learn how to convert an SVG file to an OBJ in C# in this post.

The following topics shall be covered in this article:

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

C# SVG to OBJ Converter – Free Download

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

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

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

PM> Install-Package Aspose.CAD

How to Convert SVG File to OBJ using C#

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

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

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

Convert SVG to OBJ Programmatically in C#

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

1.Utilizing the Image class, load an input SVG file initially. 2.Create an instance of the ObjOptions class after that. 3.Finally, save it as an OBJ by calling the Save() method.ObjOptions and the path to the output OBJ file are its arguments.

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

Export SVG to OBJ with Options in C#

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

1.Utilizing the Image class, load an input SVG file initially. 2.Next, make an instance of the class “CadRasterizationOptions.” 3.Then, specify the width and height of the page. 4.Next, make an instance of the class “ObjOptions.” 5.After that, change the value of the property “VectorRasterizationOptions” to “CadRasterizationOptions.” 6.Finally, save it as an OBJ by calling the Save() method.ObjOptions and the path to the output OBJ file are its arguments.

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

An SVG file is a Scalar Vector Graphics file that uses XML based text format for describing the appearance of an image. The word Scalable refers to the fact that the SVG can be scaled to different sizes without losing any quality. Text-based description of such files makes them independent of resolution. It is one of the most used formats for building a website and print graphics in order to achieve scalability. Besides converting a SVG to a OBJ 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