How to draw a text on a cylindrical surface

First of all, add a text (on plane XY) and a cylinder to the scene:

text = new Text(Plane.XY, new Point2D(5, 25), "Eyeshot", 11);

radius = 10;

// if using Solid3D
cylinder = Solid3D.CreateCylinder(radius, 50, 100);

// you can rotate it and translate it
cylinder.Rotate(0.5, Vector3D.AxisY, Point3D.Origin);
cylinder.Translate(0, 0, 10);

Then use the following code to create a text on a cylinder:

private void CreateCylindricalTextMesh(Plane pln)
    Align3D t = new Align3D(Plane.XY, pln);

    Mesh[] textMeshes = text.ConvertToMesh(viewportLayout1);

    Mesh[] finalMeshes = new Mesh[textMeshes.Length];
    for (var i = 0; i < textMeshes.Length; i++)
        Mesh m = (Mesh)textMeshes[i].Clone();
        m.LightWeight = false;
        for (int j = 0; j < m.Vertices.Length; j++)
            double x = m.Vertices[j].X;
            double y = m.Vertices[j].Y;

            Point3D pt = new Point3D(r * Math.Cos(x / r), r * Math.Sin(x / r), y);


            m.Vertices[j] = pt;

        finalMeshes[i] = m;



If you use a Solid3D you can call it in this way:

// Cylindrical face base plane
Plane pln = ((PlanarSurf)cylinder.Faces[1].Surface).Plane;


Cylinder as Mesh

If you have a Mesh instead of a Solid3D you must keep a Plane "synchronized" with that Mesh.

For example, if you rotate and translate the Mesh you have to apply the same transformation to that Plane:

cylinder = Mesh.CreateCylinder(r, 50, 100);
pln = Plane.XY;

cylinder.Rotate(0.5, Vector3D.AxisY, Point3D.Origin);
cylinder.Translate(0, 0, 10);

pln.Rotate(0.5, Vector3D.AxisY, Point3D.Origin);
pln.Translate(0, 0, 10);

Then call the method in this way:


Final result:

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request



Please sign in to leave a comment.