Creating Text to colored mesh

Here is a small script. There are 2 C#, one ouputting all fonts (424 for me) and one outputing Brep. Brep are changed to mesh outside C#. It is surely not difficult to do it inside, so you can do it.
There is no placement of the text.
I am quite sure many plugins do this type of work but it was interesting to remake this script with the new Rhino 6 objects.


Frame_
text_curve_rhino6.gh (10.4 KB)

And for the record
https://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_DocObjects_Font.htm
https://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_Geometry_TextEntity.htm

    if(content != null && content != String.Empty
    && face != null && face != String.Empty )
    {
      if(size == 0)
        size = 5;
      Rhino.DocObjects.Font.FontStyle fontStyle = Rhino.DocObjects.Font.FontStyle.Upright;
      if (italics) fontStyle = Rhino.DocObjects.Font.FontStyle.Italic;
      Rhino.DocObjects.Font.FontWeight fontWeight = Rhino.DocObjects.Font.FontWeight.Normal;
      if (bold) fontWeight = Rhino.DocObjects.Font.FontWeight.Bold;

      bool underlined = false;
      bool strikethrough = false;

      Rhino.DocObjects.Font font = new Rhino.DocObjects.Font(face, fontWeight, fontStyle, underlined, strikethrough);
      TextEntity text_entity = new TextEntity
        {
          Plane = Plane.WorldXY,
          PlainText = content,
          Justification = TextJustification.MiddleCenter,
          Font = font
          };
      Rhino.DocObjects.DimensionStyle dimstyle = new Rhino.DocObjects.DimensionStyle();
      dimstyle.TextHeight = size;
      double smallCapsScale = 1;
      double spacing = 0;
      A = text_entity.CreateSurfaces(dimstyle, smallCapsScale, spacing);
    } 
    else 
    {
      Print("Some content is required.");
    }

And see this

2 Likes