Cylinders are commonly used in three-dimensional scenes. In different graphics processing applications, you may need to create different types of cylinders. Here we will discuss how to make various kinds of three-dimensional cylinders with different transforms and variations. It explains how to create a 3D cylinder with a shear bottom, shear top, and fan cylinder with different theta lengths programmatically in C#.

Create 3D Cylinders Programmatically – C# API Installation

Aspose.3D for .NET API can be used to create or manipulate 3D scenes and objects. Moreover, you do not need to install any other 3D processing applications or tools to work with the API. Just configure the API quickly from the New Releases page or run the NuGet installation command below:

PM> Install-Package Aspose.3D

Make a Cylinder in C#

You can make a cylinder in a three-dimensional scene by following the steps below:

  1. Initialize an object of the Scene class.
  2. Set the vertices to transform the offset of the bottom side.
  3. Add the cylinder to the scene.
  4. Create another cylinder and customize the shear bottom.
  5. Add the cylinder and Save the output scene.

The code snippet below demonstrates how to follow these steps and make a cylinder programmatically in C#:

Moreover, the following image shows the output image generated using the above code snippet.

Make 3D Cylinder C#

Create a Fan Cylinder in C#

The following steps explain how to create a fan cylinder in a 3D scene:

  1. Create a Scene class object.
  2. Create a cylinder and set GenerateFanCylinder to true.
  3. Set the length of theta and create a child node.
  4. Create a cylinder without a fan and repeat the above steps.
  5. Save the output scene.

The following code snippet elaborates on how to create a fan cylinder programmatically in C#:

The following screenshot shows the output scene created using this sample code:

Make 3D Fan Cylinder C#

Get Free Temporary License

You may request a free temporary license to test the API to its full capacity.

Conclusion

In this article, you have learned how to create a 3D cylinder programmatically in C#. It covers how to modify the code snippet to create a variety of cylinder shapes. Furthermore, you can explore many other features of the API by taking a look at the documentation section. In case of any ambiguities, please reach out to us at forum.

See Also

Convert MA to USDZ File in C#