Convert text to braille

Here is a little script


You have to right click on Id then “Set Multiple Guids”, normally you could select all the objects you want.

Then slect in Rhino, click enter if OK.
Surface will appears, you can extrude then,…
When OK you could bake the geometry in Rhino.
braille from textobject.gh (5.4 KB)

//Rhino.DocObjects.TextObject obj = (Rhino.DocObjects.TextObject) RhinoDocument.Objects.FindId(guid);
    var objet = RhinoDocument.Objects.FindId(guid);

    //Data from wikipedia
    string ascii = " A1B'K2L@CIF/MSP\"E3H9O6R^DJG>NTQ,*5<-U8V.%[$+X!&;:4\\0Z7(_?W]#Y)=";
    var charsAscii = ascii.ToCharArray();

    string braille = "⠀⠁⠂⠃⠄⠅⠆⠇⠈⠉⠊⠋⠌⠍⠎⠏⠐⠑⠒⠓⠔⠕⠖⠗⠘⠙⠚⠛⠜⠝⠞⠟⠠⠡⠢⠣⠤⠥⠦⠧⠨⠩⠪⠫⠬⠭⠮⠯⠰⠱⠲⠳⠴⠵⠶⠷⠸⠹⠺⠻⠼⠽⠾⠿";
    var charsBraille = braille.ToCharArray();

    if(objet is Rhino.DocObjects.TextObject)
    {
      Rhino.DocObjects.TextObject obj = ( Rhino.DocObjects.TextObject) objet;
      //get the text of text object
      string brailleString = obj.DisplayText.ToUpper();
      //Conversion to Braille
      for (int i = 0; i < charsAscii.Length; i++)
      {
        brailleString = brailleString.Replace(charsAscii[i], charsBraille[i]);
      }
      //To surface
      if(size == 0) size = 5;

      Rhino.DocObjects.Font.FontStyle fontStyle = Rhino.DocObjects.Font.FontStyle.Upright;
      Rhino.DocObjects.Font.FontWeight fontWeight = Rhino.DocObjects.Font.FontWeight.Normal;
      bool underlined = false;
      bool strikethrough = false;
      Rhino.DocObjects.Font font = new Rhino.DocObjects.Font(face, fontWeight, fontStyle, underlined, strikethrough);
      BoundingBox bb = obj.Geometry.GetBoundingBox(false);
      Plane plane = new Plane(bb.Min + Vector3d.YAxis * size, Vector3d.XAxis, Vector3d.YAxis);

      TextEntity text_entity = new TextEntity
        {
          Plane = plane,
          PlainText = brailleString,
          Justification = TextJustification.BottomRight,
          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);
    }
4 Likes