Creating Text to colored mesh

Hi,

Is it possible to write a script in GHPython to create a text object and in the output represent both text and mesh object which could be defined colored mesh?

If someone knows that and how to write. I’ll appreciate the help.

Hello again, sorry for insisting on.
I’m grateful If someone could share an idea or any suggestion about my issue in helping me. :bouquet:

Could you be a little more clear for the input and output
Input
Text
Font
Size …
Thickness?
Output
Mesh (2d 3d ?)

you will find script that can do that if you search on old forum grasshopper3d.com

Hi @laurent_delrieu.
Sure, Thanks for the reply.
here’s my plan for the script:
Inputs:

  1. Text as strings (it’s better to be list access)
  2. Font
  3. Size(text height)
  4. color

Outputs:

  1. Mesh (2d)
  2. colored mesh
  3. text object

Thank you.

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

1 Like

@laurent_delrieu wonderful!
Thank you so much. for your help.
best