# 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 text = new Text(Plane.XY, new Point2D(5, 25), "Eyeshot", 5);
double radius = 20;

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

// you can rotate it and translate it
cylinder.Rotate(0.5, Vector3D.AxisY, Point3D.Origin);
cylinder.Translate(0, 0, 10);Plane pln = ((PlanarSurf)cylinder.Faces[1].Surface).Plane;
``````

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

``````private void CreateCylindricalTextMesh(Plane pln,Text text, Model model1, double radius)
{
Align3D t = new Align3D(Plane.XY, pln);

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

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(radius * Math.Cos(x / radius), radius * Math.Sin(x / radius), y);

pt.TransformBy(t);

m.Vertices[j] = pt;
}

finalMeshes[i] = m;
}

model1.Invalidate();
}
``````

# Cylinder as Mesh

If you have a Mesh instead of a Brep 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:

``````double radius=10;
Mesh cylinder = Mesh.CreateCylinder(radius, 50, 100);
Plane 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:

``````CreateCylindricalTextMesh(pln, text, model1, radius);
``````

Final result: